Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_uri.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 | 003b8b4b56a7 |
children | fee60f17ebac |
comparison
equal
deleted
inserted
replaced
3027:ff5bcb12ae60 | 3028:ab2696e34d29 |
---|---|
16 | 16 |
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 | 20 |
21 import base | 21 from . import base |
22 from sat.core.i18n import _ | 22 from sat.core.i18n import _ |
23 from sat_frontends.jp.constants import Const as C | 23 from sat_frontends.jp.constants import Const as C |
24 from sat.tools.common import uri | 24 from sat.tools.common import uri |
25 | 25 |
26 __commands__ = ["Uri"] | 26 __commands__ = ["Uri"] |
32 self, | 32 self, |
33 host, | 33 host, |
34 "parse", | 34 "parse", |
35 use_profile=False, | 35 use_profile=False, |
36 use_output=C.OUTPUT_DICT, | 36 use_output=C.OUTPUT_DICT, |
37 help=_(u"parse URI"), | 37 help=_("parse URI"), |
38 ) | 38 ) |
39 | 39 |
40 def add_parser_options(self): | 40 def add_parser_options(self): |
41 self.parser.add_argument( | 41 self.parser.add_argument( |
42 "uri", type=base.unicode_decoder, help=_(u"XMPP URI to parse") | 42 "uri", help=_("XMPP URI to parse") |
43 ) | 43 ) |
44 | 44 |
45 def start(self): | 45 def start(self): |
46 self.output(uri.parseXMPPUri(self.args.uri)) | 46 self.output(uri.parseXMPPUri(self.args.uri)) |
47 | 47 |
48 | 48 |
49 class Build(base.CommandBase): | 49 class Build(base.CommandBase): |
50 def __init__(self, host): | 50 def __init__(self, host): |
51 base.CommandBase.__init__( | 51 base.CommandBase.__init__( |
52 self, host, "build", use_profile=False, help=_(u"build URI") | 52 self, host, "build", use_profile=False, help=_("build URI") |
53 ) | 53 ) |
54 | 54 |
55 def add_parser_options(self): | 55 def add_parser_options(self): |
56 self.parser.add_argument("type", type=base.unicode_decoder, help=_(u"URI type")) | 56 self.parser.add_argument("type", help=_("URI type")) |
57 self.parser.add_argument("path", type=base.unicode_decoder, help=_(u"URI path")) | 57 self.parser.add_argument("path", help=_("URI path")) |
58 self.parser.add_argument( | 58 self.parser.add_argument( |
59 "-f", | 59 "-f", |
60 "--field", | 60 "--field", |
61 type=base.unicode_decoder, | |
62 action="append", | 61 action="append", |
63 nargs=2, | 62 nargs=2, |
64 dest="fields", | 63 dest="fields", |
65 metavar=(u"KEY", u"VALUE"), | 64 metavar=("KEY", "VALUE"), |
66 help=_(u"URI fields"), | 65 help=_("URI fields"), |
67 ) | 66 ) |
68 | 67 |
69 def start(self): | 68 def start(self): |
70 fields = dict(self.args.fields) if self.args.fields else {} | 69 fields = dict(self.args.fields) if self.args.fields else {} |
71 self.disp(uri.buildXMPPUri(self.args.type, path=self.args.path, **fields)) | 70 self.disp(uri.buildXMPPUri(self.args.type, path=self.args.path, **fields)) |