3 """The `debug` module provides :class:`DebugPlugin` and associated
4 :class:`hooke.command.Command`\s which provide useful debugging
11 from .. import version
12 from ..command import Command, Argument
13 from ..plugin import Builtin
16 class DebugPlugin (Builtin):
18 super(DebugPlugin, self).__init__(name='debug')
21 return [VersionCommand(), DebugCommand()]
24 class VersionCommand (Command):
25 """Get the Hooke version, as well as versions for important Python
26 packages. Useful for debugging.
29 super(VersionCommand, self).__init__(
30 name='version', help=self.__doc__)
32 def _run(self, hooke, inqueue, outqueue, params):
36 'Python ' + sys.version]
37 for name,module in sorted(sys.modules.items()):
40 v = getattr(module, '__version__', None)
42 lines.append('%s %s' % (name, v))
45 'Platform: %s' % ' '.join(platform.uname()),
46 'User interface: %s' % hooke.ui.name,
49 lines.extend([p.name for p in hooke.plugins])
53 lines.extend([d.name for d in hooke.drivers])
54 outqueue.put('\n'.join(lines))
57 class DebugCommand (Command):
58 """Get Hooke attributes. Useful for debugging.
61 super(DebugCommand, self).__init__(
64 Argument(name='attribute', help="""
65 Hooke attribute to print.
70 def _run(self, hooke, inqueue, outqueue, params):
71 if params['attribute'] == None:
74 outqueue.put(getattr(hooke, params['attribute']))