homescreen_git.bb: Bump SRCREV to add meson support
[AGL/meta-agl-demo.git] / recipes-connectivity / kuksa-val / kuksa-viss-client / 0002-kuksa_viss_client-Update-cmd2-completer-usage.patch
1 From 525122ade01998e34eabce74cb24d1c427c4b48d Mon Sep 17 00:00:00 2001
2 From: Scott Murray <scott.murray@konsulko.com>
3 Date: Wed, 21 Sep 2022 13:27:49 -0400
4 Subject: [PATCH] kuksa_viss_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 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
11 ---
12  kuksa_viss_client/__main__.py | 28 ++++++++++++++--------------
13  1 file changed, 14 insertions(+), 14 deletions(-)
14
15 diff --git a/kuksa_viss_client/__main__.py b/kuksa_viss_client/__main__.py
16 index 4d61433..d0b1af3 100755
17 --- a/kuksa_viss_client/__main__.py
18 +++ b/kuksa_viss_client/__main__.py
19 @@ -14,7 +14,7 @@ from typing import Dict, List
20  import queue, time, os
21  from pygments import highlight, lexers, formatters
22  from cmd2 import Cmd, with_argparser, with_category, Cmd2ArgumentParser, CompletionItem
23 -from cmd2.utils import CompletionError, basic_complete
24 +from cmd2.exceptions import CompletionError
25  import functools, subprocess
26  DEFAULT_SERVER_ADDR = "127.0.0.1"
27  DEFAULT_SERVER_PORT = 8090
28 @@ -82,7 +82,7 @@ class TestClient(Cmd):
29                      self.pathCompletionItems.append(CompletionItem(prefix + key+seperator, "Children of branch "+prefix+key))
30  
31  
32 -        return basic_complete(text, line, begidx, endidx, self.pathCompletionItems)
33 +        return Cmd.basic_complete(self, text, line, begidx, endidx, self.pathCompletionItems)
34  
35      def subscribeCallback(self, path, attr, resp):
36          print(path, attr)
37 @@ -93,7 +93,7 @@ class TestClient(Cmd):
38          self.pathCompletionItems = []
39          for id in self.subscribeIdToPath.keys():
40              self.pathCompletionItems.append(CompletionItem(id))
41 -        return basic_complete(text, line, begidx, endidx, self.pathCompletionItems)
42 +        return Cmd.basic_complete(self, text, line, begidx, endidx, self.pathCompletionItems)
43      
44      COMM_SETUP_COMMANDS = "Communication Set-up Commands"
45      VISS_COMMANDS = "Kuksa Interaction Commands"
46 @@ -106,44 +106,44 @@ class TestClient(Cmd):
47      ap_authorize = argparse.ArgumentParser()
48      tokenfile_completer_method = functools.partial(Cmd.path_complete,
49          path_filter=lambda path: (os.path.isdir(path) or path.endswith(".token")))
50 -    ap_authorize.add_argument('Token', help='JWT(or the file storing the token) for authorizing the client.', completer_method=tokenfile_completer_method)
51 +    ap_authorize.add_argument('Token', help='JWT(or the file storing the token) for authorizing the client.', completer=tokenfile_completer_method)
52      ap_setServerAddr = argparse.ArgumentParser()
53      ap_setServerAddr.add_argument('IP', help='VISS Server IP Address', default=DEFAULT_SERVER_ADDR)
54      ap_setServerAddr.add_argument('Port', type=int, help='VISS Server Websocket Port', default=DEFAULT_SERVER_PORT)
55  
56      ap_setValue = argparse.ArgumentParser()
57 -    ap_setValue.add_argument("Path", help="Path to be set", completer_method=path_completer)
58 +    ap_setValue.add_argument("Path", help="Path to be set", completer=path_completer)
59      ap_setValue.add_argument("Value", help="Value to be set")
60      ap_setValue.add_argument("Attribute", help="Attribute to be set", default="value", nargs=(0,1))
61  
62      ap_getValue = argparse.ArgumentParser()
63 -    ap_getValue.add_argument("Path", help="Path to be read", completer_method=path_completer)
64 +    ap_getValue.add_argument("Path", help="Path to be read", completer=path_completer)
65      ap_getValue.add_argument("Attribute", help="Attribute to be get", default="value", nargs=(0,1))
66  
67      ap_setTargetValue = argparse.ArgumentParser()
68 -    ap_setTargetValue.add_argument("Path", help="Path whose target value to be set", completer_method=path_completer)
69 +    ap_setTargetValue.add_argument("Path", help="Path whose target value to be set", completer=path_completer)
70      ap_setTargetValue.add_argument("Value", help="Value to be set")
71  
72      ap_getTargetValue = argparse.ArgumentParser()
73 -    ap_getTargetValue.add_argument("Path", help="Path whose target value to be read", completer_method=path_completer)
74 +    ap_getTargetValue.add_argument("Path", help="Path whose target value to be read", completer=path_completer)
75  
76      ap_subscribe = argparse.ArgumentParser()
77 -    ap_subscribe.add_argument("Path", help="Path to be subscribed", completer_method=path_completer)
78 -    ap_subscribe.add_argument("Attribute", help="Attribute to be subscribed", default="value", completer_method=path_completer, nargs=(0,1))
79 +    ap_subscribe.add_argument("Path", help="Path to be subscribed", completer=path_completer)
80 +    ap_subscribe.add_argument("Attribute", help="Attribute to be subscribed", default="value", completer=path_completer, nargs=(0,1))
81  
82      ap_unsubscribe = argparse.ArgumentParser()
83 -    ap_unsubscribe.add_argument("SubscribeId", help="Corresponding subscription Id", completer_method=subscriptionIdCompleter)
84 +    ap_unsubscribe.add_argument("SubscribeId", help="Corresponding subscription Id", completer=subscriptionIdCompleter)
85  
86      ap_getMetaData = argparse.ArgumentParser()
87 -    ap_getMetaData.add_argument("Path", help="Path whose metadata is to be read", completer_method=path_completer)
88 +    ap_getMetaData.add_argument("Path", help="Path whose metadata is to be read", completer=path_completer)
89      ap_updateMetaData = argparse.ArgumentParser()
90 -    ap_updateMetaData.add_argument("Path", help="Path whose MetaData is to update", completer_method=path_completer)
91 +    ap_updateMetaData.add_argument("Path", help="Path whose MetaData is to update", completer=path_completer)
92      ap_updateMetaData.add_argument("Json", help="MetaData to update. Note, only attributes can be update, if update children or the whole vss tree, use `updateVSSTree` instead.")
93  
94      ap_updateVSSTree = argparse.ArgumentParser()
95      jsonfile_completer_method = functools.partial(Cmd.path_complete,
96          path_filter=lambda path: (os.path.isdir(path) or path.endswith(".json")))
97 -    ap_updateVSSTree.add_argument("Json", help="Json tree to update VSS", completer_method=jsonfile_completer_method)
98 +    ap_updateVSSTree.add_argument("Json", help="Json tree to update VSS", completer=jsonfile_completer_method)
99  
100  
101      # Constructor
102 -- 
103 2.37.3
104