1 From 89aa41f52d5946796ad8dea587cd848aef71c8c0 Mon Sep 17 00:00:00 2001
2 From: Scott Murray <scott.murray@konsulko.com>
3 Date: Mon, 27 Nov 2023 15:31:02 -0500
4 Subject: [PATCH 1/2] kuksa-client: Update cmd2 completer usage
6 Update cmd2 usage to avoid using internal methods and fix breakage
7 with newer versions of the cmd2 module.
9 Upstream-Status: pending
11 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
13 kuksa-client/kuksa_client/__main__.py | 33 +++++++++++++--------------
14 1 file changed, 16 insertions(+), 17 deletions(-)
16 diff --git a/kuksa-client/kuksa_client/__main__.py b/kuksa-client/kuksa_client/__main__.py
17 index 032410b..1d2d1fc 100755
18 --- a/kuksa-client/kuksa_client/__main__.py
19 +++ b/kuksa-client/kuksa_client/__main__.py
20 @@ -36,7 +36,6 @@ from cmd2 import CompletionItem
21 from cmd2 import with_argparser
22 from cmd2 import with_category
23 from cmd2 import constants
24 -from cmd2.utils import basic_complete
25 from urllib.parse import urlparse
27 from kuksa_client import kuksa_server_certificates
28 @@ -156,7 +155,7 @@ class TestClient(Cmd):
29 self.pathCompletionItems = []
30 for sub_id in self.subscribeIds:
31 self.pathCompletionItems.append(CompletionItem(sub_id))
32 - return basic_complete(text, line, begidx, endidx, self.pathCompletionItems)
33 + return Cmd.basic_complete(self, text, line, begidx, endidx, self.pathCompletionItems)
35 COMM_SETUP_COMMANDS = "Communication Set-up Commands"
36 VSS_COMMANDS = "Kuksa Interaction Commands"
37 @@ -171,19 +170,19 @@ class TestClient(Cmd):
39 ap_disconnect = argparse.ArgumentParser()
40 ap_authorize = argparse.ArgumentParser()
41 - tokenfile_completer_method = functools.partial(
42 + tokenfile_completer = functools.partial(
44 path_filter=lambda path: (os.path.isdir(path) or path.endswith(".token")),
46 ap_authorize.add_argument(
48 help="JWT(or the file storing the token) for authorizing the client.",
49 - completer_method=tokenfile_completer_method,
50 + completer=tokenfile_completer,
53 ap_setValue = argparse.ArgumentParser()
54 ap_setValue.add_argument(
55 - "Path", help="Path to be set", completer_method=path_completer
56 + "Path", help="Path to be set", completer=path_completer
58 ap_setValue.add_argument("Value", nargs="+", help="Value to be set")
59 ap_setValue.add_argument(
60 @@ -203,7 +202,7 @@ class TestClient(Cmd):
62 ap_getValue = argparse.ArgumentParser()
63 ap_getValue.add_argument(
64 - "Path", help="Path to be read", completer_method=path_completer
65 + "Path", help="Path to be read", completer=path_completer
67 ap_getValue.add_argument(
68 "-a", "--attribute", help="Attribute to be get", default="value"
69 @@ -214,7 +213,7 @@ class TestClient(Cmd):
71 help="Path whose value is to be read",
73 - completer_method=path_completer,
74 + completer=path_completer,
76 ap_getValues.add_argument(
77 "-a", "--attribute", help="Attribute to be get", default="value"
78 @@ -224,7 +223,7 @@ class TestClient(Cmd):
79 ap_setTargetValue.add_argument(
81 help="Path whose target value to be set",
82 - completer_method=path_completer,
83 + completer=path_completer,
85 ap_setTargetValue.add_argument("Value", help="Value to be set")
87 @@ -240,7 +239,7 @@ class TestClient(Cmd):
88 ap_getTargetValue.add_argument(
90 help="Path whose target value is to be read",
91 - completer_method=path_completer,
92 + completer=path_completer,
95 ap_getTargetValues = argparse.ArgumentParser()
96 @@ -248,12 +247,12 @@ class TestClient(Cmd):
98 help="Path whose target value is to be read",
100 - completer_method=path_completer,
101 + completer=path_completer,
104 ap_subscribe = argparse.ArgumentParser()
105 ap_subscribe.add_argument(
106 - "Path", help="Path to subscribe to", completer_method=path_completer
107 + "Path", help="Path to subscribe to", completer=path_completer
109 ap_subscribe.add_argument(
110 "-a", "--attribute", help="Attribute to subscribe to", default="value"
111 @@ -268,7 +267,7 @@ class TestClient(Cmd):
113 ap_subscribeMultiple = argparse.ArgumentParser()
114 ap_subscribeMultiple.add_argument(
115 - "Path", help="Path to subscribe to", nargs="+", completer_method=path_completer
116 + "Path", help="Path to subscribe to", nargs="+", completer=path_completer
118 ap_subscribeMultiple.add_argument(
119 "-a", "--attribute", help="Attribute to subscribe to", default="value"
120 @@ -284,18 +283,18 @@ class TestClient(Cmd):
121 ap_unsubscribe.add_argument(
123 help="Corresponding subscription Id",
124 - completer_method=subscriptionIdCompleter,
125 + completer=subscriptionIdCompleter,
128 ap_getMetaData = argparse.ArgumentParser()
129 ap_getMetaData.add_argument(
131 help="Path whose metadata is to be read",
132 - completer_method=path_completer,
133 + completer=path_completer,
135 ap_updateMetaData = argparse.ArgumentParser()
136 ap_updateMetaData.add_argument(
137 - "Path", help="Path whose MetaData is to update", completer_method=path_completer
138 + "Path", help="Path whose MetaData is to update", completer=path_completer
140 ap_updateMetaData.add_argument(
142 @@ -304,14 +303,14 @@ class TestClient(Cmd):
145 ap_updateVSSTree = argparse.ArgumentParser()
146 - jsonfile_completer_method = functools.partial(
147 + jsonfile_completer = functools.partial(
149 path_filter=lambda path: (os.path.isdir(path) or path.endswith(".json")),
151 ap_updateVSSTree.add_argument(
153 help="Json tree to update VSS",
154 - completer_method=jsonfile_completer_method,
155 + completer=jsonfile_completer,
158 # Constructor, request names after protocol to avoid errors