Skip to content

Commit

Permalink
cli: check if helper tools are available
Browse files Browse the repository at this point in the history
  • Loading branch information
doegox committed Oct 17, 2023
1 parent 82fcc76 commit 2beb8f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions software/script/chameleon_cli_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def startCLI(self):
raise Exception("This script requires at least Python 3.9")

self.print_banner()
chameleon_cli_unit.check_tools()
cmd_strs = []
while True:
if cmd_strs:
Expand Down
15 changes: 12 additions & 3 deletions software/script/chameleon_cli_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,21 @@
0x38: "SmartMX with MIFARE Classic 4K",
}

if getattr(sys, 'frozen', False):
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
# in pyinstaller
default_cwd = str(Path(sys._MEIPASS) / "bin")
default_cwd = Path.cwd() / Path(sys._MEIPASS) / "bin"
else:
# from source
default_cwd = str(Path(__file__).parent.parent / "bin")
default_cwd = Path.cwd() / Path(__file__).parent.parent / "bin"


def check_tools():
tools = ['staticnested', 'nested', 'darkside', 'mfkey32v2']
if sys.platform == "win32":
tools = [x+'.exe' for x in tools]
missing_tools = [tool for tool in tools if not (default_cwd / tool).exists()]
if len(missing_tools) > 0:
print(f'{CR}Warning, tools {", ".join(missing_tools)} not found. Corresponding commands will not work as intended.{C0}')


class BaseCLIUnit:
Expand Down

0 comments on commit 2beb8f7

Please sign in to comment.