|
@@ -5,8 +5,10 @@ import subprocess
|
5
|
5
|
from datetime import datetime
|
6
|
6
|
import json
|
7
|
7
|
|
|
8
|
+max_comm_retries = 5
|
|
9
|
+
|
8
|
10
|
# https://unix.stackexchange.com/a/776620
|
9
|
|
-def query(verbose=False):
|
|
11
|
+def query_internal(verbose=False):
|
10
|
12
|
dir_path = os.path.abspath(os.path.dirname(__file__))
|
11
|
13
|
file_path = os.path.join(dir_path, "kwin_check.js")
|
12
|
14
|
datetime_now = datetime.now()
|
|
@@ -44,6 +46,14 @@ def query(verbose=False):
|
44
|
46
|
msg = result.stdout.decode().rstrip().split("\n")[0][4:]
|
45
|
47
|
return json.loads(msg)
|
46
|
48
|
|
|
49
|
+def query(verbose=False):
|
|
50
|
+ for attempts in range(0, max_comm_retries):
|
|
51
|
+ try:
|
|
52
|
+ return query_internal(verbose)
|
|
53
|
+ except Exception as e:
|
|
54
|
+ if attempts >= (max_comm_retries - 1):
|
|
55
|
+ raise e
|
|
56
|
+
|
47
|
57
|
if __name__ == "__main__":
|
48
|
58
|
info = query()
|
49
|
59
|
print("Name: \"{}\"".format(info["name"]))
|