Commit e9a9d050 by devttys0

Added improved version.py

parent 8e6e02e4
...@@ -11,7 +11,7 @@ MODULE_NAME = "binwalk" ...@@ -11,7 +11,7 @@ MODULE_NAME = "binwalk"
MODULE_VERSION = "2.2.0" MODULE_VERSION = "2.2.0"
SCRIPT_NAME = MODULE_NAME SCRIPT_NAME = MODULE_NAME
MODULE_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) MODULE_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
VERSION_FILE = os.path.join(MODULE_DIRECTORY, "src", "binwalk", "core", "version.py") #VERSION_FILE = os.path.join(MODULE_DIRECTORY, "src", "binwalk", "core", "version.py")
# Python3 has a built-in DEVNULL; for Python2, we have to open # Python3 has a built-in DEVNULL; for Python2, we have to open
# os.devnull to redirect subprocess stderr output to the ether. # os.devnull to redirect subprocess stderr output to the ether.
...@@ -221,12 +221,12 @@ class CleanCommand(Command): ...@@ -221,12 +221,12 @@ class CleanCommand(Command):
pass pass
def run(self): def run(self):
sys.stdout.write("removing '%s'\n" % (VERSION_FILE)) #sys.stdout.write("removing '%s'\n" % (VERSION_FILE))
try: #try:
os.remove(VERSION_FILE) # os.remove(VERSION_FILE)
except OSError as e: #except OSError as e:
sys.stderr.write("failed to remove file '%s': %s\n" % (VERSION_FILE, str(e))) # sys.stderr.write("failed to remove file '%s': %s\n" % (VERSION_FILE, str(e)))
try: try:
remove_tree(os.path.join(MODULE_DIRECTORY, "build")) remove_tree(os.path.join(MODULE_DIRECTORY, "build"))
...@@ -329,16 +329,16 @@ for data_dir in ["magic", "config", "plugins", "modules", "core"]: ...@@ -329,16 +329,16 @@ for data_dir in ["magic", "config", "plugins", "modules", "core"]:
# If doing a build or installation, then create a version.py file # If doing a build or installation, then create a version.py file
# which defines the current binwalk version. This file is excluded # which defines the current binwalk version. This file is excluded
# from git in the .gitignore file. # from git in the .gitignore file.
if 'install' in ' '.join(sys.argv) or 'build' in ' '.join(sys.argv) or 'sdist' in ' '.join(sys.argv): #if 'install' in ' '.join(sys.argv) or 'build' in ' '.join(sys.argv) or 'sdist' in ' '.join(sys.argv):
sys.stdout.write("creating %s\n" % (VERSION_FILE)) # sys.stdout.write("creating %s\n" % (VERSION_FILE))
#
try: # try:
with open(VERSION_FILE, "w") as fp: # with open(VERSION_FILE, "w") as fp:
fp.write("# This file has been auto-generated by setup.py\n") # fp.write("# This file has been auto-generated by setup.py\n")
fp.write('__version__ = "%s"\n' % MODULE_VERSION) # fp.write('__version__ = "%s"\n' % MODULE_VERSION)
except IOError as e: # except IOError as e:
sys.stderr.write("failed to create file %s: %s\n" % (VERSION_FILE, str(e))) # sys.stderr.write("failed to create file %s: %s\n" % (VERSION_FILE, str(e)))
sys.exit(1) # sys.exit(1)
# Install the module, script, and support files # Install the module, script, and support files
setup( setup(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment