mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
python: adjust help, hide more if no python available, search lua/cmd/py if no extension given
This commit is contained in:
parent
b4c715d8fb
commit
fcfdd92407
2 changed files with 25 additions and 8 deletions
|
@ -372,10 +372,14 @@ else
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(PYTHON_FOUND),1)
|
||||
$(info Python3 library: Python3 v$(shell pkg-config --modversion python3) found, enabled)
|
||||
ifeq ($(SKIPPYTHON),1)
|
||||
$(info Python3 library: skipped)
|
||||
else
|
||||
ifeq ($(PYTHON_FOUND),1)
|
||||
$(info Python3 library: Python3 v$(shell pkg-config --modversion python3) found, enabled)
|
||||
else
|
||||
$(info Python3 library: Python3 not found, disabled)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(SKIPWHEREAMISYSTEM),1)
|
||||
|
|
|
@ -139,8 +139,11 @@ static int CmdScriptList(const char *Cmd) {
|
|||
ret = searchAndList(CMD_SCRIPTS_SUBDIR, ".cmd");
|
||||
if (ret != PM3_SUCCESS)
|
||||
return ret;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
return searchAndList(PYTHON_SCRIPTS_SUBDIR, ".py");
|
||||
#else
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,7 +161,10 @@ static int CmdScriptRun(const char *Cmd) {
|
|||
int arg_len = 0;
|
||||
static uint8_t luascriptfile_idx = 0;
|
||||
sscanf(Cmd, "%127s%n %255[^\n\r]%n", preferredName, &name_len, arguments, &arg_len);
|
||||
|
||||
if (strlen(preferredName) == 0) {
|
||||
PrintAndLogEx(FAILED, "no script name provided");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
char *extension_chk;
|
||||
extension_chk = str_dup(preferredName);
|
||||
str_lower(extension_chk);
|
||||
|
@ -329,15 +335,18 @@ static int CmdScriptRun(const char *Cmd) {
|
|||
#ifdef HAVE_PYTHON
|
||||
else if (ext == PM3_PY)
|
||||
ret = searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", false);
|
||||
#endif
|
||||
else if (ext == PM3_UNSPECIFIED)
|
||||
PrintAndLogEx(FAILED, "Error - can't find %s.[lua|cmd|py]", preferredName);
|
||||
#else
|
||||
else if (ext == PM3_UNSPECIFIED)
|
||||
PrintAndLogEx(FAILED, "Error - can't find %s.[lua|cmd]", preferredName);
|
||||
#endif
|
||||
free(script_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"help", CmdHelp, AlwaysAvailable, "Usage info"},
|
||||
{"list", CmdScriptList, AlwaysAvailable, "List available scripts"},
|
||||
{"run", CmdScriptRun, AlwaysAvailable, "<name> -- execute a script"},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
|
@ -351,7 +360,11 @@ static command_t CommandTable[] = {
|
|||
*/
|
||||
static int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
PrintAndLogEx(NORMAL, "This is a feature to run Lua-scripts. You can place Lua-scripts within the luascripts/-folder. ");
|
||||
#ifdef HAVE_PYTHON
|
||||
PrintAndLogEx(NORMAL, "This is a feature to run Lua/Cmd/Python scripts. You can place scripts within the luascripts/cmdscripts/pyscripts folders. ");
|
||||
#else
|
||||
PrintAndLogEx(NORMAL, "This is a feature to run Lua/Cmd scripts. You can place scripts within the luascripts/cmdscripts folders. ");
|
||||
#endif
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue