1 """The `debug` module provides :class:`DebugPlugin` and associated
2 :class:`hooke.command.Command`\s which provide useful debugging
10 from ..command import Command, Argument
11 from ..plugin import Builtin
14 class DebugPlugin (Builtin):
16 super(DebugPlugin, self).__init__(name='debug')
19 return [VersionCommand(), DebugCommand()]
22 class VersionCommand (Command):
23 """Get the Hooke version, as well as versions for important Python
24 packages. Useful for debugging.
27 super(VersionCommand, self).__init__(
28 name='version', help=self.__doc__)
30 def _run(self, hooke, inqueue, outqueue, params):
34 'Python ' + sys.version]
35 for name,module in sorted(sys.modules.items()):
38 v = getattr(module, '__version__', None)
40 lines.append('%s %s' % (name, v))
43 'Platform: %s' % ' '.join(platform.uname()),
44 'User interface: %s' % hooke.ui.name,
47 lines.extend([p.name for p in hooke.plugins])
51 lines.extend([d.name for d in hooke.drivers])
52 outqueue.put('\n'.join(lines))
55 class DebugCommand (Command):
56 """Get Hooke attributes. Useful for debugging.
59 super(DebugCommand, self).__init__(
62 Argument(name='attribute', help="""
63 Hooke attribute to print.
68 def _run(self, hooke, inqueue, outqueue, params):
69 if params['attribute'] == None:
72 outqueue.put(getattr(hooke, params['attribute']))