Skip to content
Snippets Groups Projects
Commit f0dd4f56 authored by Jeff Wallace's avatar Jeff Wallace
Browse files

Updated output formatting and added return value enumeration.

parent 02984502
Branches
Tags
No related merge requests found
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
# #
# http://wiki.sleuthkit.org/index.php?title=Autopsy_3_Module_Versions # http://wiki.sleuthkit.org/index.php?title=Autopsy_3_Module_Versions
# #
# The basic idea is that this script uses javadoc/jdiff to # The basic idea is that this script uses javadoc/jdiff to
# compare the current state of the source code to the last # compare the current state of the source code to the last
# tag and identifies if APIs were removed, added, etc. # tag and identifies if APIs were removed, added, etc.
# #
# When run from the Autopsy build script, this script will: # When run from the Autopsy build script, this script will:
# - Clone Autopsy and checkout to the previous release tag # - Clone Autopsy and checkout to the previous release tag
...@@ -61,6 +61,12 @@ ...@@ -61,6 +61,12 @@
from tempfile import mkstemp from tempfile import mkstemp
from xml.dom.minidom import parse, parseString 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 # An Autopsy module object
class Module: class Module:
# Initialize it with a name, return code, and version numbers # Initialize it with a name, return code, and version numbers
...@@ -218,11 +224,11 @@ def compare_xml(module, apiname_tag, apiname_cur): ...@@ -218,11 +224,11 @@ def compare_xml(module, apiname_tag, apiname_cur):
log.close() log.close()
code = jdiff.returncode code = jdiff.returncode
print("Compared XML for " + module.name) print("Compared XML for " + module.name)
if code == 100: if code == NO_CHANGES:
print(" No API changes") print(" No API changes")
elif code == 101: elif code == COMPATIBLE:
print(" API Changes are backwards compatible") print(" API Changes are backwards compatible")
elif code == 102: elif code == NON_COMPATIBLE:
print(" API Changes are not backwards compatible") print(" API Changes are not backwards compatible")
else: else:
print(" *Error in XML, most likely an empty module") print(" *Error in XML, most likely an empty module")
...@@ -564,18 +570,18 @@ def update_versions(modules, source): ...@@ -564,18 +570,18 @@ def update_versions(modules, source):
if manifest == None or project == None: if manifest == None or project == None:
print(" Error finding manifeset and project properties files") print(" Error finding manifeset and project properties files")
return return
if module.ret == 101: if module.ret == COMPATIBLE:
versions = [versions[0].set(versions[0].increment()), versions[1] + 1, versions[2]] versions = [versions[0].set(versions[0].increment()), versions[1] + 1, versions[2]]
set_specification(project, manifest, versions[0]) set_specification(project, manifest, versions[0])
set_implementation(manifest, versions[1]) set_implementation(manifest, versions[1])
module.set_versions(versions) 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] versions = [versions[0].set(versions[0].overflow()), versions[1] + 1, versions[2] + 1]
set_specification(project, manifest, versions[0]) set_specification(project, manifest, versions[0])
set_implementation(manifest, versions[1]) set_implementation(manifest, versions[1])
set_release(manifest, versions[2]) set_release(manifest, versions[2])
module.set_versions(versions) module.set_versions(versions)
elif module.ret == 100: elif module.ret == NO_CHANGES:
versions = [versions[0], versions[1] + 1, versions[2]] versions = [versions[0], versions[1] + 1, versions[2]]
set_implementation(manifest, versions[1]) set_implementation(manifest, versions[1])
module.set_versions(versions) module.set_versions(versions)
...@@ -624,48 +630,40 @@ def print_version_updates(modules): ...@@ -624,48 +630,40 @@ def print_version_updates(modules):
f = open("gen_version.txt", "a") f = open("gen_version.txt", "a")
for module in modules: for module in modules:
versions = module.versions versions = module.versions
if module.ret == 101: if module.ret == COMPATIBLE:
output = (module.name + ":\n") output = (module.name + ":\n")
output += (" Current Specification version:\t" + str(versions[0]) + "\n") output += ("\tSpecification:\t" + str(versions[0]) + "\t->\t" + str(versions[0].increment()) + "\n")
output += (" Updated Specification version:\t" + str(versions[0].increment()) + "\n") output += ("\tImplementation:\t" + str(versions[1]) + "\t->\t" + str(versions[1] + 1) + "\n")
output += ("\n") output += ("\tRelease:\tNo Change.\n")
output += (" Current Implementation version:\t" + str(versions[1]) + "\n")
output += (" Updated Implementation version:\t" + str(versions[1] + 1) + "\n")
output += ("\n") output += ("\n")
print(output) print(output)
sys.stdout.flush() sys.stdout.flush()
f.write(output) f.write(output)
elif module.ret == 102: elif module.ret == NON_COMPATIBLE:
output = (module.name + ":\n") output = (module.name + ":\n")
output += (" Current Specification version:\t" + str(versions[0]) + "\n") output += ("\tSpecification:\t" + str(versions[0]) + "\t->\t" + str(versions[0].overflow()) + "\n")
output += (" Updated Specification version:\t" + str(versions[0].overflow()) + "\n") output += ("\tImplementation:\t" + str(versions[1]) + "\t->\t" + str(versions[1] + 1) + "\n")
output += ("\n") output += ("\tRelease:\t" + str(versions[2]) + "\t->\t" + str(versions[2] + 1) + "\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 += ("\n") output += ("\n")
print(output) print(output)
sys.stdout.flush() sys.stdout.flush()
f.write(output) f.write(output)
elif module.ret == 1: elif module.ret == ERROR:
output = (module.name + ":\n") output = (module.name + ":\n")
output += (" *Unable to detect necessary changes\n") output += ("\t*Unable to detect necessary changes\n")
output += (" Current Specification version:\t" + str(versions[0]) + "\n") output += ("\tSpecification:\t" + str(versions[0]) + "\n")
output += (" Current Implementation version:\t" + str(versions[1]) + "\n") output += ("\tImplementation:\t" + str(versions[1]) + "\n")
output += (" Current Release version:\t\t" + str(versions[2]) + "\n") output += ("\tRelease:\t\t" + str(versions[2]) + "\n")
output += ("\n") output += ("\n")
print(output) print(output)
f.write(output) f.write(output)
sys.stdout.flush() sys.stdout.flush()
elif module.ret == 100: elif module.ret == NO_CHANGES:
output = (module.name + ":\n") output = (module.name + ":\n")
if versions[1] is None: if versions[1] is None:
output += (" No Implementation version.\n") output += ("\tImplementation: None\n")
else: else:
output += (" Current Implementation version:\t" + str(versions[1]) + "\n") output += ("\tImplementation:\t" + str(versions[1]) + "\t->\t" + str(versions[1] + 1) + "\n")
output += (" Updated Implementation version:\t" + str(versions[1] + 1) + "\n")
output += ("\n") output += ("\n")
print(output) print(output)
sys.stdout.flush() sys.stdout.flush()
...@@ -673,16 +671,13 @@ def print_version_updates(modules): ...@@ -673,16 +671,13 @@ def print_version_updates(modules):
elif module.ret is None: elif module.ret is None:
output = ("Added " + module.name + ":\n") output = ("Added " + module.name + ":\n")
if module.spec() != "1.0" and module.spec() != "0.0": if module.spec() != "1.0" and module.spec() != "0.0":
output += (" Current Specification version:\t" + str(module.spec()) + "\n") output += ("\tSpecification:\t" + str(module.spec()) + "\t->\t" + "1.0\n")
output += (" Updated Specification version:\t1.0\n")
output += ("\n") output += ("\n")
if module.impl() != 1: if module.impl() != 1:
output += (" Current Implementation version:\t" + str(module.impl()) + "\n") output += ("\tImplementation:\t" + str(module.impl()) + "\t->\t" + "1\n")
output += (" Updated Implementation version:\t1\n")
output += ("\n") output += ("\n")
if module.release() != 1 and module.release() != 0: if module.release() != 1 and module.release() != 0:
output += (" Current Release version:\t\t" + str(module.release()) + "\n") output += ("Release:\t\t" + str(module.release()) + "\t->\t" + "1\n")
output += (" Updated Release version:\t\t1\n")
output += ("\n") output += ("\n")
print(output) print(output)
sys.stdout.flush() sys.stdout.flush()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment