'NoneType' object has no attribute 'strip' when connecting device after upgrade to 0.7
Closed this issue · 6 comments
Steps to reproduce:
- upgrade to 0.7
- Invoke Alfred, type "blt studio" (name of the device)
- error below is thrown
Thanks for looking into it!
'NoneType' object has no attribute 'strip'
[09:22:17.343] Logging Started...
[09:22:26.227] Bluetooth Connector[Script Filter] Queuing argument ''
[09:22:26.680] Bluetooth Connector[Script Filter] Script with argv '(null)' finished
[09:22:26.687] STDERR: Bluetooth Connector[Script Filter] .
09:22:26 workflow.py:2055 DEBUG ---------- Bluetooth Connector (0.7.0) ----------
09:22:26 workflow.py:1462 DEBUG reading settings from /Users/lzrnecko/Library/Application Support/Alfred/Workflow Data/de.tilmanginzel.alfred.bluetooth/settings.json
09:22:26 workflow.py:2339 DEBUG update check not due
09:22:26 workflow.py:1689 DEBUG loading cached data: /Users/lzrnecko/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/de.tilmanginzel.alfred.bluetooth/__workflow_update_status.cpickle
09:22:26 workflow.py:2269 DEBUG update_data: {u'available': False, u'version': u'v0.7.0', u'download_url': u'https://github.com/tilmanginzel/alfred-bluetooth-workflow/releases/download/v0.7.0/Bluetooth.Connector.alfredworkflow'}
09:22:26 workflow.py:2248 DEBUG set last run version: 0.7.0
09:22:26 workflow.py:2097 DEBUG ---------- finished in 0.185s ----------
[09:22:26.690] Bluetooth Connector[Script Filter] {"items": [{"subtitle": "Connected", "title": "lzrnecko\u2019s Keyboard", "variables": {"title": "lzrnecko\u2019s Keyboard"}, "valid": true, "arg": "68-fe-f7-50-87-05", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-connected.png"}}, {"subtitle": "Connected", "title": "lzrnecko\u2019s Trackpad", "variables": {"title": "lzrnecko\u2019s Trackpad"}, "valid": true, "arg": "14-c2-13-ef-09-7d", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-connected.png"}}, {"subtitle": "Disconnected", "title": null, "variables": {"title": null}, "valid": true, "arg": "d0-d2-b0-a2-6f-22", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}, {"subtitle": "Disconnected", "title": "Jani\u010d\u010diny Powerbeats\u00b3", "variables": {"title": "Jani\u010d\u010diny Powerbeats\u00b3"}, "valid": true, "arg": "d0-81-7a-08-cb-d3", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}, {"subtitle": "Disconnected", "title": "Lubomir's Trackpad", "variables": {"title": "Lubomir's Trackpad"}, "valid": true, "arg": "c8-bc-c8-fc-a7-38", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}, {"subtitle": "Disconnected", "title": "Lubomir's iPad", "variables": {"title": "Lubomir's iPad"}, "valid": true, "arg": "84-89-ad-1b-91-f4", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}, {"subtitle": "Disconnected", "title": "Lubomir\u2019s Apple\u00a0Watch", "variables": {"title": "Lubomir\u2019s Apple\u00a0Watch"}, "valid": true, "arg": "40-4d-7f-18-36-69", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}, {"subtitle": "Disconnected", "title": "Lubomir\u2019s Keyboard", "variables": {"title": "Lubomir\u2019s Keyboard"}, "valid": true, "arg": "7c-c3-a1-8e-dc-65", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}, {"subtitle": "Disconnected", "title": "Lubomir\u2019s Mouse", "variables": {"title": "Lubomir\u2019s Mouse"}, "valid": true, "arg": "b8-17-c2-9d-8b-b4", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}, {"subtitle": "Disconnected", "title": "Lubomir\u2019s New iPad", "variables": {"title": "Lubomir\u2019s New iPad"}, "valid": true, "arg": "34-42-62-4e-01-05", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}, {"subtitle": "Disconnected", "title": "Lubom\u00edr\u2019s Beats Solo\u00b3", "variables": {"title": "Lubom\u00edr\u2019s Beats Solo\u00b3"}, "valid": true, "arg": "dc-d3-a2-ae-5e-58", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}, {"subtitle": "Disconnected", "title": "Lubom\u00edr\u2019s Beats Studio\u00b3", "variables": {"title": "Lubom\u00edr\u2019s Beats Studio\u00b3"}, "valid": true, "arg": "1c-36-bb-40-01-e6", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}, {"subtitle": "Disconnected", "title": "Luboskuv iPhone 8", "variables": {"title": "Luboskuv iPhone 8"}, "valid": true, "arg": "6c-4d-73-cf-4e-10", "type": "file:skipcheck", "icon": {"path": "./icons/bluetooth-disconnected.png"}}]}
[09:22:29.104] Bluetooth Connector[Script Filter] Queuing argument 's'
[09:22:29.287] Bluetooth Connector[Script Filter] Queuing argument 'st'
[09:22:29.451] Bluetooth Connector[Script Filter] Queuing argument 'stu'
[09:22:29.540] Bluetooth Connector[Script Filter] Queuing argument 'stud'
[09:22:29.663] Bluetooth Connector[Script Filter] Queuing argument 'studi'
[09:22:30.010] Bluetooth Connector[Script Filter] Script with argv '(null)' finished
[09:22:30.029] ERROR: Bluetooth Connector[Script Filter] Code 1: .
09:22:29 workflow.py:2055 DEBUG ---------- Bluetooth Connector (0.7.0) ----------
09:22:29 workflow.py:1462 DEBUG reading settings from /Users/lzrnecko/Library/Application Support/Alfred/Workflow Data/de.tilmanginzel.alfred.bluetooth/settings.json
09:22:29 workflow.py:2339 DEBUG update check not due
09:22:29 workflow.py:1689 DEBUG loading cached data: /Users/lzrnecko/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/de.tilmanginzel.alfred.bluetooth/__workflow_update_status.cpickle
09:22:29 workflow.py:2269 DEBUG update_data: {u'available': False, u'version': u'v0.7.0', u'download_url': u'https://github.com/tilmanginzel/alfred-bluetooth-workflow/releases/download/v0.7.0/Bluetooth.Connector.alfredworkflow'}
09:22:29 workflow.py:2074 ERROR 'NoneType' object has no attribute 'strip'
Traceback (most recent call last):
File "/Users/lzrnecko/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.3E37DB7A-A792-4BD0-B46F-44243DFB0A5B/workflow/workflow.py", line 2067, in run
func(self)
File "alfred_bluetooth_workflow.py", line 41, in main
filtered_devices = wf.filter(query, devices, key=lambda k: k['title'])
File "/Users/lzrnecko/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.3E37DB7A-A792-4BD0-B46F-44243DFB0A5B/workflow/workflow.py", line 1879, in filter
value = key(item).strip()
AttributeError: 'NoneType' object has no attribute 'strip'
09:22:29 workflow.py:2097 DEBUG ---------- finished in 0.134s ----------
[09:22:30.034] Bluetooth Connector[Script Filter] {"items": [{"valid": false, "subtitle": "'NoneType' object has no attribute 'strip'", "icon": {"path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"}, "title": "Error in workflow 'Bluetooth Connector'"}]}
I'm unable to reproduce this unfortunately. It seems that this occurs when devices
contains an item that is None
, though that results in a different, though similar error ('NoneType' object has no attribute '__getitem__'
).
Could you try the following commands, in order to clean up your workflow cache / data dir?
blt workflow:delcache
blt workflow:deldata
blt workflow:delsettings
No worries, there's no preferences persisted, only some caching going on here. If this has no effect for you, could you share the result of blueutil
? You can execute a blueutil
command by doing the following:
- Open the Bluetooth Connector workflow in alfred, right click and open in terminal.
- Run
./blueutil --paired --format JSON | pbcopy
in that directory - Post the results here
The command don't seem to help.
Here you are (I just stripped the MAC addresses)
blueutil --paired --format JSON | jq '(.[] | .address) |= "aa-bb-cc-dd-ee-ff"' | pbcopy
[
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-05-14T15:50:33+02:00",
"favourite": false,
"name": "Lubomir’s Keyboard",
"connected": false,
"paired": true
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-11-12T11:21:32+01:00",
"paired": true,
"RSSI": 0,
"rawRSSI": -59,
"favourite": false,
"connected": true,
"name": "lzrnecko’s Trackpad",
"slave": true
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-11-08T09:43:38+01:00",
"favourite": false,
"name": "Luboskuv iPhone 8",
"connected": false,
"paired": false
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-11-12T11:19:36+01:00",
"paired": true,
"RSSI": 0,
"rawRSSI": -45,
"favourite": false,
"connected": true,
"name": "lzrnecko’s Keyboard",
"slave": false
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-11-08T14:17:00+01:00",
"favourite": false,
"name": "Lubomir’s Mouse",
"connected": false,
"paired": true
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-05-14T15:55:39+02:00",
"favourite": false,
"name": "Lubomir's Trackpad",
"connected": false,
"paired": true
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": null,
"favourite": false,
"name": null,
"connected": false,
"paired": false
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-11-06T13:17:20+01:00",
"favourite": false,
"name": "Lubomír’s Beats Solo³",
"connected": false,
"paired": true
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-11-12T10:37:22+01:00",
"favourite": false,
"name": "Lubomír’s Beats Studio³",
"connected": false,
"paired": true
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-10-22T16:35:31+02:00",
"favourite": false,
"name": "Lubomir's iPad",
"connected": false,
"paired": false
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-11-12T12:39:15+01:00",
"favourite": false,
"name": "Lubomir’s Apple Watch",
"connected": false,
"paired": false
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": "2019-10-26T09:54:05+02:00",
"favourite": false,
"name": "Lubomir’s New iPad",
"connected": false,
"paired": false
},
{
"address": "aa-bb-cc-dd-ee-ff",
"recentAccessDate": null,
"favourite": false,
"name": "Janiččiny Powerbeats³",
"connected": false,
"paired": true
}
]
I'm wondering if the "device" with null name could be the culprit.
Hi @lubosek, thanks for the issue and the output json. It is probably the same or similar issue than this comment. It definitely would make sense to filter devices with a null
name. Can you try this version: Bluetooth Connector.alfredworkflow.zip ?
Works fine now.
Thank you for fixing the bug and for the workflow in general!
If you have a PayPal, I'll buy you a beer!
Great to hear this fixes it @lubosek :) Just published version 0.8.0.
If you have a PayPal, I'll buy you a beer!
That's very kind, but none required. ;)