[PATCH 10/10] python: Mark event callback wrappers as private

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These functions aren't intended to be called directly by users, so mark
them as private.

While we're at it, remove unneeded exception handling, and break some
long lines.

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 python/libvirt-override-virConnect.py |  102 ++++++++++++++-------------------
 python/libvirt-override-virStream.py  |    2 +-
 python/libvirt-override.c             |   24 ++++----
 python/libvirt-override.py            |    4 +-
 4 files changed, 59 insertions(+), 73 deletions(-)

diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
index 362be75..5be9659 100644
--- a/python/libvirt-override-virConnect.py
+++ b/python/libvirt-override-virConnect.py
@@ -33,7 +33,7 @@
             ret = libvirtmod.virConnectDomainEventRegister(self._o, self)
             if ret == -1: raise libvirtError ('virConnectDomainEventRegister() failed', conn=self)
 
-    def dispatchDomainEventCallbacks(self, dom, event, detail):
+    def _dispatchDomainEventCallbacks(self, dom, event, detail):
         """Dispatches events to python user domain event callbacks
         """
         try:
@@ -43,7 +43,7 @@
         except AttributeError:
             pass
 
-    def dispatchDomainEventLifecycleCallback(self, dom, event, detail, cbData):
+    def _dispatchDomainEventLifecycleCallback(self, dom, event, detail, cbData):
         """Dispatches events to python user domain lifecycle event callbacks
         """
         cb = cbData["cb"]
@@ -52,89 +52,75 @@
         cb(self, virDomain(self, _obj=dom), event, detail, opaque)
         return 0
 
-    def dispatchDomainEventGenericCallback(self, dom, cbData):
+    def _dispatchDomainEventGenericCallback(self, dom, cbData):
         """Dispatches events to python user domain generic event callbacks
         """
-        try:
-            cb = cbData["cb"]
-            opaque = cbData["opaque"]
+        cb = cbData["cb"]
+        opaque = cbData["opaque"]
 
-            cb(self, virDomain(self, _obj=dom), opaque)
-            return 0
-        except AttributeError:
-            pass
+        cb(self, virDomain(self, _obj=dom), opaque)
+        return 0
 
-    def dispatchDomainEventRTCChangeCallback(self, dom, offset, cbData):
+    def _dispatchDomainEventRTCChangeCallback(self, dom, offset, cbData):
         """Dispatches events to python user domain RTC change event callbacks
         """
-        try:
-            cb = cbData["cb"]
-            opaque = cbData["opaque"]
+        cb = cbData["cb"]
+        opaque = cbData["opaque"]
 
-            cb(self, virDomain(self, _obj=dom), offset ,opaque)
-            return 0
-        except AttributeError:
-            pass
+        cb(self, virDomain(self, _obj=dom), offset ,opaque)
+        return 0
 
-    def dispatchDomainEventWatchdogCallback(self, dom, action, cbData):
+    def _dispatchDomainEventWatchdogCallback(self, dom, action, cbData):
         """Dispatches events to python user domain watchdog event callbacks
         """
-        try:
-            cb = cbData["cb"]
-            opaque = cbData["opaque"]
+        cb = cbData["cb"]
+        opaque = cbData["opaque"]
 
-            cb(self, virDomain(self, _obj=dom), action, opaque)
-            return 0
-        except AttributeError:
-            pass
+        cb(self, virDomain(self, _obj=dom), action, opaque)
+        return 0
 
-    def dispatchDomainEventIOErrorCallback(self, dom, srcPath, devAlias, action, cbData):
+    def _dispatchDomainEventIOErrorCallback(self, dom, srcPath, devAlias,
+                                            action, cbData):
         """Dispatches events to python user domain IO error event callbacks
         """
-        try:
-            cb = cbData["cb"]
-            opaque = cbData["opaque"]
+        cb = cbData["cb"]
+        opaque = cbData["opaque"]
 
-            cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action, opaque)
-            return 0
-        except AttributeError:
-            pass
+        cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action, opaque)
+        return 0
 
-    def dispatchDomainEventIOErrorReasonCallback(self, dom, srcPath, devAlias, action, reason, cbData):
+    def _dispatchDomainEventIOErrorReasonCallback(self, dom, srcPath,
+                                                  devAlias, action, reason,
+                                                  cbData):
         """Dispatches events to python user domain IO error event callbacks
         """
-        try:
-            cb = cbData["cb"]
-            opaque = cbData["opaque"]
+        cb = cbData["cb"]
+        opaque = cbData["opaque"]
 
-            cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action, reason, opaque)
-            return 0
-        except AttributeError:
-            pass
+        cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action,
+           reason, opaque)
+        return 0
 
-    def dispatchDomainEventGraphicsCallback(self, dom, phase, localAddr, remoteAddr, authScheme, subject, cbData):
+    def _dispatchDomainEventGraphicsCallback(self, dom, phase, localAddr,
+                                            remoteAddr, authScheme, subject,
+                                            cbData):
         """Dispatches events to python user domain graphics event callbacks
         """
-        try:
-            cb = cbData["cb"]
-            opaque = cbData["opaque"]
+        cb = cbData["cb"]
+        opaque = cbData["opaque"]
 
-            cb(self, virDomain(self, _obj=dom), phase, localAddr, remoteAddr, authScheme, subject, opaque)
-            return 0
-        except AttributeError:
-            pass
+        cb(self, virDomain(self, _obj=dom), phase, localAddr, remoteAddr,
+           authScheme, subject, opaque)
+        return 0
 
-    def dispatchDomainEventBlockPullCallback(self, dom, path, status, cbData):
+    def _dispatchDomainEventBlockPullCallback(self, dom, path, status, cbData):
         """Dispatches events to python user domain blockPull event callbacks
         """
-        try:
-            cb = cbData["cb"]
-            opaque = cbData["opaque"]
+        cb = cbData["cb"]
+        opaque = cbData["opaque"]
 
-            cb(self, virDomain(self, _obj=dom), path, status, opaque)
-            return 0
-        except AttributeError:
-            pass
+        cb(self, virDomain(self, _obj=dom), path, status, opaque)
+        return 0
 
     def domainEventDeregisterAny(self, callbackID):
         """Removes a Domain Event Callback. De-registering for a
diff --git a/python/libvirt-override-virStream.py b/python/libvirt-override-virStream.py
index 82e1648..92e6fb1 100644
--- a/python/libvirt-override-virStream.py
+++ b/python/libvirt-override-virStream.py
@@ -9,7 +9,7 @@
             libvirtmod.virStreamFree(self._o)
         self._o = None
 
-    def dispatchStreamEventCallback(self, events, cbData):
+    def _dispatchStreamEventCallback(self, events, cbData):
         """
         Dispatches events to python user's stream event callbacks
         """
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index b000718..5a36be0 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -2581,7 +2581,7 @@ libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     /* Call the Callback Dispatcher */
     pyobj_ret = PyObject_CallMethod(pyobj_conn_inst,
-                                    (char*)"dispatchDomainEventCallbacks",
+                                    (char*)"_dispatchDomainEventCallbacks",
                                     (char*)"Oii",
                                     pyobj_dom_inst,
                                     event,
@@ -2707,7 +2707,7 @@ libvirt_virEventAddHandleFunc  (int fd,
     LIBVIRT_ENSURE_THREAD_STATE;
 
     /* Lookup the python callback */
-    python_cb = libvirt_lookupPythonFunc("eventInvokeHandleCallback");
+    python_cb = libvirt_lookupPythonFunc("_eventInvokeHandleCallback");
     if (!python_cb) {
         goto cleanup;
     }
@@ -2834,7 +2834,7 @@ libvirt_virEventAddTimeoutFunc(int timeout,
     LIBVIRT_ENSURE_THREAD_STATE;
 
     /* Lookup the python callback */
-    python_cb = libvirt_lookupPythonFunc("eventInvokeTimeoutCallback");
+    python_cb = libvirt_lookupPythonFunc("_eventInvokeTimeoutCallback");
     if (!python_cb) {
         goto cleanup;
     }
@@ -3224,7 +3224,7 @@ libvirt_virConnectDomainEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUS
 
     /* Call the Callback Dispatcher */
     pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"dispatchDomainEventLifecycleCallback",
+                                    (char*)"_dispatchDomainEventLifecycleCallback",
                                     (char*)"OiiO",
                                     pyobj_dom,
                                     event, detail,
@@ -3270,7 +3270,7 @@ libvirt_virConnectDomainEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED
 
     /* Call the Callback Dispatcher */
     pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"dispatchDomainEventGenericCallback",
+                                    (char*)"_dispatchDomainEventGenericCallback",
                                     (char*)"OO",
                                     pyobj_dom, pyobj_cbData);
 
@@ -3315,7 +3315,7 @@ libvirt_virConnectDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUS
 
     /* Call the Callback Dispatcher */
     pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"dispatchDomainEventRTCChangeCallback",
+                                    (char*)"_dispatchDomainEventRTCChangeCallback",
                                     (char*)"OLO",
                                     pyobj_dom,
                                     (PY_LONG_LONG)utcoffset,
@@ -3362,7 +3362,7 @@ libvirt_virConnectDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSE
 
     /* Call the Callback Dispatcher */
     pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"dispatchDomainEventWatchdogCallback",
+                                    (char*)"_dispatchDomainEventWatchdogCallback",
                                     (char*)"OiO",
                                     pyobj_dom,
                                     action,
@@ -3411,7 +3411,7 @@ libvirt_virConnectDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED
 
     /* Call the Callback Dispatcher */
     pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"dispatchDomainEventIOErrorCallback",
+                                    (char*)"_dispatchDomainEventIOErrorCallback",
                                     (char*)"OssiO",
                                     pyobj_dom,
                                     srcPath, devAlias, action,
@@ -3461,7 +3461,7 @@ libvirt_virConnectDomainEventIOErrorReasonCallback(virConnectPtr conn ATTRIBUTE_
 
     /* Call the Callback Dispatcher */
     pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"dispatchDomainEventIOErrorReasonCallback",
+                                    (char*)"_dispatchDomainEventIOErrorReasonCallback",
                                     (char*)"OssisO",
                                     pyobj_dom,
                                     srcPath, devAlias, action, reason,
@@ -3547,7 +3547,7 @@ libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSE
 
     /* Call the Callback Dispatcher */
     pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"dispatchDomainEventGraphicsCallback",
+                                    (char*)"_dispatchDomainEventGraphicsCallback",
                                     (char*)"OiOOsOO",
                                     pyobj_dom,
                                     phase, pyobj_local, pyobj_remote,
@@ -3596,7 +3596,7 @@ libvirt_virConnectDomainEventBlockPullCallback(virConnectPtr conn ATTRIBUTE_UNUS
 
     /* Call the Callback Dispatcher */
     pyobj_ret = PyObject_CallMethod(pyobj_conn,
-                                    (char*)"dispatchDomainEventBlockPullCallback",
+                                    (char*)"_dispatchDomainEventBlockPullCallback",
                                     (char*)"OsiO",
                                     pyobj_dom, path, status, pyobj_cbData);
 
@@ -3752,7 +3752,7 @@ libvirt_virStreamEventCallback(virStreamPtr st ATTRIBUTE_UNUSED,
 
     /* Call the pure python dispatcher */
     pyobj_ret = PyObject_CallMethod(pyobj_stream,
-                                    (char *)"dispatchStreamEventCallback",
+                                    (char *)"_dispatchStreamEventCallback",
                                     (char *)"iO",
                                     events, pyobj_cbData);
 
diff --git a/python/libvirt-override.py b/python/libvirt-override.py
index 8df9dc1..98241d6 100644
--- a/python/libvirt-override.py
+++ b/python/libvirt-override.py
@@ -117,7 +117,7 @@ def getVersion (name = None):
 #
 # Invoke an EventHandle callback
 #
-def eventInvokeHandleCallback(watch, fd, event, opaque, opaquecompat=None):
+def _eventInvokeHandleCallback(watch, fd, event, opaque, opaquecompat=None):
     """
     Invoke the Event Impl Handle Callback in C
     """
@@ -137,7 +137,7 @@ def eventInvokeHandleCallback(watch, fd, event, opaque, opaquecompat=None):
 #
 # Invoke an EventTimeout callback
 #
-def eventInvokeTimeoutCallback(timer, opaque, opaquecompat=None):
+def _eventInvokeTimeoutCallback(timer, opaque, opaquecompat=None):
     """
     Invoke the Event Impl Timeout Callback in C
     """
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]