1 # Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
3 # This file is part of Hooke.
5 # Hooke is free software: you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation, either
8 # version 3 of the License, or (at your option) any later version.
10 # Hooke is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with Hooke. If not, see
17 # <http://www.gnu.org/licenses/>.
19 """The `debug` module provides :class:`DebugPlugin` and associated
20 :class:`hooke.command.Command`\s which provide useful debugging
27 from .. import version
28 from ..command import Command, Argument
29 from ..plugin import Builtin
32 class DebugPlugin (Builtin):
34 super(DebugPlugin, self).__init__(name='debug')
37 return [VersionCommand(), DebugCommand()]
40 class VersionCommand (Command):
41 """Get the Hooke version, as well as versions for important Python
42 packages. Useful for debugging.
45 super(VersionCommand, self).__init__(
46 name='version', help=self.__doc__)
48 def _run(self, hooke, inqueue, outqueue, params):
52 'Python ' + sys.version]
53 for name,module in sorted(sys.modules.items()):
56 v = getattr(module, '__version__', None)
58 lines.append('%s %s' % (name, v))
61 'Platform: %s' % ' '.join(platform.uname()),
62 'User interface: %s' % hooke.ui.name,
65 lines.extend([p.name for p in hooke.plugins])
69 lines.extend([d.name for d in hooke.drivers])
70 outqueue.put('\n'.join(lines))
73 class DebugCommand (Command):
74 """Get Hooke attributes. Useful for debugging.
77 super(DebugCommand, self).__init__(
80 Argument(name='attribute', help="""
81 Hooke attribute to print.
86 def _run(self, hooke, inqueue, outqueue, params):
87 if params['attribute'] == None:
90 outqueue.put(getattr(hooke, params['attribute']))