pylint: enforce indentation (W0311) (#24039)
* pylint: enforce indentation (W0311) * few morepull/24002/merge
parent
1df3c86999
commit
8af20af66d
|
@ -54,7 +54,7 @@ confidence=
|
||||||
# --enable=similarities". If you want to run only the classes checker, but have
|
# --enable=similarities". If you want to run only the classes checker, but have
|
||||||
# no Warning level messages displayed, use"--disable=all --enable=classes
|
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||||
# --disable=W"
|
# --disable=W"
|
||||||
disable=C,R,W0613,W0511,W0212,W0201,W0311,W0106,W0603,W0621,W0703,W1201,W1203,E1136,W1514
|
disable=C,R,W0613,W0511,W0212,W0201,W0106,W0603,W0621,W0703,W1201,W1203,E1136,W1514
|
||||||
|
|
||||||
|
|
||||||
# Enable the message, report, category or checker with the given id(s). You can
|
# Enable the message, report, category or checker with the given id(s). You can
|
||||||
|
|
|
@ -36,8 +36,8 @@ class TestSimpleKalman(unittest.TestCase):
|
||||||
self.assertEqual(self.kf.x, [[1.0], [1.0]])
|
self.assertEqual(self.kf.x, [[1.0], [1.0]])
|
||||||
|
|
||||||
def update_returns_state(self):
|
def update_returns_state(self):
|
||||||
x = self.kf.update(100)
|
x = self.kf.update(100)
|
||||||
self.assertEqual(x, self.kf.x)
|
self.assertEqual(x, self.kf.x)
|
||||||
|
|
||||||
def test_old_equal_new(self):
|
def test_old_equal_new(self):
|
||||||
for _ in range(1000):
|
for _ in range(1000):
|
||||||
|
|
|
@ -172,33 +172,33 @@ class SwagLogger(logging.Logger):
|
||||||
#On some versions of IronPython, currentframe() returns None if
|
#On some versions of IronPython, currentframe() returns None if
|
||||||
#IronPython isn't run with -X:Frames.
|
#IronPython isn't run with -X:Frames.
|
||||||
if f is not None:
|
if f is not None:
|
||||||
f = f.f_back
|
f = f.f_back
|
||||||
orig_f = f
|
orig_f = f
|
||||||
while f and stacklevel > 1:
|
while f and stacklevel > 1:
|
||||||
f = f.f_back
|
f = f.f_back
|
||||||
stacklevel -= 1
|
stacklevel -= 1
|
||||||
if not f:
|
if not f:
|
||||||
f = orig_f
|
f = orig_f
|
||||||
rv = "(unknown file)", 0, "(unknown function)", None
|
rv = "(unknown file)", 0, "(unknown function)", None
|
||||||
while hasattr(f, "f_code"):
|
while hasattr(f, "f_code"):
|
||||||
co = f.f_code
|
co = f.f_code
|
||||||
filename = os.path.normcase(co.co_filename)
|
filename = os.path.normcase(co.co_filename)
|
||||||
|
|
||||||
# TODO: is this pylint exception correct?
|
# TODO: is this pylint exception correct?
|
||||||
if filename == _srcfile: # pylint: disable=comparison-with-callable
|
if filename == _srcfile: # pylint: disable=comparison-with-callable
|
||||||
f = f.f_back
|
f = f.f_back
|
||||||
continue
|
continue
|
||||||
sinfo = None
|
sinfo = None
|
||||||
if stack_info:
|
if stack_info:
|
||||||
sio = io.StringIO()
|
sio = io.StringIO()
|
||||||
sio.write('Stack (most recent call last):\n')
|
sio.write('Stack (most recent call last):\n')
|
||||||
traceback.print_stack(f, file=sio)
|
traceback.print_stack(f, file=sio)
|
||||||
sinfo = sio.getvalue()
|
sinfo = sio.getvalue()
|
||||||
if sinfo[-1] == '\n':
|
if sinfo[-1] == '\n':
|
||||||
sinfo = sinfo[:-1]
|
sinfo = sinfo[:-1]
|
||||||
sio.close()
|
sio.close()
|
||||||
rv = (co.co_filename, f.f_lineno, co.co_name, sinfo)
|
rv = (co.co_filename, f.f_lineno, co.co_name, sinfo)
|
||||||
break
|
break
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -74,4 +74,4 @@ class TestBoarddApiMethods(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -24,9 +24,9 @@ if __name__ == "__main__":
|
||||||
lr = list(LogReader(path))
|
lr = list(LogReader(path))
|
||||||
|
|
||||||
for msg in tqdm(lr):
|
for msg in tqdm(lr):
|
||||||
if msg.which() == 'thumbnail':
|
if msg.which() == 'thumbnail':
|
||||||
with open(os.path.join(out_path, f"{msg.thumbnail.frameId}.jpg"), 'wb') as f:
|
with open(os.path.join(out_path, f"{msg.thumbnail.frameId}.jpg"), 'wb') as f:
|
||||||
f.write(msg.thumbnail.thumbnail)
|
f.write(msg.thumbnail.thumbnail)
|
||||||
elif msg.which() == 'navThumbnail':
|
elif msg.which() == 'navThumbnail':
|
||||||
with open(os.path.join(out_path, f"nav_{msg.navThumbnail.frameId}.jpg"), 'wb') as f:
|
with open(os.path.join(out_path, f"nav_{msg.navThumbnail.frameId}.jpg"), 'wb') as f:
|
||||||
f.write(msg.navThumbnail.thumbnail)
|
f.write(msg.navThumbnail.thumbnail)
|
||||||
|
|
|
@ -404,7 +404,7 @@ class CarInterface(CarInterfaceBase):
|
||||||
# do enable on both accel and decel buttons
|
# do enable on both accel and decel buttons
|
||||||
if not self.CP.pcmCruise:
|
if not self.CP.pcmCruise:
|
||||||
if b.type in (ButtonType.accelCruise, ButtonType.decelCruise) and not b.pressed:
|
if b.type in (ButtonType.accelCruise, ButtonType.decelCruise) and not b.pressed:
|
||||||
events.add(EventName.buttonEnable)
|
events.add(EventName.buttonEnable)
|
||||||
|
|
||||||
# do disable on button down
|
# do disable on button down
|
||||||
if b.type == ButtonType.cancel and b.pressed:
|
if b.type == ButtonType.cancel and b.pressed:
|
||||||
|
|
|
@ -58,14 +58,14 @@ class CarController():
|
||||||
self.last_angle = apply_angle
|
self.last_angle = apply_angle
|
||||||
|
|
||||||
if self.CP.carFingerprint in (CAR.ROGUE, CAR.XTRAIL, CAR.ALTIMA) and cruise_cancel:
|
if self.CP.carFingerprint in (CAR.ROGUE, CAR.XTRAIL, CAR.ALTIMA) and cruise_cancel:
|
||||||
can_sends.append(nissancan.create_acc_cancel_cmd(self.packer, self.car_fingerprint, CS.cruise_throttle_msg, frame))
|
can_sends.append(nissancan.create_acc_cancel_cmd(self.packer, self.car_fingerprint, CS.cruise_throttle_msg, frame))
|
||||||
|
|
||||||
# TODO: Find better way to cancel!
|
# TODO: Find better way to cancel!
|
||||||
# For some reason spamming the cancel button is unreliable on the Leaf
|
# For some reason spamming the cancel button is unreliable on the Leaf
|
||||||
# We now cancel by making propilot think the seatbelt is unlatched,
|
# We now cancel by making propilot think the seatbelt is unlatched,
|
||||||
# this generates a beep and a warning message every time you disengage
|
# this generates a beep and a warning message every time you disengage
|
||||||
if self.CP.carFingerprint in (CAR.LEAF, CAR.LEAF_IC) and frame % 2 == 0:
|
if self.CP.carFingerprint in (CAR.LEAF, CAR.LEAF_IC) and frame % 2 == 0:
|
||||||
can_sends.append(nissancan.create_cancel_msg(self.packer, CS.cancel_msg, cruise_cancel))
|
can_sends.append(nissancan.create_cancel_msg(self.packer, CS.cancel_msg, cruise_cancel))
|
||||||
|
|
||||||
can_sends.append(nissancan.create_steering_control(
|
can_sends.append(nissancan.create_steering_control(
|
||||||
self.packer, apply_angle, frame, c.enabled, self.lkas_max_torque))
|
self.packer, apply_angle, frame, c.enabled, self.lkas_max_torque))
|
||||||
|
|
|
@ -54,7 +54,7 @@ def create_es_lkas(packer, es_lkas_msg, enabled, visual_alert, left_line, right_
|
||||||
values["LKAS_ACTIVE"] = 1 # Show LKAS lane lines
|
values["LKAS_ACTIVE"] = 1 # Show LKAS lane lines
|
||||||
values["LKAS_Dash_State"] = 2 # Green enabled indicator
|
values["LKAS_Dash_State"] = 2 # Green enabled indicator
|
||||||
else:
|
else:
|
||||||
values["LKAS_Dash_State"] = 0 # LKAS Not enabled
|
values["LKAS_Dash_State"] = 0 # LKAS Not enabled
|
||||||
|
|
||||||
values["LKAS_Left_Line_Visible"] = int(left_line)
|
values["LKAS_Left_Line_Visible"] = int(left_line)
|
||||||
values["LKAS_Right_Line_Visible"] = int(right_line)
|
values["LKAS_Right_Line_Visible"] = int(right_line)
|
||||||
|
|
|
@ -37,12 +37,12 @@ def check_fingerprint_consistency(f1, f2):
|
||||||
is_f1_in_f2 = True
|
is_f1_in_f2 = True
|
||||||
for k in f1:
|
for k in f1:
|
||||||
if (k not in f2 or f1[k] != f2[k]) and k < max_msg:
|
if (k not in f2 or f1[k] != f2[k]) and k < max_msg:
|
||||||
is_f1_in_f2 = False
|
is_f1_in_f2 = False
|
||||||
|
|
||||||
is_f2_in_f1 = True
|
is_f2_in_f1 = True
|
||||||
for k in f2:
|
for k in f2:
|
||||||
if (k not in f1 or f2[k] != f1[k]) and k < max_msg:
|
if (k not in f1 or f2[k] != f1[k]) and k < max_msg:
|
||||||
is_f2_in_f1 = False
|
is_f2_in_f1 = False
|
||||||
|
|
||||||
return not is_f1_in_f2 and not is_f2_in_f1
|
return not is_f1_in_f2 and not is_f2_in_f1
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,11 @@ candidate_cars = all_legacy_fingerprint_cars()
|
||||||
|
|
||||||
|
|
||||||
for addr, l in fingerprint.items():
|
for addr, l in fingerprint.items():
|
||||||
dat = messaging.new_message('can', 1)
|
dat = messaging.new_message('can', 1)
|
||||||
|
|
||||||
msg = dat.can[0]
|
msg = dat.can[0]
|
||||||
msg.address = addr
|
msg.address = addr
|
||||||
msg.dat = " " * l
|
msg.dat = " " * l
|
||||||
|
|
||||||
candidate_cars = eliminate_incompatible_cars(msg, candidate_cars)
|
candidate_cars = eliminate_incompatible_cars(msg, candidate_cars)
|
||||||
print(candidate_cars)
|
print(candidate_cars)
|
||||||
|
|
|
@ -24,19 +24,19 @@ MM_MODEM_SIMPLE = MM + ".Modem.Simple"
|
||||||
MM_SIM = MM + ".Sim"
|
MM_SIM = MM + ".Sim"
|
||||||
|
|
||||||
class MM_MODEM_STATE(IntEnum):
|
class MM_MODEM_STATE(IntEnum):
|
||||||
FAILED = -1
|
FAILED = -1
|
||||||
UNKNOWN = 0
|
UNKNOWN = 0
|
||||||
INITIALIZING = 1
|
INITIALIZING = 1
|
||||||
LOCKED = 2
|
LOCKED = 2
|
||||||
DISABLED = 3
|
DISABLED = 3
|
||||||
DISABLING = 4
|
DISABLING = 4
|
||||||
ENABLING = 5
|
ENABLING = 5
|
||||||
ENABLED = 6
|
ENABLED = 6
|
||||||
SEARCHING = 7
|
SEARCHING = 7
|
||||||
REGISTERED = 8
|
REGISTERED = 8
|
||||||
DISCONNECTING = 9
|
DISCONNECTING = 9
|
||||||
CONNECTING = 10
|
CONNECTING = 10
|
||||||
CONNECTED = 11
|
CONNECTED = 11
|
||||||
|
|
||||||
class NMMetered(IntEnum):
|
class NMMetered(IntEnum):
|
||||||
NM_METERED_UNKNOWN = 0
|
NM_METERED_UNKNOWN = 0
|
||||||
|
@ -194,14 +194,14 @@ class Tici(HardwareBase):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def parse_strength(self, percentage):
|
def parse_strength(self, percentage):
|
||||||
if percentage < 25:
|
if percentage < 25:
|
||||||
return NetworkStrength.poor
|
return NetworkStrength.poor
|
||||||
elif percentage < 50:
|
elif percentage < 50:
|
||||||
return NetworkStrength.moderate
|
return NetworkStrength.moderate
|
||||||
elif percentage < 75:
|
elif percentage < 75:
|
||||||
return NetworkStrength.good
|
return NetworkStrength.good
|
||||||
else:
|
else:
|
||||||
return NetworkStrength.great
|
return NetworkStrength.great
|
||||||
|
|
||||||
def get_network_strength(self, network_type):
|
def get_network_strength(self, network_type):
|
||||||
network_strength = NetworkStrength.unknown
|
network_strength = NetworkStrength.unknown
|
||||||
|
|
|
@ -474,14 +474,14 @@ class LocKalman():
|
||||||
z = trans[:, :3]
|
z = trans[:, :3]
|
||||||
R = np.zeros((len(trans), 3, 3))
|
R = np.zeros((len(trans), 3, 3))
|
||||||
for i, _ in enumerate(z):
|
for i, _ in enumerate(z):
|
||||||
R[i, :, :] = np.diag(trans[i, 3:]**2)
|
R[i, :, :] = np.diag(trans[i, 3:]**2)
|
||||||
return self.filter.predict_and_update_batch(t, kind, z, R)
|
return self.filter.predict_and_update_batch(t, kind, z, R)
|
||||||
|
|
||||||
def predict_and_update_odo_rot(self, rot, t, kind):
|
def predict_and_update_odo_rot(self, rot, t, kind):
|
||||||
z = rot[:, :3]
|
z = rot[:, :3]
|
||||||
R = np.zeros((len(rot), 3, 3))
|
R = np.zeros((len(rot), 3, 3))
|
||||||
for i, _ in enumerate(z):
|
for i, _ in enumerate(z):
|
||||||
R[i, :, :] = np.diag(rot[i, 3:]**2)
|
R[i, :, :] = np.diag(rot[i, 3:]**2)
|
||||||
return self.filter.predict_and_update_batch(t, kind, z, R)
|
return self.filter.predict_and_update_batch(t, kind, z, R)
|
||||||
|
|
||||||
def predict_and_update_orb_features(self, tracks, t, kind):
|
def predict_and_update_orb_features(self, tracks, t, kind):
|
||||||
|
@ -518,7 +518,7 @@ class LocKalman():
|
||||||
|
|
||||||
y_full = np.zeros((z.shape[0], z.shape[1] - 3))
|
y_full = np.zeros((z.shape[0], z.shape[1] - 3))
|
||||||
if sum(good_idxs) > 0:
|
if sum(good_idxs) > 0:
|
||||||
y_full[good_idxs] = np.array(ret[6])
|
y_full[good_idxs] = np.array(ret[6])
|
||||||
ret = ret[:6] + (y_full, z, ecef_pos)
|
ret = ret[:6] + (y_full, z, ecef_pos)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -23,4 +23,4 @@ if __name__ == "__main__":
|
||||||
# Fill up to 99 percent
|
# Fill up to 99 percent
|
||||||
available_percent = get_available_percent()
|
available_percent = get_available_percent()
|
||||||
if available_percent < 1.0:
|
if available_percent < 1.0:
|
||||||
break
|
break
|
||||||
|
|
|
@ -8,22 +8,22 @@ import unittest
|
||||||
import selfdrive.loggerd.uploader as uploader
|
import selfdrive.loggerd.uploader as uploader
|
||||||
|
|
||||||
def create_random_file(file_path, size_mb, lock=False):
|
def create_random_file(file_path, size_mb, lock=False):
|
||||||
try:
|
try:
|
||||||
os.mkdir(os.path.dirname(file_path))
|
os.mkdir(os.path.dirname(file_path))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
lock_path = file_path + ".lock"
|
lock_path = file_path + ".lock"
|
||||||
if lock:
|
if lock:
|
||||||
os.close(os.open(lock_path, os.O_CREAT | os.O_EXCL))
|
os.close(os.open(lock_path, os.O_CREAT | os.O_EXCL))
|
||||||
|
|
||||||
chunks = 128
|
chunks = 128
|
||||||
chunk_bytes = int(size_mb * 1024 * 1024 / chunks)
|
chunk_bytes = int(size_mb * 1024 * 1024 / chunks)
|
||||||
data = os.urandom(chunk_bytes)
|
data = os.urandom(chunk_bytes)
|
||||||
|
|
||||||
with open(file_path, 'wb') as f:
|
with open(file_path, 'wb') as f:
|
||||||
for _ in range(chunks):
|
for _ in range(chunks):
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
class MockResponse():
|
class MockResponse():
|
||||||
def __init__(self, text, status_code):
|
def __init__(self, text, status_code):
|
||||||
|
|
|
@ -199,7 +199,7 @@ class NativeProcess(ManagerProcess):
|
||||||
def start(self) -> None:
|
def start(self) -> None:
|
||||||
# In case we only tried a non blocking stop we need to stop it before restarting
|
# In case we only tried a non blocking stop we need to stop it before restarting
|
||||||
if self.shutting_down:
|
if self.shutting_down:
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
if self.proc is not None:
|
if self.proc is not None:
|
||||||
return
|
return
|
||||||
|
@ -231,7 +231,7 @@ class PythonProcess(ManagerProcess):
|
||||||
def start(self) -> None:
|
def start(self) -> None:
|
||||||
# In case we only tried a non blocking stop we need to stop it before restarting
|
# In case we only tried a non blocking stop we need to stop it before restarting
|
||||||
if self.shutting_down:
|
if self.shutting_down:
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
if self.proc is not None:
|
if self.proc is not None:
|
||||||
return
|
return
|
||||||
|
|
|
@ -136,21 +136,21 @@ class TestMonitoring(unittest.TestCase):
|
||||||
# engaged, invisible driver, down to orange, driver touches wheel; then down to orange again, driver appears
|
# engaged, invisible driver, down to orange, driver touches wheel; then down to orange again, driver appears
|
||||||
# - both actions should clear the alert, but momentary appearance should not
|
# - both actions should clear the alert, but momentary appearance should not
|
||||||
def test_sometimes_transparent_commuter(self):
|
def test_sometimes_transparent_commuter(self):
|
||||||
_visible_time = np.random.choice([0.5, 10])
|
_visible_time = np.random.choice([0.5, 10])
|
||||||
ds_vector = always_no_face[:]*2
|
ds_vector = always_no_face[:]*2
|
||||||
interaction_vector = always_false[:]*2
|
interaction_vector = always_false[:]*2
|
||||||
ds_vector[int((2*INVISIBLE_SECONDS_TO_ORANGE+1)/DT_DMON):int((2*INVISIBLE_SECONDS_TO_ORANGE+1+_visible_time)/DT_DMON)] = [msg_ATTENTIVE] * int(_visible_time/DT_DMON)
|
ds_vector[int((2*INVISIBLE_SECONDS_TO_ORANGE+1)/DT_DMON):int((2*INVISIBLE_SECONDS_TO_ORANGE+1+_visible_time)/DT_DMON)] = [msg_ATTENTIVE] * int(_visible_time/DT_DMON)
|
||||||
interaction_vector[int((INVISIBLE_SECONDS_TO_ORANGE)/DT_DMON):int((INVISIBLE_SECONDS_TO_ORANGE+1)/DT_DMON)] = [True] * int(1/DT_DMON)
|
interaction_vector[int((INVISIBLE_SECONDS_TO_ORANGE)/DT_DMON):int((INVISIBLE_SECONDS_TO_ORANGE+1)/DT_DMON)] = [True] * int(1/DT_DMON)
|
||||||
events, _ = self._run_seq(ds_vector, interaction_vector, 2*always_true, 2*always_false)
|
events, _ = self._run_seq(ds_vector, interaction_vector, 2*always_true, 2*always_false)
|
||||||
self.assertTrue(len(events[int(INVISIBLE_SECONDS_TO_ORANGE*0.5/DT_DMON)]) == 0)
|
self.assertTrue(len(events[int(INVISIBLE_SECONDS_TO_ORANGE*0.5/DT_DMON)]) == 0)
|
||||||
self.assertEqual(events[int((INVISIBLE_SECONDS_TO_ORANGE-0.1)/DT_DMON)].names[0], EventName.promptDriverUnresponsive)
|
self.assertEqual(events[int((INVISIBLE_SECONDS_TO_ORANGE-0.1)/DT_DMON)].names[0], EventName.promptDriverUnresponsive)
|
||||||
self.assertTrue(len(events[int((INVISIBLE_SECONDS_TO_ORANGE+0.1)/DT_DMON)]) == 0)
|
self.assertTrue(len(events[int((INVISIBLE_SECONDS_TO_ORANGE+0.1)/DT_DMON)]) == 0)
|
||||||
if _visible_time == 0.5:
|
if _visible_time == 0.5:
|
||||||
self.assertEqual(events[int((INVISIBLE_SECONDS_TO_ORANGE*2+1-0.1)/DT_DMON)].names[0], EventName.promptDriverUnresponsive)
|
self.assertEqual(events[int((INVISIBLE_SECONDS_TO_ORANGE*2+1-0.1)/DT_DMON)].names[0], EventName.promptDriverUnresponsive)
|
||||||
self.assertEqual(events[int((INVISIBLE_SECONDS_TO_ORANGE*2+1+0.1+_visible_time)/DT_DMON)].names[0], EventName.preDriverUnresponsive)
|
self.assertEqual(events[int((INVISIBLE_SECONDS_TO_ORANGE*2+1+0.1+_visible_time)/DT_DMON)].names[0], EventName.preDriverUnresponsive)
|
||||||
elif _visible_time == 10:
|
elif _visible_time == 10:
|
||||||
self.assertEqual(events[int((INVISIBLE_SECONDS_TO_ORANGE*2+1-0.1)/DT_DMON)].names[0], EventName.promptDriverUnresponsive)
|
self.assertEqual(events[int((INVISIBLE_SECONDS_TO_ORANGE*2+1-0.1)/DT_DMON)].names[0], EventName.promptDriverUnresponsive)
|
||||||
self.assertTrue(len(events[int((INVISIBLE_SECONDS_TO_ORANGE*2+1+0.1+_visible_time)/DT_DMON)]) == 0)
|
self.assertTrue(len(events[int((INVISIBLE_SECONDS_TO_ORANGE*2+1+0.1+_visible_time)/DT_DMON)]) == 0)
|
||||||
|
|
||||||
# engaged, invisible driver, down to red, driver appears and then touches wheel, then disengages/reengages
|
# engaged, invisible driver, down to red, driver appears and then touches wheel, then disengages/reengages
|
||||||
# - only disengage will clear the alert
|
# - only disengage will clear the alert
|
||||||
|
|
|
@ -25,7 +25,7 @@ def save_log(dest, log_msgs, compress=True):
|
||||||
dat = bz2.compress(dat)
|
dat = bz2.compress(dat)
|
||||||
|
|
||||||
with open(dest, "wb") as f:
|
with open(dest, "wb") as f:
|
||||||
f.write(dat)
|
f.write(dat)
|
||||||
|
|
||||||
|
|
||||||
def remove_ignored_fields(msg, ignore):
|
def remove_ignored_fields(msg, ignore):
|
||||||
|
|
|
@ -231,7 +231,7 @@ def ublox_rcv_callback(msg):
|
||||||
elif (msg_class, msg_id) in {(2, 1 * 16 + 5), (10, 9)}:
|
elif (msg_class, msg_id) in {(2, 1 * 16 + 5), (10, 9)}:
|
||||||
return ["ubloxGnss"]
|
return ["ubloxGnss"]
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
CONFIGS = [
|
CONFIGS = [
|
||||||
|
|
|
@ -61,10 +61,10 @@ def replay_manager_state(s, msgs):
|
||||||
rk = Ratekeeper(service_list[s].frequency, print_delay_threshold=None)
|
rk = Ratekeeper(service_list[s].frequency, print_delay_threshold=None)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
new_m = messaging.new_message('managerState')
|
new_m = messaging.new_message('managerState')
|
||||||
new_m.managerState.processes = [{'name': name, 'running': True} for name in managed_processes]
|
new_m.managerState.processes = [{'name': name, 'running': True} for name in managed_processes]
|
||||||
pm.send(s, new_m)
|
pm.send(s, new_m)
|
||||||
rk.keep_time()
|
rk.keep_time()
|
||||||
|
|
||||||
|
|
||||||
def replay_device_state(s, msgs):
|
def replay_device_state(s, msgs):
|
||||||
|
|
|
@ -153,9 +153,9 @@ def report_tombstone_apport(fn):
|
||||||
# Try to find first entry in openpilot, fall back to first line
|
# Try to find first entry in openpilot, fall back to first line
|
||||||
for line in stacktrace_s:
|
for line in stacktrace_s:
|
||||||
if "at selfdrive/" in line:
|
if "at selfdrive/" in line:
|
||||||
crash_function = line
|
crash_function = line
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
crash_function = stacktrace_s[1]
|
crash_function = stacktrace_s[1]
|
||||||
|
|
|
@ -86,13 +86,13 @@ def auth_redirect_link(method):
|
||||||
})
|
})
|
||||||
return 'https://github.com/login/oauth/authorize?' + urlencode(params)
|
return 'https://github.com/login/oauth/authorize?' + urlencode(params)
|
||||||
elif method == 'apple':
|
elif method == 'apple':
|
||||||
params.update({
|
params.update({
|
||||||
'client_id': 'ai.comma.login',
|
'client_id': 'ai.comma.login',
|
||||||
'response_type': 'code',
|
'response_type': 'code',
|
||||||
'response_mode': 'form_post',
|
'response_mode': 'form_post',
|
||||||
'scope': 'name email',
|
'scope': 'name email',
|
||||||
})
|
})
|
||||||
return 'https://appleid.apple.com/auth/authorize?' + urlencode(params)
|
return 'https://appleid.apple.com/auth/authorize?' + urlencode(params)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f"no redirect implemented for method {method}")
|
raise NotImplementedError(f"no redirect implemented for method {method}")
|
||||||
|
|
||||||
|
|
|
@ -66,4 +66,4 @@ class TestFileDownload(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -9,8 +9,8 @@ from typing import NoReturn
|
||||||
# Iterate over the joystick devices.
|
# Iterate over the joystick devices.
|
||||||
print('Available devices:')
|
print('Available devices:')
|
||||||
for fn in os.listdir('/dev/input'):
|
for fn in os.listdir('/dev/input'):
|
||||||
if fn.startswith('js'):
|
if fn.startswith('js'):
|
||||||
print(f' /dev/input/{fn}')
|
print(f' /dev/input/{fn}')
|
||||||
|
|
||||||
# We'll store the states here.
|
# We'll store the states here.
|
||||||
axis_states = {}
|
axis_states = {}
|
||||||
|
@ -18,74 +18,74 @@ button_states = {}
|
||||||
|
|
||||||
# These constants were borrowed from linux/input.h
|
# These constants were borrowed from linux/input.h
|
||||||
axis_names = {
|
axis_names = {
|
||||||
0x00 : 'x',
|
0x00 : 'x',
|
||||||
0x01 : 'y',
|
0x01 : 'y',
|
||||||
0x02 : 'z',
|
0x02 : 'z',
|
||||||
0x03 : 'rx',
|
0x03 : 'rx',
|
||||||
0x04 : 'ry',
|
0x04 : 'ry',
|
||||||
0x05 : 'rz',
|
0x05 : 'rz',
|
||||||
0x06 : 'trottle',
|
0x06 : 'trottle',
|
||||||
0x07 : 'rudder',
|
0x07 : 'rudder',
|
||||||
0x08 : 'wheel',
|
0x08 : 'wheel',
|
||||||
0x09 : 'gas',
|
0x09 : 'gas',
|
||||||
0x0a : 'brake',
|
0x0a : 'brake',
|
||||||
0x10 : 'hat0x',
|
0x10 : 'hat0x',
|
||||||
0x11 : 'hat0y',
|
0x11 : 'hat0y',
|
||||||
0x12 : 'hat1x',
|
0x12 : 'hat1x',
|
||||||
0x13 : 'hat1y',
|
0x13 : 'hat1y',
|
||||||
0x14 : 'hat2x',
|
0x14 : 'hat2x',
|
||||||
0x15 : 'hat2y',
|
0x15 : 'hat2y',
|
||||||
0x16 : 'hat3x',
|
0x16 : 'hat3x',
|
||||||
0x17 : 'hat3y',
|
0x17 : 'hat3y',
|
||||||
0x18 : 'pressure',
|
0x18 : 'pressure',
|
||||||
0x19 : 'distance',
|
0x19 : 'distance',
|
||||||
0x1a : 'tilt_x',
|
0x1a : 'tilt_x',
|
||||||
0x1b : 'tilt_y',
|
0x1b : 'tilt_y',
|
||||||
0x1c : 'tool_width',
|
0x1c : 'tool_width',
|
||||||
0x20 : 'volume',
|
0x20 : 'volume',
|
||||||
0x28 : 'misc',
|
0x28 : 'misc',
|
||||||
}
|
}
|
||||||
|
|
||||||
button_names = {
|
button_names = {
|
||||||
0x120 : 'trigger',
|
0x120 : 'trigger',
|
||||||
0x121 : 'thumb',
|
0x121 : 'thumb',
|
||||||
0x122 : 'thumb2',
|
0x122 : 'thumb2',
|
||||||
0x123 : 'top',
|
0x123 : 'top',
|
||||||
0x124 : 'top2',
|
0x124 : 'top2',
|
||||||
0x125 : 'pinkie',
|
0x125 : 'pinkie',
|
||||||
0x126 : 'base',
|
0x126 : 'base',
|
||||||
0x127 : 'base2',
|
0x127 : 'base2',
|
||||||
0x128 : 'base3',
|
0x128 : 'base3',
|
||||||
0x129 : 'base4',
|
0x129 : 'base4',
|
||||||
0x12a : 'base5',
|
0x12a : 'base5',
|
||||||
0x12b : 'base6',
|
0x12b : 'base6',
|
||||||
0x12f : 'dead',
|
0x12f : 'dead',
|
||||||
0x130 : 'a',
|
0x130 : 'a',
|
||||||
0x131 : 'b',
|
0x131 : 'b',
|
||||||
0x132 : 'c',
|
0x132 : 'c',
|
||||||
0x133 : 'x',
|
0x133 : 'x',
|
||||||
0x134 : 'y',
|
0x134 : 'y',
|
||||||
0x135 : 'z',
|
0x135 : 'z',
|
||||||
0x136 : 'tl',
|
0x136 : 'tl',
|
||||||
0x137 : 'tr',
|
0x137 : 'tr',
|
||||||
0x138 : 'tl2',
|
0x138 : 'tl2',
|
||||||
0x139 : 'tr2',
|
0x139 : 'tr2',
|
||||||
0x13a : 'select',
|
0x13a : 'select',
|
||||||
0x13b : 'start',
|
0x13b : 'start',
|
||||||
0x13c : 'mode',
|
0x13c : 'mode',
|
||||||
0x13d : 'thumbl',
|
0x13d : 'thumbl',
|
||||||
0x13e : 'thumbr',
|
0x13e : 'thumbr',
|
||||||
|
|
||||||
0x220 : 'dpad_up',
|
0x220 : 'dpad_up',
|
||||||
0x221 : 'dpad_down',
|
0x221 : 'dpad_down',
|
||||||
0x222 : 'dpad_left',
|
0x222 : 'dpad_left',
|
||||||
0x223 : 'dpad_right',
|
0x223 : 'dpad_right',
|
||||||
|
|
||||||
# XBox 360 controller uses these codes.
|
# XBox 360 controller uses these codes.
|
||||||
0x2c0 : 'dpad_left',
|
0x2c0 : 'dpad_left',
|
||||||
0x2c1 : 'dpad_right',
|
0x2c1 : 'dpad_right',
|
||||||
0x2c2 : 'dpad_up',
|
0x2c2 : 'dpad_up',
|
||||||
0x2c3 : 'dpad_down',
|
0x2c3 : 'dpad_down',
|
||||||
}
|
}
|
||||||
|
|
||||||
axis_map = []
|
axis_map = []
|
||||||
|
@ -118,18 +118,18 @@ def wheel_poll_thread(q: 'Queue[str]') -> NoReturn:
|
||||||
ioctl(jsdev, 0x80406a32, buf) # JSIOCGAXMAP
|
ioctl(jsdev, 0x80406a32, buf) # JSIOCGAXMAP
|
||||||
|
|
||||||
for _axis in buf[:num_axes]:
|
for _axis in buf[:num_axes]:
|
||||||
axis_name = axis_names.get(_axis, f'unknown(0x{_axis:02x})')
|
axis_name = axis_names.get(_axis, f'unknown(0x{_axis:02x})')
|
||||||
axis_map.append(axis_name)
|
axis_map.append(axis_name)
|
||||||
axis_states[axis_name] = 0.0
|
axis_states[axis_name] = 0.0
|
||||||
|
|
||||||
# Get the button map.
|
# Get the button map.
|
||||||
buf = array.array('H', [0] * 200)
|
buf = array.array('H', [0] * 200)
|
||||||
ioctl(jsdev, 0x80406a34, buf) # JSIOCGBTNMAP
|
ioctl(jsdev, 0x80406a34, buf) # JSIOCGBTNMAP
|
||||||
|
|
||||||
for btn in buf[:num_buttons]:
|
for btn in buf[:num_buttons]:
|
||||||
btn_name = button_names.get(btn, f'unknown(0x{btn:03x})')
|
btn_name = button_names.get(btn, f'unknown(0x{btn:03x})')
|
||||||
button_map.append(btn_name)
|
button_map.append(btn_name)
|
||||||
button_states[btn_name] = 0
|
button_states[btn_name] = 0
|
||||||
|
|
||||||
print('%d axes found: %s' % (num_axes, ', '.join(axis_map)))
|
print('%d axes found: %s' % (num_axes, ', '.join(axis_map)))
|
||||||
print('%d buttons found: %s' % (num_buttons, ', '.join(button_map)))
|
print('%d buttons found: %s' % (num_buttons, ', '.join(button_map)))
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
@ -7,11 +6,11 @@ from socket import gethostbyname, gaierror
|
||||||
from tools.zookeeper import Zookeeper
|
from tools.zookeeper import Zookeeper
|
||||||
|
|
||||||
def is_online(ip):
|
def is_online(ip):
|
||||||
try:
|
try:
|
||||||
addr = gethostbyname(ip)
|
addr = gethostbyname(ip)
|
||||||
return (os.system(f"ping -c 1 {addr} > /dev/null") == 0)
|
return (os.system(f"ping -c 1 {addr} > /dev/null") == 0)
|
||||||
except gaierror:
|
except gaierror:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
z = Zookeeper()
|
z = Zookeeper()
|
||||||
|
|
Loading…
Reference in New Issue