diff options
author | Richard Jones <rjones@redhat.com> | 2009-05-08 14:28:03 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-05-08 14:28:03 +0100 |
commit | 0faa5dde7b992ba11bb88f77b3424676c7c492e4 (patch) | |
tree | 14948be793fca09223d7ca3022b9ac7e1fbebd81 /python | |
parent | fa7c8bb79b45aecdf65ed93635a42f3fdf301134 (diff) | |
download | libguestfs-0faa5dde7b992ba11bb88f77b3424676c7c492e4.tar.gz libguestfs-0faa5dde7b992ba11bb88f77b3424676c7c492e4.tar.xz libguestfs-0faa5dde7b992ba11bb88f77b3424676c7c492e4.zip |
Generated code to support previous 2 commits.
Diffstat (limited to 'python')
-rw-r--r-- | python/guestfs-py.c | 79 | ||||
-rw-r--r-- | python/guestfs.py | 47 |
2 files changed, 126 insertions, 0 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c index 918e2ba0..efc57920 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -3254,6 +3254,82 @@ py_guestfs_equal (PyObject *self, PyObject *args) return py_r; } +static PyObject * +py_guestfs_strings (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char **r; + const char *path; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_strings", + &py_g, &path)) + return NULL; + g = get_handle (py_g); + + r = guestfs_strings (g, path); + 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 PyObject * +py_guestfs_strings_e (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char **r; + const char *encoding; + const char *path; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_strings_e", + &py_g, &encoding, &path)) + return NULL; + g = get_handle (py_g); + + r = guestfs_strings_e (g, encoding, path); + 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 PyObject * +py_guestfs_hexdump (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char *r; + const char *path; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_hexdump", + &py_g, &path)) + return NULL; + g = get_handle (py_g); + + r = guestfs_hexdump (g, path); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyString_FromString (r); + free (r); + return py_r; +} + static PyMethodDef methods[] = { { (char *) "create", py_guestfs_create, METH_VARARGS, NULL }, { (char *) "close", py_guestfs_close, METH_VARARGS, NULL }, @@ -3371,6 +3447,9 @@ static PyMethodDef methods[] = { { (char *) "dmesg", py_guestfs_dmesg, METH_VARARGS, NULL }, { (char *) "ping_daemon", py_guestfs_ping_daemon, METH_VARARGS, NULL }, { (char *) "equal", py_guestfs_equal, METH_VARARGS, NULL }, + { (char *) "strings", py_guestfs_strings, METH_VARARGS, NULL }, + { (char *) "strings_e", py_guestfs_strings_e, METH_VARARGS, NULL }, + { (char *) "hexdump", py_guestfs_hexdump, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/python/guestfs.py b/python/guestfs.py index 3db9ac0f..9cf9d881 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -743,6 +743,11 @@ class GuestFS: calculated using "strlen" (so in this case the content cannot contain embedded ASCII NULs). + *NB.* Owing to a bug, writing content containing ASCII + NUL characters does *not* work, even if the length is + specified. We hope to resolve this bug in a future + version. In the meantime use "g.upload". + Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. To transfer large files you should use FTP. @@ -1251,3 +1256,45 @@ class GuestFS: """ return libguestfsmod.equal (self._o, file1, file2) + def strings (self, path): + u"""This runs the strings(1) command on a file and returns + the list of printable strings found. + + This function returns a list of strings. + + Because of the message protocol, there is a transfer + limit of somewhere between 2MB and 4MB. To transfer + large files you should use FTP. + """ + return libguestfsmod.strings (self._o, path) + + def strings_e (self, encoding, path): + u"""This is like the "g.strings" command, but allows you to + specify the encoding. + + See the strings(1) manpage for the full list of + encodings. + + Commonly useful encodings are "l" (lower case L) which + will show strings inside Windows/x86 files. + + The returned strings are transcoded to UTF-8. + + This function returns a list of strings. + + Because of the message protocol, there is a transfer + limit of somewhere between 2MB and 4MB. To transfer + large files you should use FTP. + """ + return libguestfsmod.strings_e (self._o, encoding, path) + + def hexdump (self, path): + u"""This runs "hexdump -C" on the given "path". The result + is the human-readable, canonical hex dump of the file. + + Because of the message protocol, there is a transfer + limit of somewhere between 2MB and 4MB. To transfer + large files you should use FTP. + """ + return libguestfsmod.hexdump (self._o, path) + |