annotate libervia/cli/cmd_profile.py @ 4272:89a0999884ac

cli (list/set): add "--comments" argument.
author Goffi <goffi@goffi.org>
date Thu, 20 Jun 2024 14:46:55 +0200
parents 0d7bb4df2343
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3137
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
1 #!/usr/bin/env python3
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
2
815
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
3
4075
47401850dec6 refactoring: rename `libervia.frontends.jp` to `libervia.cli`
Goffi <goffi@goffi.org>
parents: 4074
diff changeset
4 # Libervia CLI
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
815
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
6
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
7 # This program is free software: you can redistribute it and/or modify
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
10 # (at your option) any later version.
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
11
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
12 # This program is distributed in the hope that it will be useful,
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
15 # GNU Affero General Public License for more details.
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
16
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
19
814
59c7bc51c323 jp: refactoring using ArgParse
Dal <kedals0@gmail.com>
parents: 811
diff changeset
20 """This module permits to manage profiles. It can list, create, delete
1199
96fb74a4714d misc: fixed some typos
Matteo Cypriani <mcy@lm7.fr>
parents: 1139
diff changeset
21 and retrieve information about a profile."""
0
goffi@necton2
parents:
diff changeset
22
4075
47401850dec6 refactoring: rename `libervia.frontends.jp` to `libervia.cli`
Goffi <goffi@goffi.org>
parents: 4074
diff changeset
23 from libervia.cli.constants import Const as C
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
24 from libervia.backend.core.log import getLogger
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
25 from libervia.backend.core.i18n import _
4075
47401850dec6 refactoring: rename `libervia.frontends.jp` to `libervia.cli`
Goffi <goffi@goffi.org>
parents: 4074
diff changeset
26 from libervia.cli import base
402
f03688bdb858 jp: use with statement to open fifo
Goffi <goffi@goffi.org>
parents: 401
diff changeset
27
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
28 log = getLogger(__name__)
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
29
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
30
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
31 __commands__ = ["Profile"]
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
32
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
33 PROFILE_HELP = _("The name of the profile")
0
goffi@necton2
parents:
diff changeset
34
goffi@necton2
parents:
diff changeset
35
1597
91a605feed8c jp: added profile/connect command
Goffi <goffi@goffi.org>
parents: 1596
diff changeset
36 class ProfileConnect(base.CommandBase):
91a605feed8c jp: added profile/connect command
Goffi <goffi@goffi.org>
parents: 1596
diff changeset
37 """Dummy command to use profile_session parent, i.e. to be able to connect without doing anything else"""
91a605feed8c jp: added profile/connect command
Goffi <goffi@goffi.org>
parents: 1596
diff changeset
38
91a605feed8c jp: added profile/connect command
Goffi <goffi@goffi.org>
parents: 1596
diff changeset
39 def __init__(self, host):
91a605feed8c jp: added profile/connect command
Goffi <goffi@goffi.org>
parents: 1596
diff changeset
40 # it's weird to have a command named "connect" with need_connect=False, but it can be handy to be able
2336
a7438fe4e24d jp (profile): added disconnect command
Goffi <goffi@goffi.org>
parents: 2221
diff changeset
41 # to launch just the session, so some paradoxes don't hurt
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
42 super(ProfileConnect, self).__init__(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
43 host, "connect", need_connect=False, help=("connect a profile")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
44 )
1597
91a605feed8c jp: added profile/connect command
Goffi <goffi@goffi.org>
parents: 1596
diff changeset
45
91a605feed8c jp: added profile/connect command
Goffi <goffi@goffi.org>
parents: 1596
diff changeset
46 def add_parser_options(self):
91a605feed8c jp: added profile/connect command
Goffi <goffi@goffi.org>
parents: 1596
diff changeset
47 pass
91a605feed8c jp: added profile/connect command
Goffi <goffi@goffi.org>
parents: 1596
diff changeset
48
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
49 async def start(self):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
50 # connection is already managed by profile common commands
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
51 # so we just need to check arguments and quit
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
52 if not self.args.connect and not self.args.start_session:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
53 self.parser.error(_("You need to use either --connect or --start-session"))
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
54 self.host.quit()
1597
91a605feed8c jp: added profile/connect command
Goffi <goffi@goffi.org>
parents: 1596
diff changeset
55
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
56
2336
a7438fe4e24d jp (profile): added disconnect command
Goffi <goffi@goffi.org>
parents: 2221
diff changeset
57 class ProfileDisconnect(base.CommandBase):
a7438fe4e24d jp (profile): added disconnect command
Goffi <goffi@goffi.org>
parents: 2221
diff changeset
58
a7438fe4e24d jp (profile): added disconnect command
Goffi <goffi@goffi.org>
parents: 2221
diff changeset
59 def __init__(self, host):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
60 super(ProfileDisconnect, self).__init__(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
61 host, "disconnect", need_connect=False, help=("disconnect a profile")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
62 )
2336
a7438fe4e24d jp (profile): added disconnect command
Goffi <goffi@goffi.org>
parents: 2221
diff changeset
63
a7438fe4e24d jp (profile): added disconnect command
Goffi <goffi@goffi.org>
parents: 2221
diff changeset
64 def add_parser_options(self):
a7438fe4e24d jp (profile): added disconnect command
Goffi <goffi@goffi.org>
parents: 2221
diff changeset
65 pass
a7438fe4e24d jp (profile): added disconnect command
Goffi <goffi@goffi.org>
parents: 2221
diff changeset
66
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
67 async def start(self):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
68 try:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
69 await self.host.bridge.disconnect(self.args.profile)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
70 except Exception as e:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
71 self.disp(f"can't disconnect profile: {e}", error=True)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
72 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
73 else:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
74 self.host.quit()
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
75
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
76
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
77 class ProfileCreate(base.CommandBase):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
78 def __init__(self, host):
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
79 super(ProfileCreate, self).__init__(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
80 host, "create", use_profile=False, help=("create a new profile")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
81 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
82
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
83 def add_parser_options(self):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
84 self.parser.add_argument("profile", type=str, help=_("the name of the profile"))
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
85 self.parser.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
86 "-p",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
87 "--password",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
88 type=str,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
89 default="",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
90 help=_("the password of the profile"),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
91 )
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
92 self.parser.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
93 "-j", "--jid", type=str, help=_("the jid of the profile")
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
94 )
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
95 self.parser.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
96 "-x",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
97 "--xmpp-password",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
98 type=str,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
99 help=_(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
100 "the password of the XMPP account (use profile password if not specified)"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
101 ),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
102 metavar="PASSWORD",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
103 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
104 self.parser.add_argument(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
105 "-A",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
106 "--autoconnect",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
107 choices=[C.BOOL_TRUE, C.BOOL_FALSE],
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
108 nargs="?",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
109 const=C.BOOL_TRUE,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
110 help=_("connect this profile automatically when backend starts"),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
111 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
112 self.parser.add_argument(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
113 "-C",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
114 "--component",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
115 default="",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
116 help=_("set to component import name (entry point) if this is a component"),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
117 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
118
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
119 async def start(self):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
120 """Create a new profile"""
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
121 if self.args.profile in await self.host.bridge.profiles_list_get():
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
122 self.disp(f"Profile {self.args.profile} already exists.", error=True)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
123 self.host.quit(C.EXIT_BRIDGE_ERROR)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
124 try:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
125 await self.host.bridge.profile_create(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
126 self.args.profile, self.args.password, self.args.component
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
127 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
128 except Exception as e:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
129 self.disp(f"can't create profile: {e}", error=True)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
130 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
131
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
132 try:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
133 await self.host.bridge.profile_start_session(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
134 self.args.password, self.args.profile
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
135 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
136 except Exception as e:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
137 self.disp(f"can't start profile session: {e}", error=True)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
138 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
139
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
140 if self.args.jid:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
141 await self.host.bridge.param_set(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
142 "JabberID", self.args.jid, "Connection", profile_key=self.args.profile
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
143 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
144 xmpp_pwd = self.args.password or self.args.xmpp_password
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
145 if xmpp_pwd:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
146 await self.host.bridge.param_set(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
147 "Password", xmpp_pwd, "Connection", profile_key=self.args.profile
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
148 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
149
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
150 if self.args.autoconnect is not None:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
151 await self.host.bridge.param_set(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
152 "autoconnect_backend",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
153 self.args.autoconnect,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
154 "Connection",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
155 profile_key=self.args.profile,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
156 )
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
157
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
158 self.disp(f"profile {self.args.profile} created successfully", 1)
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
159 self.host.quit()
2336
a7438fe4e24d jp (profile): added disconnect command
Goffi <goffi@goffi.org>
parents: 2221
diff changeset
160
a7438fe4e24d jp (profile): added disconnect command
Goffi <goffi@goffi.org>
parents: 2221
diff changeset
161
1596
b7ee113183fc jp: better profile commands:
Goffi <goffi@goffi.org>
parents: 1404
diff changeset
162 class ProfileDefault(base.CommandBase):
b7ee113183fc jp: better profile commands:
Goffi <goffi@goffi.org>
parents: 1404
diff changeset
163 def __init__(self, host):
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
164 super(ProfileDefault, self).__init__(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
165 host, "default", use_profile=False, help=("print default profile")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
166 )
1596
b7ee113183fc jp: better profile commands:
Goffi <goffi@goffi.org>
parents: 1404
diff changeset
167
b7ee113183fc jp: better profile commands:
Goffi <goffi@goffi.org>
parents: 1404
diff changeset
168 def add_parser_options(self):
b7ee113183fc jp: better profile commands:
Goffi <goffi@goffi.org>
parents: 1404
diff changeset
169 pass
b7ee113183fc jp: better profile commands:
Goffi <goffi@goffi.org>
parents: 1404
diff changeset
170
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
171 async def start(self):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
172 print(await self.host.bridge.profile_name_get("@DEFAULT@"))
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
173 self.host.quit()
1596
b7ee113183fc jp: better profile commands:
Goffi <goffi@goffi.org>
parents: 1404
diff changeset
174
b7ee113183fc jp: better profile commands:
Goffi <goffi@goffi.org>
parents: 1404
diff changeset
175
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
176 class ProfileDelete(base.CommandBase):
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
177 def __init__(self, host):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
178 super(ProfileDelete, self).__init__(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
179 host, "delete", use_profile=False, help=("delete a profile")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
180 )
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
181
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
182 def add_parser_options(self):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
183 self.parser.add_argument("profile", type=str, help=PROFILE_HELP)
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
184 self.parser.add_argument(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
185 "-f",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
186 "--force",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
187 action="store_true",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
188 help=_("delete profile without confirmation"),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
189 )
0
goffi@necton2
parents:
diff changeset
190
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
191 async def start(self):
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
192 if self.args.profile not in await self.host.bridge.profiles_list_get():
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
193 log.error(f"Profile {self.args.profile} doesn't exist.")
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
194 self.host.quit(C.EXIT_NOT_FOUND)
1861
3b2a236fa743 jp (profile): added confirmation and --force arguement to profile/delete
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
195 if not self.args.force:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
196 message = f"Are you sure to delete profile [{self.args.profile}] ?"
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
197 cancel_message = "Profile deletion cancelled"
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
198 await self.host.confirm_or_quit(message, cancel_message)
1861
3b2a236fa743 jp (profile): added confirmation and --force arguement to profile/delete
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
199
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
200 await self.host.bridge.profile_delete_async(self.args.profile)
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
201 self.host.quit()
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
202
0
goffi@necton2
parents:
diff changeset
203
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
204 class ProfileInfo(base.CommandBase):
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
205
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
206 def __init__(self, host):
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
207 super(ProfileInfo, self).__init__(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
208 host,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
209 "info",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
210 need_connect=False,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
211 use_output=C.OUTPUT_DICT,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
212 help=_("get information about a profile"),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
213 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
214 self.to_show = [
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
215 (_("jid"), "Connection", "JabberID"),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
216 ]
1402
391b0c21f4be jp (profile): fixed "profile info" to use profile, and then manage connection.
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
217
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
218 def add_parser_options(self):
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
219 self.parser.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
220 "--show-password",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
221 action="store_true",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
222 help=_("show the XMPP password IN CLEAR TEXT"),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
223 )
814
59c7bc51c323 jp: refactoring using ArgParse
Dal <kedals0@gmail.com>
parents: 811
diff changeset
224
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
225 async def start(self):
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
226 if self.args.show_password:
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
227 self.to_show.append((_("XMPP password"), "Connection", "Password"))
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
228 self.to_show.append(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
229 (_("autoconnect (backend)"), "Connection", "autoconnect_backend")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
230 )
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
231 data = {}
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
232 for label, category, name in self.to_show:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
233 try:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
234 value = await self.host.bridge.param_get_a_async(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
235 name, category, profile_key=self.host.profile
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
236 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
237 except Exception as e:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
238 self.disp(f"can't get {name}/{category} param: {e}", error=True)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
239 else:
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
240 data[label] = value
814
59c7bc51c323 jp: refactoring using ArgParse
Dal <kedals0@gmail.com>
parents: 811
diff changeset
241
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
242 await self.output(data)
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
243 self.host.quit()
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
244
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
245
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
246 class ProfileList(base.CommandBase):
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
247 def __init__(self, host):
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
248 super(ProfileList, self).__init__(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
249 host, "list", use_profile=False, use_output="list", help=("list profiles")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
250 )
657
09bbd5c00244 jp: profiles management
Dal <kedals0@gmail.com>
parents: 627
diff changeset
251
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
252 def add_parser_options(self):
2146
1bb9bf1b4150 core, frontends: getProfilesList renamed to profilesGetList + behaviour change:
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
253 group = self.parser.add_mutually_exclusive_group()
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
254 group.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
255 "-c", "--clients", action="store_true", help=_("get clients profiles only")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
256 )
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
257 group.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
258 "-C",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
259 "--components",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
260 action="store_true",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
261 help=("get components profiles only"),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
262 )
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
263
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
264 async def start(self):
2146
1bb9bf1b4150 core, frontends: getProfilesList renamed to profilesGetList + behaviour change:
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
265 if self.args.clients:
1bb9bf1b4150 core, frontends: getProfilesList renamed to profilesGetList + behaviour change:
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
266 clients, components = True, False
1bb9bf1b4150 core, frontends: getProfilesList renamed to profilesGetList + behaviour change:
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
267 elif self.args.components:
1bb9bf1b4150 core, frontends: getProfilesList renamed to profilesGetList + behaviour change:
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
268 clients, components = False, True
1bb9bf1b4150 core, frontends: getProfilesList renamed to profilesGetList + behaviour change:
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
269 else:
1bb9bf1b4150 core, frontends: getProfilesList renamed to profilesGetList + behaviour change:
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
270 clients, components = True, True
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
271 await self.output(await self.host.bridge.profiles_list_get(clients, components))
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
272 self.host.quit()
657
09bbd5c00244 jp: profiles management
Dal <kedals0@gmail.com>
parents: 627
diff changeset
273
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
274
1404
e4e960d285b0 jp (profile): added "profile modify" command
Goffi <goffi@goffi.org>
parents: 1403
diff changeset
275 class ProfileModify(base.CommandBase):
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
276
1404
e4e960d285b0 jp (profile): added "profile modify" command
Goffi <goffi@goffi.org>
parents: 1403
diff changeset
277 def __init__(self, host):
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
278 super(ProfileModify, self).__init__(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
279 host, "modify", need_connect=False, help=_("modify an existing profile")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
280 )
1404
e4e960d285b0 jp (profile): added "profile modify" command
Goffi <goffi@goffi.org>
parents: 1403
diff changeset
281
e4e960d285b0 jp (profile): added "profile modify" command
Goffi <goffi@goffi.org>
parents: 1403
diff changeset
282 def add_parser_options(self):
1687
de9cc4d62a4a jp (profile): fixed profile/modify command:
Goffi <goffi@goffi.org>
parents: 1597
diff changeset
283 profile_pwd_group = self.parser.add_mutually_exclusive_group()
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
284 profile_pwd_group.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
285 "-w", "--password", help=_("change the password of the profile")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
286 )
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
287 profile_pwd_group.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
288 "--disable-password",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
289 action="store_true",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
290 help=_("disable profile password (dangerous!)"),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
291 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
292 self.parser.add_argument("-j", "--jid", help=_("the jid of the profile"))
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
293 self.parser.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
294 "-x",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
295 "--xmpp-password",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
296 help=_("change the password of the XMPP account"),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
297 metavar="PASSWORD",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
298 )
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
299 self.parser.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
300 "-D", "--default", action="store_true", help=_("set as default profile")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
301 )
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
302 self.parser.add_argument(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
303 "-A",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
304 "--autoconnect",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
305 choices=[C.BOOL_TRUE, C.BOOL_FALSE],
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
306 nargs="?",
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
307 const=C.BOOL_TRUE,
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
308 help=_("connect this profile automatically when backend starts"),
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
309 )
1404
e4e960d285b0 jp (profile): added "profile modify" command
Goffi <goffi@goffi.org>
parents: 1403
diff changeset
310
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
311 async def start(self):
1687
de9cc4d62a4a jp (profile): fixed profile/modify command:
Goffi <goffi@goffi.org>
parents: 1597
diff changeset
312 if self.args.disable_password:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
313 self.args.password = ""
1404
e4e960d285b0 jp (profile): added "profile modify" command
Goffi <goffi@goffi.org>
parents: 1403
diff changeset
314 if self.args.password is not None:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
315 await self.host.bridge.param_set(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
316 "Password", self.args.password, "General", profile_key=self.host.profile
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
317 )
1404
e4e960d285b0 jp (profile): added "profile modify" command
Goffi <goffi@goffi.org>
parents: 1403
diff changeset
318 if self.args.jid is not None:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
319 await self.host.bridge.param_set(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
320 "JabberID", self.args.jid, "Connection", profile_key=self.host.profile
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
321 )
1404
e4e960d285b0 jp (profile): added "profile modify" command
Goffi <goffi@goffi.org>
parents: 1403
diff changeset
322 if self.args.xmpp_password is not None:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
323 await self.host.bridge.param_set(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
324 "Password",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
325 self.args.xmpp_password,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
326 "Connection",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
327 profile_key=self.host.profile,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
328 )
1596
b7ee113183fc jp: better profile commands:
Goffi <goffi@goffi.org>
parents: 1404
diff changeset
329 if self.args.default:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
330 await self.host.bridge.profile_set_default(self.host.profile)
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
331 if self.args.autoconnect is not None:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
332 await self.host.bridge.param_set(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
333 "autoconnect_backend",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
334 self.args.autoconnect,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
335 "Connection",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
336 profile_key=self.host.profile,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
337 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
338
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
339 self.host.quit()
1404
e4e960d285b0 jp (profile): added "profile modify" command
Goffi <goffi@goffi.org>
parents: 1403
diff changeset
340
e4e960d285b0 jp (profile): added "profile modify" command
Goffi <goffi@goffi.org>
parents: 1403
diff changeset
341
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
342 class Profile(base.CommandBase):
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
343 subcommands = (
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
344 ProfileConnect,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
345 ProfileDisconnect,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
346 ProfileCreate,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
347 ProfileDefault,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
348 ProfileDelete,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
349 ProfileInfo,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
350 ProfileList,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
351 ProfileModify,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
352 )
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
353
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
354 def __init__(self, host):
3122
4486d72658b9 jp (profile): added --autoconnect argument in `modify` and `create` + use output in `info`
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
355 super(Profile, self).__init__(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
356 host, "profile", use_profile=False, help=_("profile commands")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4075
diff changeset
357 )