Upgrade KUKSA.val components to 0.4.2 release
[AGL/meta-agl-demo.git] / recipes-connectivity / kuksa-val / kuksa-client / 0001-kuksa-client-Update-cmd2-completer-usage.patch
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
5
6 Update cmd2 usage to avoid using internal methods and fix breakage
7 with newer versions of the cmd2 module.
8
9 Upstream-Status: pending
10
11 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
12 ---
13  kuksa-client/kuksa_client/__main__.py | 33 +++++++++++++--------------
14  1 file changed, 16 insertions(+), 17 deletions(-)
15
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
26  
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)
34  
35      COMM_SETUP_COMMANDS = "Communication Set-up Commands"
36      VSS_COMMANDS = "Kuksa Interaction Commands"
37 @@ -171,19 +170,19 @@ class TestClient(Cmd):
38  
39      ap_disconnect = argparse.ArgumentParser()
40      ap_authorize = argparse.ArgumentParser()
41 -    tokenfile_completer_method = functools.partial(
42 +    tokenfile_completer = functools.partial(
43          Cmd.path_complete,
44          path_filter=lambda path: (os.path.isdir(path) or path.endswith(".token")),
45      )
46      ap_authorize.add_argument(
47          "token_or_tokenfile",
48          help="JWT(or the file storing the token) for authorizing the client.",
49 -        completer_method=tokenfile_completer_method,
50 +        completer=tokenfile_completer,
51      )
52  
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
57      )
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):
61  
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
66      )
67      ap_getValue.add_argument(
68          "-a", "--attribute", help="Attribute to be get", default="value"
69 @@ -214,7 +213,7 @@ class TestClient(Cmd):
70          "Path",
71          help="Path whose value is to be read",
72          nargs="+",
73 -        completer_method=path_completer,
74 +        completer=path_completer,
75      )
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(
80          "Path",
81          help="Path whose target value to be set",
82 -        completer_method=path_completer,
83 +        completer=path_completer,
84      )
85      ap_setTargetValue.add_argument("Value", help="Value to be set")
86  
87 @@ -240,7 +239,7 @@ class TestClient(Cmd):
88      ap_getTargetValue.add_argument(
89          "Path",
90          help="Path whose target value is to be read",
91 -        completer_method=path_completer,
92 +        completer=path_completer,
93      )
94  
95      ap_getTargetValues = argparse.ArgumentParser()
96 @@ -248,12 +247,12 @@ class TestClient(Cmd):
97          "Path",
98          help="Path whose target value is to be read",
99          nargs="+",
100 -        completer_method=path_completer,
101 +        completer=path_completer,
102      )
103  
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
108      )
109      ap_subscribe.add_argument(
110          "-a", "--attribute", help="Attribute to subscribe to", default="value"
111 @@ -268,7 +267,7 @@ class TestClient(Cmd):
112  
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
117      )
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(
122          "SubscribeId",
123          help="Corresponding subscription Id",
124 -        completer_method=subscriptionIdCompleter,
125 +        completer=subscriptionIdCompleter,
126      )
127  
128      ap_getMetaData = argparse.ArgumentParser()
129      ap_getMetaData.add_argument(
130          "Path",
131          help="Path whose metadata is to be read",
132 -        completer_method=path_completer,
133 +        completer=path_completer,
134      )
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
139      )
140      ap_updateMetaData.add_argument(
141          "Json",
142 @@ -304,14 +303,14 @@ class TestClient(Cmd):
143      )
144  
145      ap_updateVSSTree = argparse.ArgumentParser()
146 -    jsonfile_completer_method = functools.partial(
147 +    jsonfile_completer = functools.partial(
148          Cmd.path_complete,
149          path_filter=lambda path: (os.path.isdir(path) or path.endswith(".json")),
150      )
151      ap_updateVSSTree.add_argument(
152          "Json",
153          help="Json tree to update VSS",
154 -        completer_method=jsonfile_completer_method,
155 +        completer=jsonfile_completer,
156      )
157  
158      # Constructor, request names after protocol to avoid errors
159 -- 
160 2.42.0
161