summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-20 10:19:45 +0100
committerRichard Jones <rjones@redhat.com>2009-04-20 10:19:45 +0100
commit24ccbb29ac475187f51a27dcd318db2b4824a0c1 (patch)
treeecb06a1b2985b33b7bdd8dad6e222a380b274ac5 /python
parentaef3d2013fee188c9607f35657c45df88503cd64 (diff)
downloadlibguestfs-24ccbb29ac475187f51a27dcd318db2b4824a0c1.tar.gz
libguestfs-24ccbb29ac475187f51a27dcd318db2b4824a0c1.tar.xz
libguestfs-24ccbb29ac475187f51a27dcd318db2b4824a0c1.zip
Generated code for 'checksum' command.
Diffstat (limited to 'python')
-rw-r--r--python/guestfs-py.c27
-rw-r--r--python/guestfs.py38
2 files changed, 65 insertions, 0 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c
index 9969c538..4d31d9f7 100644
--- a/python/guestfs-py.c
+++ b/python/guestfs-py.c
@@ -2536,6 +2536,32 @@ py_guestfs_download (PyObject *self, PyObject *args)
return py_r;
}
+static PyObject *
+py_guestfs_checksum (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ char *r;
+ const char *csumtype;
+ const char *path;
+
+ if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_checksum",
+ &py_g, &csumtype, &path))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_checksum (g, csumtype, 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 },
@@ -2625,6 +2651,7 @@ static PyMethodDef methods[] = {
{ (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 },
+ { (char *) "checksum", py_guestfs_checksum, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};
diff --git a/python/guestfs.py b/python/guestfs.py
index 416404b5..4d71b23c 100644
--- a/python/guestfs.py
+++ b/python/guestfs.py
@@ -959,3 +959,41 @@ class GuestFS:
"""
return libguestfsmod.download (self._o, remotefilename, filename)
+ def checksum (self, csumtype, path):
+ u"""This call computes the MD5, SHAx or CRC checksum of the
+ file named "path".
+
+ The type of checksum to compute is given by the
+ "csumtype" parameter which must have one of the
+ following values:
+
+ "crc"
+ Compute the cyclic redundancy check (CRC) specified
+ by POSIX for the "cksum" command.
+
+ "md5"
+ Compute the MD5 hash (using the "md5sum" program).
+
+ "sha1"
+ Compute the SHA1 hash (using the "sha1sum" program).
+
+ "sha224"
+ Compute the SHA224 hash (using the "sha224sum"
+ program).
+
+ "sha256"
+ Compute the SHA256 hash (using the "sha256sum"
+ program).
+
+ "sha384"
+ Compute the SHA384 hash (using the "sha384sum"
+ program).
+
+ "sha512"
+ Compute the SHA512 hash (using the "sha512sum"
+ program).
+
+ The checksum is returned as a printable string.
+ """
+ return libguestfsmod.checksum (self._o, csumtype, path)
+