hackerbot 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hackerbot/utils/serial_helper.py +16 -10
- {hackerbot-0.3.0.dist-info → hackerbot-0.4.0.dist-info}/METADATA +2 -2
- {hackerbot-0.3.0.dist-info → hackerbot-0.4.0.dist-info}/RECORD +6 -6
- {hackerbot-0.3.0.dist-info → hackerbot-0.4.0.dist-info}/WHEEL +1 -1
- {hackerbot-0.3.0.dist-info → hackerbot-0.4.0.dist-info}/licenses/LICENSE +0 -0
- {hackerbot-0.3.0.dist-info → hackerbot-0.4.0.dist-info}/top_level.txt +0 -0
hackerbot/utils/serial_helper.py
CHANGED
@@ -23,6 +23,7 @@ import threading
|
|
23
23
|
import os
|
24
24
|
import json
|
25
25
|
from collections import deque
|
26
|
+
import time
|
26
27
|
|
27
28
|
class SerialHelper:
|
28
29
|
HOME_DIR = os.environ['HOME']
|
@@ -39,7 +40,7 @@ class SerialHelper:
|
|
39
40
|
self.state = None
|
40
41
|
self.ser_error = None
|
41
42
|
|
42
|
-
self.json_entries = deque(maxlen=
|
43
|
+
self.json_entries = deque(maxlen=20) # Store up to 10 most recent JSON entries
|
43
44
|
|
44
45
|
try:
|
45
46
|
if self.port is None:
|
@@ -123,15 +124,20 @@ class SerialHelper:
|
|
123
124
|
def get_json_from_command(self, command_filter=None):
|
124
125
|
if command_filter is None:
|
125
126
|
raise ValueError("command_filter cannot be None")
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
127
|
+
|
128
|
+
for attempt in range(5):
|
129
|
+
if self.json_entries is None or len(self.json_entries) == 0:
|
130
|
+
time.sleep(0.1)
|
131
|
+
continue
|
132
|
+
|
133
|
+
for entry in reversed(self.json_entries):
|
134
|
+
if entry.get("command") == command_filter:
|
135
|
+
if entry.get("success") == "true":
|
136
|
+
return entry
|
137
|
+
raise Exception("Fail to fetch...")
|
138
|
+
time.sleep(0.1)
|
139
|
+
|
140
|
+
raise Exception(f"Command {command_filter} not found in JSON entries after 5 retries")
|
135
141
|
|
136
142
|
def stop_read_thread(self):
|
137
143
|
"""Call this method to stop the serial reading thread."""
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hackerbot
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
4
4
|
Summary: This module contains the setup for the hackerbot python package.
|
5
|
-
Author-email: Allen Chien <
|
5
|
+
Author-email: Allen Chien <allen@hackerbot.co>
|
6
6
|
License-Expression: MIT
|
7
7
|
Project-URL: Homepage, https://github.com/hackerbotindustries/hackerbot-python-package
|
8
8
|
Requires-Python: >=3.11
|
@@ -7,9 +7,9 @@ hackerbot/base/maps.py,sha256=I_4NdvOMnkHX6-mW43QpDPJ-eVc6npgcBXq99tU7D1g,5916
|
|
7
7
|
hackerbot/head/__init__.py,sha256=VvKc6Gy3hNARUbFf8HoKkc2TFWoSSswrJbqytvEKUSA,3186
|
8
8
|
hackerbot/head/eyes.py,sha256=xqeKMxL12iaa8KQzDlbgbNy3LzcmWm8aXkebztYJ4P8,1370
|
9
9
|
hackerbot/utils/hackerbot_helper.py,sha256=egQPVBBUo52ywsO6jGAGVqhyGLpMPz-b2fgLBb39WSM,4998
|
10
|
-
hackerbot/utils/serial_helper.py,sha256=
|
11
|
-
hackerbot-0.
|
12
|
-
hackerbot-0.
|
13
|
-
hackerbot-0.
|
14
|
-
hackerbot-0.
|
15
|
-
hackerbot-0.
|
10
|
+
hackerbot/utils/serial_helper.py,sha256=qo-mpbE_sb23_IAIfDuRT8sCDtW8d8A8qyav-b9e5Kw,6567
|
11
|
+
hackerbot-0.4.0.dist-info/licenses/LICENSE,sha256=SCcXH0bf35ISRu_Ks8xEKySHXiqclANLWhBUbVU8VvA,1081
|
12
|
+
hackerbot-0.4.0.dist-info/METADATA,sha256=aDFIV8XyatIX9BXO9Ck9LDqtsoMSokV0iqNSXcyOfj4,1764
|
13
|
+
hackerbot-0.4.0.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
14
|
+
hackerbot-0.4.0.dist-info/top_level.txt,sha256=2n_FStAr1SiI3BV67x7KJHYIOmEwxjUD59zedw2hLkU,10
|
15
|
+
hackerbot-0.4.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|