optionally pass a method to call with the offset and total values.
If this method returns a 1 the check will be aborted.
---
pyisomd5sum.c | 41 +++++++++++++++++++++++++++++++++++------
1 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/pyisomd5sum.c b/pyisomd5sum.c
index a15aff2..5c37397 100644
--- a/pyisomd5sum.c
+++ b/pyisomd5sum.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001-2007 Red Hat, Inc.
+ * Copyright (C) 2001-2012 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -31,15 +31,44 @@ static PyMethodDef isomd5sumMethods[] = {
{ NULL }
} ;
+/* Call python object with offset and total
+ * If the object returns true return 1 to abort the check
+ */
+int pythonCB(void *cbdata, long long offset, long long total) {
+ PyObject *arglist, *result;
+ int rc;
+
+ arglist = Py_BuildValue("(LL)", offset, total);
+ result = PyObject_CallObject(cbdata, arglist);
+ Py_DECREF(arglist);
+
+ if (result == NULL)
+ return 1;
+
+ rc = PyObject_IsTrue(result);
+ Py_DECREF(result);
+ return (rc > 0);
+}
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
03-08-2012, 06:18 PM
Chris Lumens
add optional callback to python bindings
> optionally pass a method to call with the offset and total values.
> If this method returns a 1 the check will be aborted.
> ---
> pyisomd5sum.c | 41 +++++++++++++++++++++++++++++++++++------
> 1 files changed, 35 insertions(+), 6 deletions(-)
Turns out, I don't need this for the verify stuff in the new UI. See my
commits using all that GIO stuff for how I did it.
But anyway, these still look fine and does seem like something the
library should support.
- Chris
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list