diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-20 15:54:22 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-20 15:54:22 +0100 |
commit | 0232e722826cfda0f6042da983f9eb871f24e946 (patch) | |
tree | e08a414ae15cc70f60ed6275231f9ae050a033fe /python | |
parent | 11350529fee2dbbcfda333bbe10d72f023dc2109 (diff) | |
download | libguestfs-0232e722826cfda0f6042da983f9eb871f24e946.tar.gz libguestfs-0232e722826cfda0f6042da983f9eb871f24e946.tar.xz libguestfs-0232e722826cfda0f6042da983f9eb871f24e946.zip |
Added tar-in, tar-out, tgz-in, tgz-out commands.
Diffstat (limited to 'python')
-rw-r--r-- | python/guestfs-py.c | 108 | ||||
-rw-r--r-- | python/guestfs.py | 32 |
2 files changed, 140 insertions, 0 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c index 4d31d9f7..800d21b9 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -2562,6 +2562,110 @@ py_guestfs_checksum (PyObject *self, PyObject *args) return py_r; } +static PyObject * +py_guestfs_tar_in (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *tarfile; + const char *directory; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_tar_in", + &py_g, &tarfile, &directory)) + return NULL; + g = get_handle (py_g); + + r = guestfs_tar_in (g, tarfile, directory); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + +static PyObject * +py_guestfs_tar_out (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *directory; + const char *tarfile; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_tar_out", + &py_g, &directory, &tarfile)) + return NULL; + g = get_handle (py_g); + + r = guestfs_tar_out (g, directory, tarfile); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + +static PyObject * +py_guestfs_tgz_in (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *tarball; + const char *directory; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_tgz_in", + &py_g, &tarball, &directory)) + return NULL; + g = get_handle (py_g); + + r = guestfs_tgz_in (g, tarball, directory); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + +static PyObject * +py_guestfs_tgz_out (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *directory; + const char *tarball; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_tgz_out", + &py_g, &directory, &tarball)) + return NULL; + g = get_handle (py_g); + + r = guestfs_tgz_out (g, directory, tarball); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + static PyMethodDef methods[] = { { (char *) "create", py_guestfs_create, METH_VARARGS, NULL }, { (char *) "close", py_guestfs_close, METH_VARARGS, NULL }, @@ -2652,6 +2756,10 @@ static PyMethodDef methods[] = { { (char *) "upload", py_guestfs_upload, METH_VARARGS, NULL }, { (char *) "download", py_guestfs_download, METH_VARARGS, NULL }, { (char *) "checksum", py_guestfs_checksum, METH_VARARGS, NULL }, + { (char *) "tar_in", py_guestfs_tar_in, METH_VARARGS, NULL }, + { (char *) "tar_out", py_guestfs_tar_out, METH_VARARGS, NULL }, + { (char *) "tgz_in", py_guestfs_tgz_in, METH_VARARGS, NULL }, + { (char *) "tgz_out", py_guestfs_tgz_out, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/python/guestfs.py b/python/guestfs.py index 4d71b23c..6417caf4 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -997,3 +997,35 @@ class GuestFS: """ return libguestfsmod.checksum (self._o, csumtype, path) + def tar_in (self, tarfile, directory): + u"""This command uploads and unpacks local file "tarfile" + (an *uncompressed* tar file) into "directory". + + To upload a compressed tarball, use "g.tgz_in". + """ + return libguestfsmod.tar_in (self._o, tarfile, directory) + + def tar_out (self, directory, tarfile): + u"""This command packs the contents of "directory" and + downloads it to local file "tarfile". + + To download a compressed tarball, use "g.tgz_out". + """ + return libguestfsmod.tar_out (self._o, directory, tarfile) + + def tgz_in (self, tarball, directory): + u"""This command uploads and unpacks local file "tarball" (a + *gzip compressed* tar file) into "directory". + + To upload an uncompressed tarball, use "g.tar_in". + """ + return libguestfsmod.tgz_in (self._o, tarball, directory) + + def tgz_out (self, directory, tarball): + u"""This command packs the contents of "directory" and + downloads it to local file "tarball". + + To download an uncompressed tarball, use "g.tar_out". + """ + return libguestfsmod.tgz_out (self._o, directory, tarball) + |