mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Updated output formatting and added return value enumeration.
This commit is contained in:
parent
0298450238
commit
f0dd4f5687
@ -61,6 +61,12 @@ from shutil import move
|
||||
from tempfile import mkstemp
|
||||
from xml.dom.minidom import parse, parseString
|
||||
|
||||
# Jdiff return codes. Described in more detail further on
|
||||
NO_CHANGES = 100
|
||||
COMPATIBLE = 101
|
||||
NON_COMPATIBLE = 102
|
||||
ERROR = 1
|
||||
|
||||
# An Autopsy module object
|
||||
class Module:
|
||||
# Initialize it with a name, return code, and version numbers
|
||||
@ -218,11 +224,11 @@ def compare_xml(module, apiname_tag, apiname_cur):
|
||||
log.close()
|
||||
code = jdiff.returncode
|
||||
print("Compared XML for " + module.name)
|
||||
if code == 100:
|
||||
if code == NO_CHANGES:
|
||||
print(" No API changes")
|
||||
elif code == 101:
|
||||
elif code == COMPATIBLE:
|
||||
print(" API Changes are backwards compatible")
|
||||
elif code == 102:
|
||||
elif code == NON_COMPATIBLE:
|
||||
print(" API Changes are not backwards compatible")
|
||||
else:
|
||||
print(" *Error in XML, most likely an empty module")
|
||||
@ -564,18 +570,18 @@ def update_versions(modules, source):
|
||||
if manifest == None or project == None:
|
||||
print(" Error finding manifeset and project properties files")
|
||||
return
|
||||
if module.ret == 101:
|
||||
if module.ret == COMPATIBLE:
|
||||
versions = [versions[0].set(versions[0].increment()), versions[1] + 1, versions[2]]
|
||||
set_specification(project, manifest, versions[0])
|
||||
set_implementation(manifest, versions[1])
|
||||
module.set_versions(versions)
|
||||
elif module.ret == 102:
|
||||
elif module.ret == NON_COMPATIBLE:
|
||||
versions = [versions[0].set(versions[0].overflow()), versions[1] + 1, versions[2] + 1]
|
||||
set_specification(project, manifest, versions[0])
|
||||
set_implementation(manifest, versions[1])
|
||||
set_release(manifest, versions[2])
|
||||
module.set_versions(versions)
|
||||
elif module.ret == 100:
|
||||
elif module.ret == NO_CHANGES:
|
||||
versions = [versions[0], versions[1] + 1, versions[2]]
|
||||
set_implementation(manifest, versions[1])
|
||||
module.set_versions(versions)
|
||||
@ -624,48 +630,40 @@ def print_version_updates(modules):
|
||||
f = open("gen_version.txt", "a")
|
||||
for module in modules:
|
||||
versions = module.versions
|
||||
if module.ret == 101:
|
||||
if module.ret == COMPATIBLE:
|
||||
output = (module.name + ":\n")
|
||||
output += (" Current Specification version:\t" + str(versions[0]) + "\n")
|
||||
output += (" Updated Specification version:\t" + str(versions[0].increment()) + "\n")
|
||||
output += ("\n")
|
||||
output += (" Current Implementation version:\t" + str(versions[1]) + "\n")
|
||||
output += (" Updated Implementation version:\t" + str(versions[1] + 1) + "\n")
|
||||
output += ("\tSpecification:\t" + str(versions[0]) + "\t->\t" + str(versions[0].increment()) + "\n")
|
||||
output += ("\tImplementation:\t" + str(versions[1]) + "\t->\t" + str(versions[1] + 1) + "\n")
|
||||
output += ("\tRelease:\tNo Change.\n")
|
||||
output += ("\n")
|
||||
print(output)
|
||||
sys.stdout.flush()
|
||||
f.write(output)
|
||||
elif module.ret == 102:
|
||||
elif module.ret == NON_COMPATIBLE:
|
||||
output = (module.name + ":\n")
|
||||
output += (" Current Specification version:\t" + str(versions[0]) + "\n")
|
||||
output += (" Updated Specification version:\t" + str(versions[0].overflow()) + "\n")
|
||||
output += ("\n")
|
||||
output += (" Current Implementation version:\t" + str(versions[1]) + "\n")
|
||||
output += (" Updated Implementation version:\t" + str(versions[1] + 1) + "\n")
|
||||
output += ("\n")
|
||||
output += (" Current Release version:\t\t" + str(versions[2]) + "\n")
|
||||
output += (" Updated Release version:\t\t" + str(versions[2] + 1) + "\n")
|
||||
output += ("\tSpecification:\t" + str(versions[0]) + "\t->\t" + str(versions[0].overflow()) + "\n")
|
||||
output += ("\tImplementation:\t" + str(versions[1]) + "\t->\t" + str(versions[1] + 1) + "\n")
|
||||
output += ("\tRelease:\t" + str(versions[2]) + "\t->\t" + str(versions[2] + 1) + "\n")
|
||||
output += ("\n")
|
||||
print(output)
|
||||
sys.stdout.flush()
|
||||
f.write(output)
|
||||
elif module.ret == 1:
|
||||
elif module.ret == ERROR:
|
||||
output = (module.name + ":\n")
|
||||
output += (" *Unable to detect necessary changes\n")
|
||||
output += (" Current Specification version:\t" + str(versions[0]) + "\n")
|
||||
output += (" Current Implementation version:\t" + str(versions[1]) + "\n")
|
||||
output += (" Current Release version:\t\t" + str(versions[2]) + "\n")
|
||||
output += ("\t*Unable to detect necessary changes\n")
|
||||
output += ("\tSpecification:\t" + str(versions[0]) + "\n")
|
||||
output += ("\tImplementation:\t" + str(versions[1]) + "\n")
|
||||
output += ("\tRelease:\t\t" + str(versions[2]) + "\n")
|
||||
output += ("\n")
|
||||
print(output)
|
||||
f.write(output)
|
||||
sys.stdout.flush()
|
||||
elif module.ret == 100:
|
||||
elif module.ret == NO_CHANGES:
|
||||
output = (module.name + ":\n")
|
||||
if versions[1] is None:
|
||||
output += (" No Implementation version.\n")
|
||||
output += ("\tImplementation: None\n")
|
||||
else:
|
||||
output += (" Current Implementation version:\t" + str(versions[1]) + "\n")
|
||||
output += (" Updated Implementation version:\t" + str(versions[1] + 1) + "\n")
|
||||
output += ("\tImplementation:\t" + str(versions[1]) + "\t->\t" + str(versions[1] + 1) + "\n")
|
||||
output += ("\n")
|
||||
print(output)
|
||||
sys.stdout.flush()
|
||||
@ -673,16 +671,13 @@ def print_version_updates(modules):
|
||||
elif module.ret is None:
|
||||
output = ("Added " + module.name + ":\n")
|
||||
if module.spec() != "1.0" and module.spec() != "0.0":
|
||||
output += (" Current Specification version:\t" + str(module.spec()) + "\n")
|
||||
output += (" Updated Specification version:\t1.0\n")
|
||||
output += ("\tSpecification:\t" + str(module.spec()) + "\t->\t" + "1.0\n")
|
||||
output += ("\n")
|
||||
if module.impl() != 1:
|
||||
output += (" Current Implementation version:\t" + str(module.impl()) + "\n")
|
||||
output += (" Updated Implementation version:\t1\n")
|
||||
output += ("\tImplementation:\t" + str(module.impl()) + "\t->\t" + "1\n")
|
||||
output += ("\n")
|
||||
if module.release() != 1 and module.release() != 0:
|
||||
output += (" Current Release version:\t\t" + str(module.release()) + "\n")
|
||||
output += (" Updated Release version:\t\t1\n")
|
||||
output += ("Release:\t\t" + str(module.release()) + "\t->\t" + "1\n")
|
||||
output += ("\n")
|
||||
print(output)
|
||||
sys.stdout.flush()
|
||||
|
Loading…
x
Reference in New Issue
Block a user