else:
self.outlet.delete(args)
- def do_debug(self,args):
- '''
- this is a dummy command where I put debugging things
- '''
- print self.config['plotmanips']
- pass
-
- def help_current(self):
- print '''
-CURRENT
-Prints the current curve path.
-------
-Syntax: current
- '''
- def do_current(self,args):
- print self.current.path
-
-
-
if __name__ == '__main__':
mycli=HookeCli(0)
mycli.cmdloop()
--- /dev/null
+"""The `debug` module provides :class:`DebugPlugin` and associated
+:class:`hooke.command.Command`\s which provide useful debugging
+information.
+"""
+
+import platform
+import sys
+
+from .. import version
+from ..command import Command, Argument
+from ..plugin import Builtin
+
+
+class DebugPlugin (Builtin):
+ def __init__(self):
+ super(DebugPlugin, self).__init__(name='debug')
+
+ def commands(self):
+ return [VersionCommand(), DebugCommand()]
+
+
+class VersionCommand (Command):
+ """Get the Hooke version, as well as versions for important Python
+ packages. Useful for debugging.
+ """
+ def __init__(self):
+ super(VersionCommand, self).__init__(
+ name='version', help=self.__doc__)
+
+ def _run(self, hooke, inqueue, outqueue, params):
+ lines = [
+ 'Hooke ' + version(),
+ '---',
+ 'Python ' + sys.version]
+ for name,module in sorted(sys.modules.items()):
+ if name == 'hooke':
+ continue
+ v = getattr(module, '__version__', None)
+ if v != None:
+ lines.append('%s %s' % (name, v))
+ lines.extend([
+ '---',
+ 'Platform: %s' % ' '.join(platform.uname()),
+ 'User interface: %s' % hooke.ui.name,
+ '---',
+ 'Loaded plugins:'])
+ lines.extend([p.name for p in hooke.plugins])
+ lines.extend([
+ '---',
+ 'Loaded drivers:'])
+ lines.extend([d.name for d in hooke.drivers])
+ outqueue.put('\n'.join(lines))
+
+
+class DebugCommand (Command):
+ """Get Hooke attributes. Useful for debugging.
+ """
+ def __init__(self):
+ super(DebugCommand, self).__init__(
+ name='debug',
+ arguments=[
+ Argument(name='attribute', help="""
+Hooke attribute to print.
+""".strip()),
+ ],
+ help=self.__doc__)
+
+ def _run(self, hooke, inqueue, outqueue, params):
+ if params['attribute'] == None:
+ outqueue.put(hooke)
+ else:
+ outqueue.put(getattr(hooke, params['attribute']))