cli: check if helper tools are available

This commit is contained in:
Philippe Teuwen
2023-10-17 22:08:34 +02:00
parent 82fcc76286
commit 2beb8f74a3
2 changed files with 13 additions and 3 deletions
+1
View File
@@ -94,6 +94,7 @@ class ChameleonCLI:
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:
+12 -3
View File
@@ -37,12 +37,21 @@ type_id_SAK_dict = {0x00: "MIFARE Ultralight Classic/C/EV1/Nano | NTAG 2xx",
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: