msmith - in flumotion/trunk: . flumotion/admin/command flumotion/common flumotion/component flumotion/manager flumotion/worker

flumotion-commit at lists.fluendo.com flumotion-commit at lists.fluendo.com
Tue Dec 4 16:32:22 CET 2007


Author: msmith
Date: Tue Dec  4 16:32:00 2007
New Revision: 5967

Modified:
   flumotion/trunk/ChangeLog
   flumotion/trunk/flumotion/admin/command/commands.py
   flumotion/trunk/flumotion/common/debug.py
   flumotion/trunk/flumotion/component/component.py
   flumotion/trunk/flumotion/manager/admin.py
   flumotion/trunk/flumotion/worker/medium.py
Log:
    * flumotion/admin/command/commands.py:
      Add 'workerremoteinvoke' to invoke a pb method, mirroring invoke
      for components and managerinvoke.
    * flumotion/common/debug.py:
      Add a getVersions() method that traverses sys.modules, and for all
      flumotion modules with __version__ info, packages up that info and
      returns it.
    * flumotion/component/component.py:
    * flumotion/manager/admin.py:
    * flumotion/worker/medium.py:
      Provide PB method to get versions via debug.getVersions() in components,
      managers, workers.



Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog	(original)
+++ flumotion/trunk/ChangeLog	Tue Dec  4 16:32:00 2007
@@ -1,3 +1,18 @@
+2007-12-04  Michael Smith <msmith at fluendo.com>
+
+	* flumotion/admin/command/commands.py:
+	  Add 'workerremoteinvoke' to invoke a pb method, mirroring invoke
+	  for components and managerinvoke.
+	* flumotion/common/debug.py:
+	  Add a getVersions() method that traverses sys.modules, and for all
+	  flumotion modules with __version__ info, packages up that info and
+	  returns it.
+	* flumotion/component/component.py:
+	* flumotion/manager/admin.py:
+	* flumotion/worker/medium.py:
+	  Provide PB method to get versions via debug.getVersions() in components,
+	  managers, workers.
+
 2007-12-04  Andy Wingo  <wingo at pobox.com>
 
 	* flumotion/admin/gtk/client.py (Window._component_kill): 

Modified: flumotion/trunk/flumotion/admin/command/commands.py
==============================================================================
--- flumotion/trunk/flumotion/admin/command/commands.py	(original)
+++ flumotion/trunk/flumotion/admin/command/commands.py	Tue Dec  4 16:32:00 2007
@@ -281,6 +281,28 @@
     quit()
 do_workerinvoke = defer_generator(do_workerinvoke)
 
+def do_workerremoteinvoke(model, quit, workerName, methodName, *args):
+    if args:
+        args = _parse_typed_args(args[0], args[1:])
+        if args is None:
+            quit()
+            yield None
+
+    d = model.callRemote('workerCallRemote', workerName, methodName, *args)
+    yield d
+
+    try:
+        v = d.value()
+        print "Invoke of %s on %s was successful." % (methodName, workerName)
+        print v
+    except errors.NoMethodError:
+        print "No method '%s' on component '%s'" % (methodName, workerName)
+    except Exception, e:
+        raise
+
+    quit()
+do_workerremoteinvoke = defer_generator(do_workerremoteinvoke)
+
 def do_managerinvoke(model, quit, methodName, *args):
     if args:
         args = _parse_typed_args(args[0], args[1:])
@@ -456,12 +478,17 @@
               ('args', str, None, True)),
              do_invoke),
             ('workerinvoke',
-             'invoke a function on a worker',
+             'invoke an arbitrary function on a worker',
              (('worker-name', str),
               ('module-name', str),
               ('method-name', str),
               ('args', str, None, True)),
              do_workerinvoke),
+            ('workerremoteinvoke',
+             'invoke a remote function on a manager',
+             (('method-name', str),
+              ('args', str, None, True)),
+             do_workerremoteinvoke),
             ('managerinvoke',
              'invoke a function on a manager',
              (('method-name', str),

Modified: flumotion/trunk/flumotion/common/debug.py
==============================================================================
--- flumotion/trunk/flumotion/common/debug.py	(original)
+++ flumotion/trunk/flumotion/common/debug.py	Tue Dec  4 16:32:00 2007
@@ -285,4 +285,23 @@
         for wrap in directAllocs:
             print '  ' + self._wrapperRepr(wrap)
 
+def getVersions():
+    """
+    Get versions of all flumotion modules based on svn Rev keyword.
+    """
+    r = {}
+    for modname in sys.modules:
+        mod = sys.modules[modname]
+        if modname.startswith('flumotion.') and hasattr(mod, "__version__"):
+            # Has the form: "$Rev$"
+            try:
+                versionnum = int(mod.__version__[6:-2])
+                r[modname] = versionnum
+            except IndexError:
+                pass
+            except ValueError:
+                pass
+
+    return r
+
 __version__ = "$Rev$"

Modified: flumotion/trunk/flumotion/component/component.py
==============================================================================
--- flumotion/trunk/flumotion/component/component.py	(original)
+++ flumotion/trunk/flumotion/component/component.py	Tue Dec  4 16:32:00 2007
@@ -34,7 +34,7 @@
 
 from flumotion.common import interfaces, errors, log, planet, medium
 from flumotion.common import componentui, common, registry, messages
-from flumotion.common import interfaces, reflectcall
+from flumotion.common import interfaces, reflectcall, debug
 
 from flumotion.common.planet import moods
 from flumotion.configure import configure
@@ -243,6 +243,9 @@
         """
         return None
 
+    def remote_getVersions(self):
+        return debug.getVersions()
+
 class BaseComponent(common.InitMixin, log.Loggable):
     """
     I am the base class for all Flumotion components.

Modified: flumotion/trunk/flumotion/manager/admin.py
==============================================================================
--- flumotion/trunk/flumotion/manager/admin.py	(original)
+++ flumotion/trunk/flumotion/manager/admin.py	Tue Dec  4 16:32:00 2007
@@ -33,7 +33,7 @@
 from zope.interface import implements
 
 from flumotion.manager import base
-from flumotion.common import errors, interfaces, log, planet, registry
+from flumotion.common import errors, interfaces, log, planet, registry, debug
 
 # make Result and Message proxyable
 from flumotion.common import messages
@@ -361,14 +361,7 @@
         return self.vishnu.deleteComponent(componentState)
 
     def perspective_getVersions(self):
-        import sys
-        r = []
-        for modname in sys.modules:
-            mod = sys.modules[modname]
-            if hasattr(mod, "__version__"):
-                r.append("%s -> %s" % (modname, mod.__version__))
-
-        return r
+        return debug.getVersions()
 
     # Deprecated -- remove me when no one uses me any more
     def perspective_cleanComponents(self):

Modified: flumotion/trunk/flumotion/worker/medium.py
==============================================================================
--- flumotion/trunk/flumotion/worker/medium.py	(original)
+++ flumotion/trunk/flumotion/worker/medium.py	Tue Dec  4 16:32:00 2007
@@ -29,7 +29,7 @@
 from twisted.spread import flavors
 from zope.interface import implements
 
-from flumotion.common import errors, interfaces, log
+from flumotion.common import errors, interfaces, log, debug
 from flumotion.common import medium
 from flumotion.twisted import pb as fpb
 
@@ -272,4 +272,7 @@
         """
         self.brain.killJob(avatarId, signum)
 
+    def remote_getVersions(self):
+        return debug.getVersions()
+
 __version__ = "$Rev$"


More information about the flumotion-commit mailing list