Commit 9258050b by devttys0

Updated setup

parent ef96a6fd
...@@ -59,28 +59,25 @@ def warning(lines, terminate=True, prompt=True): ...@@ -59,28 +59,25 @@ def warning(lines, terminate=True, prompt=True):
if terminate: if terminate:
sys.exit(1) sys.exit(1)
class UninstallCommand(Command): def find_binwalk_module_paths():
description = "Uninstalls the Python module" paths = []
user_options = []
def initialize_options(self): try:
import binwalk
paths = binwalk.__path__
except KeyboardInterrupt as e:
raise e
except Exception:
pass pass
def finalize_options(self): return paths
pass
def run(self): def remove_binwalk_module():
try: for path in find_binwalk_module_paths():
import binwalk
for path in binwalk.__path__:
try: try:
remove_tree(path) remove_tree(path)
except OSError as e: except OSError as e:
pass pass
except KeyboardInterrupt as e:
raise e
except Exception as e:
pass
script_path = which(MODULE_NAME) script_path = which(MODULE_NAME)
if script_path: if script_path:
...@@ -92,6 +89,19 @@ class UninstallCommand(Command): ...@@ -92,6 +89,19 @@ class UninstallCommand(Command):
except Exception as e: except Exception as e:
pass pass
class UninstallCommand(Command):
description = "Uninstalls the Python module"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
remove_binwalk_module()
class CleanCommand(Command): class CleanCommand(Command):
description = "Clean Python build directories" description = "Clean Python build directories"
user_options = [] user_options = []
...@@ -130,6 +140,11 @@ if "install" in sys.argv: ...@@ -130,6 +140,11 @@ if "install" in sys.argv:
warning(msg, prompt=True) warning(msg, prompt=True)
# If an older version of binwalk is currently installed, completely remove it to prevent conflicts
existing_binwalk_modules = find_binwalk_module_paths()
if existing_binwalk_modules and not os.path.exists(os.path.join(existing_binwalk_modules[0], "core")):
remove_binwalk_module()
# Re-build the magic file during a build/install # Re-build the magic file during a build/install
if "install" in sys.argv or "build" in sys.argv: if "install" in sys.argv or "build" in sys.argv:
# Generate a new magic file from the files in the magic directory # Generate a new magic file from the files in the magic directory
......
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