1 From cc4da8b14896739ac2966ecad0a5c82ab1de025c Mon Sep 17 00:00:00 2001
2 From: Scott Murray <scott.murray@konsulko.com>
3 Date: Sat, 5 Aug 2023 13:26:55 -0400
4 Subject: [PATCH 1/2] kuksa_viss_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 | 31 +++++++++++++--------------
14 1 file changed, 15 insertions(+), 16 deletions(-)
16 diff --git a/kuksa-client/kuksa_client/__main__.py b/kuksa-client/kuksa_client/__main__.py
17 index 948cf56..fceca41 100755
18 --- a/kuksa-client/kuksa_client/__main__.py
19 +++ b/kuksa-client/kuksa_client/__main__.py
20 @@ -35,7 +35,6 @@ from cmd2 import Cmd
21 from cmd2 import CompletionItem
22 from cmd2 import with_argparser
23 from cmd2 import with_category
24 -from cmd2.utils import basic_complete
26 import kuksa_certificates
27 from kuksa_client import KuksaClientThread
28 @@ -126,7 +125,7 @@ class TestClient(Cmd):
29 "Children of branch "+prefix+key),
32 - return basic_complete(text, line, begidx, endidx, self.pathCompletionItems)
33 + return Cmd.basic_complete(self, text, line, begidx, endidx, self.pathCompletionItems)
35 def subscribeCallback(self, logPath, resp):
36 with logPath.open('a', encoding='utf-8') as logFile:
37 @@ -136,7 +135,7 @@ class TestClient(Cmd):
38 self.pathCompletionItems = []
39 for sub_id in self.subscribeIds:
40 self.pathCompletionItems.append(CompletionItem(sub_id))
41 - return basic_complete(text, line, begidx, endidx, self.pathCompletionItems)
42 + return Cmd.basic_complete(self, text, line, begidx, endidx, self.pathCompletionItems)
44 COMM_SETUP_COMMANDS = "Communication Set-up Commands"
45 VSS_COMMANDS = "Kuksa Interaction Commands"
46 @@ -153,7 +152,7 @@ class TestClient(Cmd):
47 ap_authorize.add_argument(
49 help='JWT(or the file storing the token) for authorizing the client.',
50 - completer_method=tokenfile_completer_method,)
51 + completer=tokenfile_completer_method,)
52 ap_setServerAddr = argparse.ArgumentParser()
53 ap_setServerAddr.add_argument(
54 'IP', help='VISS/gRPC Server IP Address', default=DEFAULT_SERVER_ADDR)
55 @@ -168,7 +167,7 @@ class TestClient(Cmd):
57 ap_setValue = argparse.ArgumentParser()
58 ap_setValue.add_argument(
59 - "Path", help="Path to be set", completer_method=path_completer)
60 + "Path", help="Path to be set", completer=path_completer)
61 ap_setValue.add_argument("Value", nargs='+', help="Value to be set")
62 ap_setValue.add_argument(
63 "-a", "--attribute", help="Attribute to be set", default="value")
64 @@ -185,19 +184,19 @@ class TestClient(Cmd):
66 ap_getValue = argparse.ArgumentParser()
67 ap_getValue.add_argument(
68 - "Path", help="Path to be read", completer_method=path_completer)
69 + "Path", help="Path to be read", completer=path_completer)
70 ap_getValue.add_argument(
71 "-a", "--attribute", help="Attribute to be get", default="value")
73 ap_getValues = argparse.ArgumentParser()
74 ap_getValues.add_argument(
75 - "Path", help="Path whose value is to be read", nargs='+', completer_method=path_completer)
76 + "Path", help="Path whose value is to be read", nargs='+', completer=path_completer)
77 ap_getValues.add_argument(
78 "-a", "--attribute", help="Attribute to be get", default="value")
80 ap_setTargetValue = argparse.ArgumentParser()
81 ap_setTargetValue.add_argument(
82 - "Path", help="Path whose target value to be set", completer_method=path_completer)
83 + "Path", help="Path whose target value to be set", completer=path_completer)
84 ap_setTargetValue.add_argument("Value", help="Value to be set")
86 ap_setTargetValues = argparse.ArgumentParser()
87 @@ -210,35 +209,35 @@ class TestClient(Cmd):
89 ap_getTargetValue = argparse.ArgumentParser()
90 ap_getTargetValue.add_argument(
91 - "Path", help="Path whose target value is to be read", completer_method=path_completer)
92 + "Path", help="Path whose target value is to be read", completer=path_completer)
94 ap_getTargetValues = argparse.ArgumentParser()
95 ap_getTargetValues.add_argument(
96 - "Path", help="Path whose target value is to be read", nargs='+', completer_method=path_completer)
97 + "Path", help="Path whose target value is to be read", nargs='+', completer=path_completer)
99 ap_subscribe = argparse.ArgumentParser()
100 ap_subscribe.add_argument(
101 - "Path", help="Path to subscribe to", completer_method=path_completer)
102 + "Path", help="Path to subscribe to", completer=path_completer)
103 ap_subscribe.add_argument(
104 "-a", "--attribute", help="Attribute to subscribe to", default="value")
106 ap_subscribeMultiple = argparse.ArgumentParser()
107 ap_subscribeMultiple.add_argument(
108 - "Path", help="Path to subscribe to", nargs='+', completer_method=path_completer)
109 + "Path", help="Path to subscribe to", nargs='+', completer=path_completer)
110 ap_subscribeMultiple.add_argument(
111 "-a", "--attribute", help="Attribute to subscribe to", default="value")
113 ap_unsubscribe = argparse.ArgumentParser()
114 ap_unsubscribe.add_argument(
115 - "SubscribeId", help="Corresponding subscription Id", completer_method=subscriptionIdCompleter,
116 + "SubscribeId", help="Corresponding subscription Id", completer=subscriptionIdCompleter,
119 ap_getMetaData = argparse.ArgumentParser()
120 ap_getMetaData.add_argument(
121 - "Path", help="Path whose metadata is to be read", completer_method=path_completer)
122 + "Path", help="Path whose metadata is to be read", completer=path_completer)
123 ap_updateMetaData = argparse.ArgumentParser()
124 ap_updateMetaData.add_argument(
125 - "Path", help="Path whose MetaData is to update", completer_method=path_completer)
126 + "Path", help="Path whose MetaData is to update", completer=path_completer)
127 ap_updateMetaData.add_argument(
129 help="MetaData to update. Note, only attributes can be update, if update children or the whole vss tree, use"
130 @@ -249,7 +248,7 @@ class TestClient(Cmd):
131 jsonfile_completer_method = functools.partial(Cmd.path_complete,
132 path_filter=lambda path: (os.path.isdir(path) or path.endswith(".json")))
133 ap_updateVSSTree.add_argument(
134 - "Json", help="Json tree to update VSS", completer_method=jsonfile_completer_method)
135 + "Json", help="Json tree to update VSS", completer=jsonfile_completer_method)
137 # Constructor, request names after protocol to avoid errors
138 def __init__(self, server_ip=None, server_port=None, server_protocol=None, *, insecure=False, token_or_tokenfile=None,