diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-18 22:33:15 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-18 22:33:15 +0100 |
commit | bb07a7f858da5d07c57360e62c0ddfd24ce6be45 (patch) | |
tree | 56201f1c514d8d79a56251b104c3d8a135fcbd39 /python | |
parent | 7bf3e1a43512293b1a3f78f880b57e7bbd372eae (diff) | |
download | libguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.tar.gz libguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.tar.xz libguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.zip |
Begin to add the upload and download commands.
Diffstat (limited to 'python')
-rw-r--r-- | python/guestfs-py.c | 54 | ||||
-rw-r--r-- | python/guestfs.py | 20 |
2 files changed, 74 insertions, 0 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c index d1f0a9e7..69446aee 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -2436,6 +2436,58 @@ py_guestfs_blockdev_rereadpt (PyObject *self, PyObject *args) return py_r; } +static PyObject * +py_guestfs_upload (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *filename; + const char *remotefilename; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_upload", + &py_g, &filename, &remotefilename)) + return NULL; + g = get_handle (py_g); + + r = guestfs_upload (g, filename, remotefilename); + 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_download (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *remotefilename; + const char *filename; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_download", + &py_g, &remotefilename, &filename)) + return NULL; + g = get_handle (py_g); + + r = guestfs_download (g, remotefilename, filename); + 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 }, @@ -2521,6 +2573,8 @@ static PyMethodDef methods[] = { { (char *) "blockdev_getsize64", py_guestfs_blockdev_getsize64, METH_VARARGS, NULL }, { (char *) "blockdev_flushbufs", py_guestfs_blockdev_flushbufs, METH_VARARGS, NULL }, { (char *) "blockdev_rereadpt", py_guestfs_blockdev_rereadpt, METH_VARARGS, NULL }, + { (char *) "upload", py_guestfs_upload, METH_VARARGS, NULL }, + { (char *) "download", py_guestfs_download, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/python/guestfs.py b/python/guestfs.py index 943f80a7..fd495fdb 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -923,3 +923,23 @@ class GuestFS: """ return libguestfsmod.blockdev_rereadpt (self._o, device) + def upload (self, filename, remotefilename): + u"""Upload local file "filename" to "remotefilename" on the + filesystem. + + "filename" can also be a named pipe. + + See also "g.download". + """ + return libguestfsmod.upload (self._o, filename, remotefilename) + + def download (self, remotefilename, filename): + u"""Download file "remotefilename" and save it as "filename" + on the local machine. + + "filename" can also be a named pipe. + + See also "g.upload", "g.cat". + """ + return libguestfsmod.download (self._o, remotefilename, filename) + |