Mercurial > libervia-backend
comparison sat/plugins/plugin_dbg_manhole.py @ 3028:ab2696e34d29
Python 3 port:
/!\ this is a huge commit
/!\ starting from this commit, SàT is needs Python 3.6+
/!\ SàT maybe be instable or some feature may not work anymore, this will improve with time
This patch port backend, bridge and frontends to Python 3.
Roughly this has been done this way:
- 2to3 tools has been applied (with python 3.7)
- all references to python2 have been replaced with python3 (notably shebangs)
- fixed files not handled by 2to3 (notably the shell script)
- several manual fixes
- fixed issues reported by Python 3 that where not handled in Python 2
- replaced "async" with "async_" when needed (it's a reserved word from Python 3.7)
- replaced zope's "implements" with @implementer decorator
- temporary hack to handle data pickled in database, as str or bytes may be returned,
to be checked later
- fixed hash comparison for password
- removed some code which is not needed anymore with Python 3
- deactivated some code which needs to be checked (notably certificate validation)
- tested with jp, fixed reported issues until some basic commands worked
- ported Primitivus (after porting dependencies like urwid satext)
- more manual fixes
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 13 Aug 2019 19:08:41 +0200 |
parents | e2005dd39c92 |
children | 9211c0d8b50c |
comparison
equal
deleted
inserted
replaced
3027:ff5bcb12ae60 | 3028:ab2696e34d29 |
---|---|
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python3 |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 | 3 |
4 # SAT plugin for debugging, using a manhole | 4 # SAT plugin for debugging, using a manhole |
5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org) | 5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org) |
6 | 6 |
27 from twisted.conch.manhole import ColoredManhole | 27 from twisted.conch.manhole import ColoredManhole |
28 | 28 |
29 log = getLogger(__name__) | 29 log = getLogger(__name__) |
30 | 30 |
31 PLUGIN_INFO = { | 31 PLUGIN_INFO = { |
32 C.PI_NAME: u"Manhole debug plugin", | 32 C.PI_NAME: "Manhole debug plugin", |
33 C.PI_IMPORT_NAME: u"manhole", | 33 C.PI_IMPORT_NAME: "manhole", |
34 C.PI_TYPE: u"DEBUG", | 34 C.PI_TYPE: "DEBUG", |
35 C.PI_PROTOCOLS: [], | 35 C.PI_PROTOCOLS: [], |
36 C.PI_DEPENDENCIES: [], | 36 C.PI_DEPENDENCIES: [], |
37 C.PI_MAIN: u"Manhole", | 37 C.PI_MAIN: "Manhole", |
38 C.PI_HANDLER: u"no", | 38 C.PI_HANDLER: "no", |
39 C.PI_DESCRIPTION: _(u"""Debug plugin to have a telnet server"""), | 39 C.PI_DESCRIPTION: _("""Debug plugin to have a telnet server"""), |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 | 43 |
44 class Manhole(object): | 44 class Manhole(object): |
48 port = int(host.memory.getConfig(None, "manhole_debug_dangerous_port_int")) | 48 port = int(host.memory.getConfig(None, "manhole_debug_dangerous_port_int")) |
49 if port: | 49 if port: |
50 self.startManhole(port) | 50 self.startManhole(port) |
51 | 51 |
52 def startManhole(self, port): | 52 def startManhole(self, port): |
53 log.warning(_(u"/!\\ Manhole debug server activated, be sure to not use it in " | 53 log.warning(_("/!\\ Manhole debug server activated, be sure to not use it in " |
54 u"production, this is dangerous /!\\")) | 54 "production, this is dangerous /!\\")) |
55 log.info(_(u"You can connect to manhole server using telnet on port {port}") | 55 log.info(_("You can connect to manhole server using telnet on port {port}") |
56 .format(port=port)) | 56 .format(port=port)) |
57 f = protocol.ServerFactory() | 57 f = protocol.ServerFactory() |
58 namespace = { | 58 namespace = { |
59 u"host": self.host, | 59 "host": self.host, |
60 u"jid": jid, | 60 "jid": jid, |
61 } | 61 } |
62 f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol, | 62 f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol, |
63 insults.ServerProtocol, | 63 insults.ServerProtocol, |
64 ColoredManhole, | 64 ColoredManhole, |
65 namespace=namespace, | 65 namespace=namespace, |