Repository URL to install this package:
|
Version:
9.0~241217-2.fc41 ▾
|
import os
import sys
import platform
from pathlib import Path
def disable_history():
try:
if "IDA_NO_HISTORY" in os.environ:
value = os.environ["IDA_NO_HISTORY"]
os.environ["IDA_NO_HISTORY"] = "1"
return value
else:
os.environ["IDA_NO_HISTORY"] = "1"
return None
except:
pass
def revert_history(value):
try:
if value is not None:
if "IDA_NO_HISTORY" in os.environ:
os.environ["IDA_NO_HISTORY"] = value
else:
os.environ.pop("IDA_NO_HISTORY")
except:
pass
PLUGIN_DIR = Path(__file__).resolve().parent
CACHE_DIR = os.path.join(
(
lambda variable, default: path
if (value := os.environ.get(variable)) and (path := Path(value)).is_absolute()
else default
)('XDG_CACHE_HOME', Path.home() / '.cache'),
'idapro',
)
SERVER_PY = os.path.join(PLUGIN_DIR, 'core', 'server.py')
IDB_PATH = ''
# get the right python interpreter path
# first check sys.executable (set under venv and standalone execution)
interpfn = os.path.basename(sys.executable) if sys.executable else ''
if interpfn.startswith("python"): #python[.exe] or python3
SYS_INTERPRETER_PATH = sys.executable
else:
# IDAPython sets sys.executable to ida[.exe]
# so look in base_exec_prefix
platform_str = platform.system()
if platform_str == "Windows":
SYS_INTERPRETER_PATH = os.path.join(sys.base_exec_prefix, 'python')
elif platform_str == "Linux":
SYS_INTERPRETER_PATH = os.path.join(sys.base_exec_prefix, 'bin', 'python3')
elif platform_str == "Darwin":
SYS_INTERPRETER_PATH = os.path.join(sys.base_exec_prefix, 'bin', 'python3')
else:
raise ImportError(f"Unknown platform {platform_str}")
PORT_START = 12345
PORT_END = PORT_START + os.cpu_count()
PORTS = [str(i) for i in range(PORT_START, PORT_END)]