Source

pida-patches / pida-remote-cleanup

Full commit
# HG changeset patch
# Parent f793432ac428515aaaf09a665695b99e4a117fb9
diff --git a/pida/utils/pdbus.py b/pida/utils/pdbus.py
--- a/pida/utils/pdbus.py
+++ b/pida/utils/pdbus.py
@@ -11,7 +11,6 @@ import py
 
 
 import dbus
-from dbus.service import BusName
 from dbus.lowlevel import MethodCallMessage
 from json import loads
 
@@ -157,9 +156,7 @@ class PidaRemote(object):
         self._pid = pid
         self._conn = conn
 
-    def call(self, path, method_name, *args, **kwargs):
-        """Calls a method with method_name under the subpath of path"""
-
+    def _path_namespace_signature(self, path, args, kwargs):
         if path:
             fpath = "%s/%s" %(self._path, path)
         else:
@@ -172,6 +169,12 @@ class PidaRemote(object):
         else:
             sig = MethodCallMessage.guess_signature(*args)
 
+        return fpath, ns, sig
+
+    def call(self, path, method_name, *args, **kwargs):
+        """Calls a method with method_name under the subpath of path"""
+        fpath, ns, sig = self._path_namespace_signature(path, args, kwargs)
+
         return self._conn.call_blocking(self._bus_name,
                                  fpath, 
                                  ns,
@@ -189,19 +192,7 @@ class PidaRemote(object):
         called on success or error.
 
         """
-
-        if path:
-            fpath = "%s/%s" %(self._path, path)
-        else:
-            fpath = self._path
-
-        ns = fpath.replace("/", ".")[1:]
-
-        if 'signature' in kwargs:
-            sig = kwargs['signature']
-        else:
-            sig = MethodCallMessage.guess_signature(*args)
-
+        fpath, ns, sig = self._path_namespace_signature(path, args, kwargs)
         reply_handler = kwargs.pop('reply_handler', None)
         error_handler = kwargs.pop('error_handler', None)