Skip to content

Commit

Permalink
Use shared path for testing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dhinakg committed Feb 20, 2022
1 parent 5b10c9c commit af348dd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Scripts/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ def debug(str):
if False:
input(f"DEBUG: {str}\nPress enter to continue")

test_mode = False
test_mode = True
if test_mode:
debug_dump_path = Path(input("Debug dump path: ").strip().replace("'", "").replace('"', ""))
else:
debug_dump_path = None

# def speed_to_name(speed: USBDeviceSpeeds):
# return _usb_protocol_names[speed]
2 changes: 1 addition & 1 deletion Scripts/usbdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def get_controllers():
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
usbdump_path = Path(sys._MEIPASS) / usbdump_path

info = json.load(Path(input("WMI json path: ")).open())["usbdump"] if shared.test_mode else json.loads(subprocess.run(usbdump_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.decode())
info = json.load(shared.debug_dump_path.open())["usbdump"] if shared.test_mode else json.loads(subprocess.run(usbdump_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.decode())
for controller in info:
if not controller["RootHub"]:
# This is useless
Expand Down
3 changes: 1 addition & 2 deletions Windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def __init__(self):
self.usbdump = None
if shared.test_mode:
self.wmi = {}
self.wmi_path = Path(input("WMI json path: "))
self.wmi_cache: dict = {p["DEVPKEY_Device_InstanceId"]: p for p in json.load(self.wmi_path.open())["wmitest"] if "duration" not in p}
self.wmi_cache: dict = {p["DEVPKEY_Device_InstanceId"]: p for p in json.load(shared.debug_dump_path.open())["wmitest"] if "duration" not in p}
else:
self.wmi = wmi.WMI()
self.wmi_cache = {}
Expand Down

0 comments on commit af348dd

Please sign in to comment.