Commit b5a333d5 authored by Dhinak G's avatar Dhinak G
Browse files

Fix exception traceback printing wrong thing

Fix crash in `guess_ports()` when companion has errored
Add some more specific port errored prints
debug_dump now saves to file (& prompts for location)
parent ce7514ba
Showing with 23 additions and 7 deletions
+23 -7
......@@ -110,7 +110,7 @@ def guess_ports():
if not port["status"].endswith("DeviceConnected"):
# we don't have info. anything else is going to error
port["guessed"] = None
elif port["type_c"] or port["companion_info"]["port"] and get_companion_port(port)["type_c"]:
elif port["type_c"] or port["companion_info"]["port"] and get_companion_port(port).get("type_c", None):
port["guessed"] = shared.USBPhysicalPortTypes.USB3TypeC_WithSwitch
elif not port["user_connectable"]:
port["guessed"] = shared.USBPhysicalPortTypes.Internal
......@@ -157,9 +157,13 @@ def serialize_hub(hub):
}
port_info["name"] = f"Port {port_info['index']}"
friendly_error = {
"DeviceCausedOvercurrent": "Device connected to port pulled too much current."
}
if not port_info["status"].endswith("DeviceConnected"):
# shared.debug(f"Device connected to port {port_info['index']} errored. Please unplug or connect a different device.")
port_info["devices"] = [{"error": True}]
port_info["devices"] = [{"error": friendly_error.get(port_info["status"], True)}]
hub_info["ports"].append(port_info)
continue
......
......@@ -111,7 +111,7 @@ class WindowsUSBMap(BaseUSBMap):
self.update_usbdump()
break
except Exception as e:
if i == 10:
if i == 9:
raise
else:
shared.debug(e)
......
......@@ -14,7 +14,7 @@ from termcolor2 import c as color
from Scripts import shared, utils
CURRENT_VERSION = "0.0.7"
CURRENT_VERSION = "0.0.8"
class Colors(Enum):
......@@ -207,7 +207,7 @@ class BaseUSBMap:
if isinstance(device, str):
print(f"{indentation}- {device}")
elif device.get("error", False):
print(f"{indentation}- Device connected to port errored. Please unplug or connect a different device.")
print(f"{indentation}- {device['error'] if isinstance(device['error'], str) else 'Device connected to port errored.'} Please unplug or connect a different device.")
else:
print(f"{indentation}- {device['name'].strip()} - operating at {shared.USBDeviceSpeeds(device['speed'])}")
for i in device["devices"]:
......
......@@ -4,7 +4,8 @@ import sys
import time
from enum import Enum
from pathlib import Path
import tkinter as tk
import tkinter.filedialog as filedialog
import win32com.client
import wmi
......@@ -77,4 +78,15 @@ if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
usbdump = json.loads(subprocess.run(usbdump_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.decode())
print(json.dumps({"wmitest": controllers, "usbdump": usbdump}, sort_keys=True))
temp_tk_root = tk.Tk()
temp_tk_root.wm_withdraw()
save_path = filedialog.asksaveasfilename(title="Save debugging information", defaultextension=".json", filetypes=[("json", "*.json")])
temp_tk_root.destroy()
if not save_path:
sys.exit(1)
else:
save_path = Path(save_path)
json.dump({"wmitest": controllers, "usbdump": usbdump}, save_path.open("w"), sort_keys=True)
input(f"Please upload {save_path}.\nPress [Enter] to exit")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment