tilmanginzel / alfred-bluetooth-workflow

Yet another Alfred workflow to connect / disconnect Bluetooth devices
MIT License
189 stars 8 forks source link

Workflow updater breaks blt command #39

Closed trietsch closed 7 months ago

trietsch commented 7 months ago

Hey @tilmanginzel, I'm trying to use the blt command, however, recently I'm running into this issue:

[11:01:19.040] Bluetooth Connector[Script Filter] Queuing argument ''
[11:01:19.244] Bluetooth Connector[Script Filter] Queuing argument 'm'
[11:01:19.401] Bluetooth Connector[Script Filter] Queuing argument 'md'
[11:01:19.559] Bluetooth Connector[Script Filter] Queuing argument 'mdr'
[11:01:19.766] Bluetooth Connector[Script Filter] Script with argv '(null)' finished
[11:01:19.772] ERROR: Bluetooth Connector[Script Filter] Code 1: .
11:01:19 workflow.py:2093 DEBUG    ---------- Bluetooth Connector (0.12.0) ----------
11:01:19 workflow.py:1483 DEBUG    reading settings from /Users/trietsch/Library/Application Support/Alfred/Workflow Data/de.tilmanginzel.alfred.bluetooth/settings.json
11:01:19 workflow.py:2394 INFO     checking for update ...
11:01:19 background.py:233 DEBUG    [__workflow_update_check] command cached: /Users/trietsch/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/de.tilmanginzel.alfred.bluetooth/__workflow_update_check.argcache
11:01:19 background.py:237 DEBUG    [__workflow_update_check] passing job to background runner: ['/Users/trietsch/.pyenv/versions/3.9.4/bin/python3', '-m', 'workflow.background', '__workflow_update_check']
.
11:01:19 workflow.py:2093 DEBUG    ---------- Bluetooth Connector (0.12.0) ----------
11:01:19 background.py:243 DEBUG    [__workflow_update_check] background job started
11:01:19 workflow.py:2114 ERROR    Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/Users/trietsch/dotfiles/preferences/alfred/Alfred.alfredpreferences/workflows/user.workflow.44A872A8-C281-4E69-A44C-73500E105A2B/workflow/workflow.py", line 2107, in run
    func(self)
  File "/Users/trietsch/dotfiles/preferences/alfred/Alfred.alfredpreferences/workflows/user.workflow.44A872A8-C281-4E69-A44C-73500E105A2B/alfred_bluetooth_workflow.py", line 40, in main
    devices = _read_devices()
  File "/Users/trietsch/dotfiles/preferences/alfred/Alfred.alfredpreferences/workflows/user.workflow.44A872A8-C281-4E69-A44C-73500E105A2B/alfred_bluetooth_workflow.py", line 14, in _read_devices
    devices_raw = json.loads(proc.stdout.read())
  File "/Users/trietsch/.pyenv/versions/3.9.4/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/Users/trietsch/.pyenv/versions/3.9.4/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/trietsch/.pyenv/versions/3.9.4/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
11:01:19 workflow.py:2136 DEBUG    ---------- finished in 0.106s ----------
[11:01:19.774] Bluetooth Connector[Script Filter] {
  "items": [
    {
      "title": "Error in workflow 'Bluetooth Connector'",
      "subtitle": "Expecting value: line 1 column 1 (char 0)",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}

To make it even weirder, running the Python script manually with the same Python distribution works properly:

/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/bin/python3 alfred_bluetooth_workflow.py "md"
.
11:11:41 workflow.py:2394 INFO     checking for update ...
.
{"items": [{"title": "MDR-1000X", "subtitle": "Connected", "valid": true, "arg": "10-4f-a8-d8-06-ed", "type": "file:skipcheck", "variables": {"title": "MDR-1000X"}, "icon": {"path": "./icons/bluetooth-connected.png"}}]}

Any idea?

trietsch commented 7 months ago

Ok, managed to fix it with this comment. Thanks, closing!