mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
Fix embedded python not working with Proxspace.
This commit is contained in:
parent
46ada2abd6
commit
0083e0ae13
1 changed files with 8 additions and 17 deletions
|
@ -399,34 +399,26 @@ static int CmdScriptRun(const char *Cmd) {
|
||||||
PrintAndLogEx(SUCCESS, "executing python " _YELLOW_("%s"), script_path);
|
PrintAndLogEx(SUCCESS, "executing python " _YELLOW_("%s"), script_path);
|
||||||
PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
|
PrintAndLogEx(SUCCESS, "args " _YELLOW_("'%s'"), arguments);
|
||||||
|
|
||||||
wchar_t *program = Py_DecodeLocale(filename, NULL);
|
|
||||||
if (program == NULL) {
|
|
||||||
PrintAndLogEx(ERR, "could not decode " _YELLOW_("%s"), filename);
|
|
||||||
free(script_path);
|
|
||||||
return PM3_ESOFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional but recommended
|
|
||||||
//Py_SetProgramName(program);
|
|
||||||
#ifdef HAVE_PYTHON_SWIG
|
#ifdef HAVE_PYTHON_SWIG
|
||||||
// hook Proxmark3 API
|
// hook Proxmark3 API
|
||||||
PyImport_AppendInittab("_pm3", PyInit__pm3);
|
PyImport_AppendInittab("_pm3", PyInit__pm3);
|
||||||
#endif
|
#endif
|
||||||
PyConfig py_conf;
|
PyConfig py_conf;
|
||||||
PyConfig_InitIsolatedConfig(&py_conf);
|
PyConfig_InitIsolatedConfig(&py_conf);
|
||||||
|
// Despite being isolated we probably want to allow users to use
|
||||||
|
// the Python packages they installed on their user directory as well
|
||||||
|
// as system ones. But it seems isolated mode still enforces them off.
|
||||||
|
py_conf.use_environment = 1;
|
||||||
|
py_conf.user_site_directory = 1;
|
||||||
|
|
||||||
//int argc, char ** argv
|
//int argc, char ** argv
|
||||||
char *argv[128];
|
char *argv[128];
|
||||||
argv[0] = filename;
|
argv[0] = filename;
|
||||||
int argc = split(arguments, &argv[1]);
|
int argc = split(arguments, &argv[1]);
|
||||||
|
// The following line will implicitly pre-initialize Python
|
||||||
PyConfig_SetBytesArgv(&py_conf, argc + 1, argv);
|
PyConfig_SetBytesArgv(&py_conf, argc + 1, argv);
|
||||||
// Despite being isolated we probably want to allow users to use
|
// This is required by Proxspace to work with an isolated Python configuration
|
||||||
// the Python packages they installed on their user directory as well
|
PyConfig_SetBytesString(&py_conf, &py_conf.home, getenv("PYTHONHOME"));
|
||||||
// as obey env variables.
|
|
||||||
py_conf.use_environment = 1;
|
|
||||||
py_conf.user_site_directory = 1;
|
|
||||||
// Setting this pre-intializes Python implictly which will change the config
|
|
||||||
PyConfig_SetString(&py_conf, &py_conf.program_name, program);
|
|
||||||
|
|
||||||
Py_InitializeFromConfig(&py_conf);
|
Py_InitializeFromConfig(&py_conf);
|
||||||
|
|
||||||
|
@ -447,7 +439,6 @@ static int CmdScriptRun(const char *Cmd) {
|
||||||
}
|
}
|
||||||
int ret = Pm3PyRun_SimpleFileNoExit(f, filename);
|
int ret = Pm3PyRun_SimpleFileNoExit(f, filename);
|
||||||
Py_Finalize();
|
Py_Finalize();
|
||||||
PyMem_RawFree(program);
|
|
||||||
free(script_path);
|
free(script_path);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
PrintAndLogEx(WARNING, "\nfinished " _YELLOW_("%s") " with exception", filename);
|
PrintAndLogEx(WARNING, "\nfinished " _YELLOW_("%s") " with exception", filename);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue