Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 44ebac0

Browse files
committed
Minor Fixes.
- Checking existence of xterm before starting it in case of a subscribe. - Checks for subscription ID before unsubscribing Signed-off-by: nayakned <naresh.nayak@de.bosch.com>
1 parent 7cb6f2d commit 44ebac0

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

kuksa_viss_client/__main__.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ def do_subscribe(self, args):
196196
self.subscribeIdToPath[resJson["subscriptionId"]] = args.Path
197197
print("Subscription log available at " + fileName)
198198
print("Execute tail -f " + fileName + " on another Terminal instance")
199-
subprocess.Popen(["xterm", "-e", "/bin/bash", "-l", "-c", "tail -f " + fileName])
199+
from shutil import which
200+
if which("xterm") != None:
201+
subprocess.Popen(["xterm", "-e", "/bin/bash", "-l", "-c", "tail -f " + fileName])
200202
print(highlight(resp, lexers.JsonLexer(), formatters.TerminalFormatter()))
201203
self.pathCompletionItems = []
202204

@@ -207,12 +209,13 @@ def do_unsubscribe(self, args):
207209
if self.checkConnection():
208210
resp = self.commThread.unsubscribe(args.SubscribeId)
209211
print(highlight(resp, lexers.JsonLexer(), formatters.TerminalFormatter()))
210-
path = self.subscribeIdToPath[args.SubscribeId]
211-
if path in self.subscribeFileDesc:
212-
self.subscribeFileDesc[path].close()
213-
del(self.subscribeFileDesc[path])
214-
del(self.subscribeIdToPath[args.SubscribeId])
215-
self.pathCompletionItems = []
212+
if args.SubscribeId in self.subscribeIdToPath.keys():
213+
path = self.subscribeIdToPath[args.SubscribeId]
214+
if path in self.subscribeFileDesc:
215+
self.subscribeFileDesc[path].close()
216+
del(self.subscribeFileDesc[path])
217+
del(self.subscribeIdToPath[args.SubscribeId])
218+
self.pathCompletionItems = []
216219

217220
def do_quit(self, args):
218221
if hasattr(self, "commThread"):

0 commit comments

Comments
 (0)