Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions software/script/chameleon_cli_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import chameleon_com
import chameleon_cmd
from chameleon_utils import ArgumentParserNoExit, ArgsParserError, UnexpectedResponseError, execute_tool, \
tqdm_if_exists, print_key_table
tqdm_if_exists, print_key_table, default_cwd
from chameleon_utils import CLITree
from chameleon_utils import CR, CG, CB, CC, CY, C0, color_string
from chameleon_utils import print_mem_dump
Expand All @@ -48,8 +48,6 @@
0x38: "SmartMX with MIFARE Classic 4K",
}

default_cwd = Path.cwd() / Path(__file__).with_name("bin")


def load_key_file(import_key, keys):
"""
Expand All @@ -66,12 +64,11 @@ def load_dic_file(import_dic, keys):


def check_tools():
bin_dir = Path.cwd() / "bin"
missing_tools = []

for tool in ("staticnested", "nested", "darkside", "mfkey32v2", "staticnested_1nt",
"staticnested_2x1nt_rf08s", "staticnested_2x1nt_rf08s_1key"):
if any(bin_dir.glob(f"{tool}*")):
if any(default_cwd.glob(f"{tool}*")):
continue
else:
missing_tools.append(tool)
Expand Down
15 changes: 14 additions & 1 deletion software/script/chameleon_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,20 @@
CM = colorama.Fore.MAGENTA
C0 = colorama.Style.RESET_ALL

default_cwd = Path.cwd() / Path(__file__).with_name("bin")

def get_resource_dir(relative_path: str):
"""
Get the resource directory of the program.
Returns the temporary directory where files are extracted after being packaged with PyInstaller, or the directory where the script is located in the development environment.
"""
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
base_dir = Path(sys._MEIPASS)
else:
base_dir = Path(__file__).parent
return base_dir / relative_path


default_cwd = get_resource_dir("bin")


class ArgsParserError(Exception):
Expand Down
Loading