diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-14 13:51:12 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-14 13:51:12 +0100 |
commit | 5365ebd501850ea10d9a5b28fc6480ea34dbe16d (patch) | |
tree | 3c3bedf7581ea8485db6f039f2633ee07361b031 /python | |
parent | 161018ed1e90c796e6e099859979da02d5f3e410 (diff) | |
download | libguestfs-5365ebd501850ea10d9a5b28fc6480ea34dbe16d.tar.gz libguestfs-5365ebd501850ea10d9a5b28fc6480ea34dbe16d.tar.xz libguestfs-5365ebd501850ea10d9a5b28fc6480ea34dbe16d.zip |
Add 'command' and 'command-lines'. Fix args freeing in Perl bindings.
Diffstat (limited to 'python')
-rw-r--r-- | python/guestfs-py.c | 60 | ||||
-rw-r--r-- | python/guestfs.py | 6 |
2 files changed, 66 insertions, 0 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c index d3d6999c..8c7ad228 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -1831,6 +1831,64 @@ py_guestfs_file (PyObject *self, PyObject *args) return py_r; } +static PyObject * +py_guestfs_command (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char *r; + PyObject *py_arguments; + const char **arguments; + + if (!PyArg_ParseTuple (args, (char *) "OO:guestfs_command", + &py_g, &py_arguments)) + return NULL; + g = get_handle (py_g); + arguments = get_string_list (py_arguments); + if (!arguments) return NULL; + + r = guestfs_command (g, arguments); + free (arguments); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyString_FromString (r); + free (r); + return py_r; +} + +static PyObject * +py_guestfs_command_lines (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char **r; + PyObject *py_arguments; + const char **arguments; + + if (!PyArg_ParseTuple (args, (char *) "OO:guestfs_command_lines", + &py_g, &py_arguments)) + return NULL; + g = get_handle (py_g); + arguments = get_string_list (py_arguments); + if (!arguments) return NULL; + + r = guestfs_command_lines (g, arguments); + free (arguments); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_string_list (r); + free_strings (r); + return py_r; +} + static PyMethodDef methods[] = { { (char *) "create", py_guestfs_create, METH_VARARGS, NULL }, { (char *) "close", py_guestfs_close, METH_VARARGS, NULL }, @@ -1895,6 +1953,8 @@ static PyMethodDef methods[] = { { (char *) "umount_all", py_guestfs_umount_all, METH_VARARGS, NULL }, { (char *) "lvm_remove_all", py_guestfs_lvm_remove_all, METH_VARARGS, NULL }, { (char *) "file", py_guestfs_file, METH_VARARGS, NULL }, + { (char *) "command", py_guestfs_command, METH_VARARGS, NULL }, + { (char *) "command_lines", py_guestfs_command_lines, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/python/guestfs.py b/python/guestfs.py index d4cd46d9..6cf7e19e 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -210,3 +210,9 @@ class GuestFS: def file (self, path): return libguestfsmod.file (self._o, path) + def command (self, arguments): + return libguestfsmod.command (self._o, arguments) + + def command_lines (self, arguments): + return libguestfsmod.command_lines (self._o, arguments) + |