diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2008-10-28 09:20:18 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2008-10-28 09:20:18 +0000 |
| commit | 608141c09c8988c1e7ef226b74a3a3f1088d83ee (patch) | |
| tree | d3b66d1907f1c1c59504e5680de9efea588390d1 /lib/base | |
| parent | 00623b736cc9488ee71c388b0da9a8fb9071cca4 (diff) | |
| download | enigma2-608141c09c8988c1e7ef226b74a3a3f1088d83ee.tar.gz enigma2-608141c09c8988c1e7ef226b74a3a3f1088d83ee.zip | |
cleanup eConsoleAppContainer code.. execute is now only possible to call with
one single string argument
Diffstat (limited to 'lib/base')
| -rw-r--r-- | lib/base/console.cpp | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/lib/base/console.cpp b/lib/base/console.cpp index b1502d7e..9204bcca 100644 --- a/lib/base/console.cpp +++ b/lib/base/console.cpp @@ -617,35 +617,11 @@ eConsolePy_running(eConsolePy* self) static PyObject * eConsolePy_execute(eConsolePy* self, PyObject *argt) { - if (PyTuple_Size(argt) > 1) - { - PyObject *cmdline, *args; - PyArg_ParseTuple(argt, "OO", &cmdline, &args); - if (!PyString_Check(cmdline) || !PySequence_Check(args)) - return PyInt_FromLong(-2); - else - { - PyObject *fast = PySequence_Fast(args, "2nd arg is not a sequence"); - Py_ssize_t size = PySequence_Fast_GET_SIZE(fast); - const char *argv[size + 1]; - int i=0; - for (; i < size; ++i) - { - PyObject *arg = PySequence_Fast_GET_ITEM(fast, i); /* borrowed ref */ - if (!PyString_Check(arg)) - return PyInt_FromLong(-3); - argv[i] = PyString_AsString(arg); /* borrowed pointer */ - } - argv[i] = 0; - return PyInt_FromLong(self->cont->execute(PyString_AsString(cmdline), argv)); /* borrowed pointer */ - } - } - else - { - const char *str; - if (PyArg_ParseTuple(argt, "s", &str)) - return PyInt_FromLong(self->cont->execute(str)); - } + 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"); return NULL; } @@ -660,7 +636,11 @@ eConsolePy_write(eConsolePy* self, PyObject *args) { PyObject *ob; if (!PyArg_ParseTuple(args, "O", &ob) || !PyString_Check(ob)) + { + PyErr_SetString(PyExc_TypeError, + "1st arg must be a string, optionaly 2nd arg can be the string length"); return NULL; + } else { Py_ssize_t length; @@ -716,7 +696,11 @@ eConsolePy_dumpToFile(eConsolePy* self, PyObject *args) { char *filename; if (!PyArg_ParseTuple(args, "s", &filename)) + { + PyErr_SetString(PyExc_TypeError, + "arg must be a string (filename)"); return NULL; + } else { int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644); @@ -731,7 +715,11 @@ eConsolePy_readFromFile(eConsolePy* self, PyObject *args) { char *filename; if (!PyArg_ParseTuple(args, "s", &filename)) + { + PyErr_SetString(PyExc_TypeError, + "arg must be a string (filename)"); return NULL; + } else { int fd = open(filename, O_RDONLY); |
