summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-06-29 11:47:07 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-06-29 11:47:07 +0100
commit826020fe18bf2eee43f8afea392874bb88c0650a (patch)
tree7c6c40758611605be29b3528da647a78a071ea1b /python
parent3854bbdecd1c089959fb812a739b84a96c05fbbf (diff)
downloadlibguestfs-826020fe18bf2eee43f8afea392874bb88c0650a.tar.gz
libguestfs-826020fe18bf2eee43f8afea392874bb88c0650a.tar.xz
libguestfs-826020fe18bf2eee43f8afea392874bb88c0650a.zip
Generated code for head/tail commands.
Diffstat (limited to 'python')
-rw-r--r--python/guestfs-py.c112
-rw-r--r--python/guestfs.py66
2 files changed, 173 insertions, 5 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c
index 07f3c460..7d28af43 100644
--- a/python/guestfs-py.c
+++ b/python/guestfs-py.c
@@ -4153,18 +4153,18 @@ py_guestfs_sfdisk_N (PyObject *self, PyObject *args)
PyObject *py_r;
int r;
const char *device;
- int n;
+ int partnum;
int cyls;
int heads;
int sectors;
const char *line;
if (!PyArg_ParseTuple (args, (char *) "Osiiiis:guestfs_sfdisk_N",
- &py_g, &device, &n, &cyls, &heads, &sectors, &line))
+ &py_g, &device, &partnum, &cyls, &heads, &sectors, &line))
return NULL;
g = get_handle (py_g);
- r = guestfs_sfdisk_N (g, device, n, cyls, heads, sectors, line);
+ r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
if (r == -1) {
PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
return NULL;
@@ -4703,6 +4703,108 @@ py_guestfs_wc_c (PyObject *self, PyObject *args)
return py_r;
}
+static PyObject *
+py_guestfs_head (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_head",
+ &py_g, &path))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_head (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_head_n (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ char **r;
+ int nrlines;
+ const char *path;
+
+ if (!PyArg_ParseTuple (args, (char *) "Ois:guestfs_head_n",
+ &py_g, &nrlines, &path))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_head_n (g, nrlines, 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_tail (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_tail",
+ &py_g, &path))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_tail (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_tail_n (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ char **r;
+ int nrlines;
+ const char *path;
+
+ if (!PyArg_ParseTuple (args, (char *) "Ois:guestfs_tail_n",
+ &py_g, &nrlines, &path))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_tail_n (g, nrlines, 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 PyMethodDef methods[] = {
{ (char *) "create", py_guestfs_create, METH_VARARGS, NULL },
{ (char *) "close", py_guestfs_close, METH_VARARGS, NULL },
@@ -4878,6 +4980,10 @@ static PyMethodDef methods[] = {
{ (char *) "wc_l", py_guestfs_wc_l, METH_VARARGS, NULL },
{ (char *) "wc_w", py_guestfs_wc_w, METH_VARARGS, NULL },
{ (char *) "wc_c", py_guestfs_wc_c, METH_VARARGS, NULL },
+ { (char *) "head", py_guestfs_head, METH_VARARGS, NULL },
+ { (char *) "head_n", py_guestfs_head_n, METH_VARARGS, NULL },
+ { (char *) "tail", py_guestfs_tail, METH_VARARGS, NULL },
+ { (char *) "tail_n", py_guestfs_tail_n, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};
diff --git a/python/guestfs.py b/python/guestfs.py
index 01318ce1..30728be5 100644
--- a/python/guestfs.py
+++ b/python/guestfs.py
@@ -1478,7 +1478,7 @@ class GuestFS:
"""
return libguestfsmod.pvresize (self._o, device)
- def sfdisk_N (self, device, n, cyls, heads, sectors, line):
+ def sfdisk_N (self, device, partnum, cyls, heads, sectors, line):
u"""This runs sfdisk(8) option to modify just the single
partition "n" (note: "n" counts from 1).
@@ -1488,7 +1488,7 @@ class GuestFS:
This command is dangerous. Without careful use you can
easily destroy all your data.
"""
- return libguestfsmod.sfdisk_N (self._o, device, n, cyls, heads, sectors, line)
+ return libguestfsmod.sfdisk_N (self._o, device, partnum, cyls, heads, sectors, line)
def sfdisk_l (self, device):
u"""This displays the partition table on "device", in the
@@ -1745,3 +1745,65 @@ class GuestFS:
"""
return libguestfsmod.wc_c (self._o, path)
+ def head (self, path):
+ u"""This command returns up to the first 10 lines of a file
+ as a list of strings.
+
+ 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.head (self._o, path)
+
+ def head_n (self, nrlines, path):
+ u"""If the parameter "nrlines" is a positive number, this
+ returns the first "nrlines" lines of the file "path".
+
+ If the parameter "nrlines" is a negative number, this
+ returns lines from the file "path", excluding the last
+ "nrlines" lines.
+
+ If the parameter "nrlines" is zero, this returns an
+ empty list.
+
+ 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.head_n (self._o, nrlines, path)
+
+ def tail (self, path):
+ u"""This command returns up to the last 10 lines of a file
+ as a list of strings.
+
+ 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.tail (self._o, path)
+
+ def tail_n (self, nrlines, path):
+ u"""If the parameter "nrlines" is a positive number, this
+ returns the last "nrlines" lines of the file "path".
+
+ If the parameter "nrlines" is a negative number, this
+ returns lines from the file "path", starting with the
+ "-nrlines"th line.
+
+ If the parameter "nrlines" is zero, this returns an
+ empty list.
+
+ 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.tail_n (self._o, nrlines, path)
+