diff options
| author | ghost <andreas.monzner@multimedia-labs.de> | 2008-10-31 13:07:01 +0100 |
|---|---|---|
| committer | Andreas Oberritter <obi@saftware.de> | 2008-11-06 01:46:55 +0100 |
| commit | 728c78384a71b0231cfe0047292e34b8ec860522 (patch) | |
| tree | d3797e574f01bbddc15f043587a1d545b97ff462 | |
| parent | 52c94625063d5ea3ebf77db99acac8a43639c12a (diff) | |
| download | enigma2-728c78384a71b0231cfe0047292e34b8ec860522.tar.gz enigma2-728c78384a71b0231cfe0047292e34b8ec860522.zip | |
add possibility to call eConsoleAppContainer execute with unlimited count of arguments
when its called with single argument, then /bin/sh is started else not
| -rw-r--r-- | lib/base/console.cpp | 36 | ||||
| -rw-r--r-- | lib/python/Components/Task.py | 4 |
2 files changed, 33 insertions, 7 deletions
diff --git a/lib/base/console.cpp b/lib/base/console.cpp index a12cb5e2..25318cc9 100644 --- a/lib/base/console.cpp +++ b/lib/base/console.cpp @@ -476,11 +476,37 @@ eConsolePy_running(eConsolePy* self) static PyObject * eConsolePy_execute(eConsolePy* self, PyObject *argt) { - const char *str; - if (PyArg_ParseTuple(argt, "s", &str)) - return PyInt_FromLong(self->cont->execute(str)); - PyErr_SetString(PyExc_TypeError, - "argument is not a string"); + Py_ssize_t argc = PyTuple_Size(argt); + if (argc > 1) + { + const char *argv[argc + 1]; + int argpos=0; + while(argpos < argc) + { + PyObject *arg = PyTuple_GET_ITEM(argt, argpos); + if (!PyString_Check(arg)) + { + char err[255]; + if (argpos) + snprintf(err, 255, "arg %d is not a string", argpos); + else + snprintf(err, 255, "cmd is not a string!"); + PyErr_SetString(PyExc_TypeError, err); + return NULL; + } + argv[argpos++] = PyString_AsString(arg); + } + argv[argpos] = 0; + return PyInt_FromLong(self->cont->execute(argv[0], argv)); + } + else + { + const char *str; + if (PyArg_ParseTuple(argt, "s", &str)) + return PyInt_FromLong(self->cont->execute(str)); + PyErr_SetString(PyExc_TypeError, + "cmd is not a string!"); + } return NULL; } diff --git a/lib/python/Components/Task.py b/lib/python/Components/Task.py index 47acc87e..ab85c667 100644 --- a/lib/python/Components/Task.py +++ b/lib/python/Components/Task.py @@ -136,6 +136,7 @@ class Task(object): def setTool(self, tool): self.cmd = tool + self.args = [tool] self.global_preconditions.append(ToolExistsPrecondition()) self.postconditions.append(ReturncodePostcondition()) @@ -171,8 +172,7 @@ class Task(object): if self.cwd is not None: self.container.setCWD(self.cwd) - execstr = " ".join([self.cmd]+self.args) - print "execute:", self.container.execute(execstr), execstr + print "execute:", self.container.execute(self.cmd, *self.args), self.cmd, *self.args if self.initial_input: self.writeInput(self.initial_input) |
