Jump to content

Making Python 2 Workflows work on macOS Monterey 12.3 and above


Recommended Posts

  • 3 weeks later...

Hey@giovanniI see you're using this fork of the Alfred-Workflow library in the workflows you ported to Python 3. There's an issue in this fork regarding the default_settings parameter of the Workflow class which doesn’t seem to work. You get a KeyError by running this code:

from workflow import Workflow

wf = Workflow(default_settings={"arg1": "value1"})
print(wf.settings["arg1"])

 

Have you ever faced this issue or have any idea on how to fix it? I have my own fork of deanishe's library which is being used by some people and I'm interested to fix this issue.

Edited by xilopaint
Link to comment
On 1/15/2023 at 2:12 PM, xilopaint said:

Hey@giovanniI see you're using this fork of the Alfred-Workflow library in the workflows you ported to Python 3. There's an issue in this fork regarding the default_settings parameter of the Workflow class which doesn’t seem to work. You get a KeyError by running this code:

from workflow import Workflow

wf = Workflow(default_settings={"arg1": "value1"})
print(wf.settings["arg1"])

 

Have you ever faced this issue or have any idea on how to fix it? I have my own fork of deanishe's library which is being used by some people and I'm interested to fix this issue.

 

@vitordo you have Python 2 installed? If so, could you check if this code works with deanishe's library?

Link to comment
  • 5 months later...
  • 10 months later...

Hi. I'm trying to use the Suffix Web Search workflow (https://www.deanishe.net/post/2019/05/workflow-suffix-web-search/) created by @deanishe (

 

I installed Python 2 via Homebrew and then updated the file

/Users/xyzen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.D8443119-4F0D-430B-9418-D5CED411E758/websearch.py

by changing

#!/usr/bin/python

to

#!/opt/homebrew/bin/python

 

Now when running the workflow, the pre-existing custom searches work. But when I try to add a new custom search, I get the following error:

___init___() takes at least 7 arguments (6 given)

ss2024-08-2012_37.25-1.thumb.png.d0455ae1056abdf01ab324f118611d25.png

 

The Alfred workflow debugger outputs:

[12:53:13.722] Suffix Web Search[Script Filter] Queuing argument 't'
[12:53:13.859] Suffix Web Search[Script Filter] Script with argv 't' finished
[12:53:13.864] ERROR: Suffix Web Search[Script Filter] Code 1: .
query=u't'
loading searches from '/Users/xyzen/Library/Application Support/Alfred/Alfred.alfredpreferences/preferences/features/websearch/prefs.plist' ...
Traceback (most recent call last):
  File "/Users/xyzen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.D8443119-4F0D-430B-9418-D5CED411E758/websearch.py", line 176, in <module>
    sys.exit(main())
  File "/Users/xyzen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.D8443119-4F0D-430B-9418-D5CED411E758/websearch.py", line 162, in main
    query, searches = parse_query(query)
  File "/Users/xyzen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.D8443119-4F0D-430B-9418-D5CED411E758/websearch.py", line 140, in parse_query
    searches = load_searches(config_path())
  File "/Users/xyzen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.D8443119-4F0D-430B-9418-D5CED411E758/websearch.py", line 133, in load_searches
    searches.append(Search(**d))
TypeError: __init__() takes at least 7 arguments (6 given)
Traceback (most recent call last):
  File "/Users/xyzen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.D8443119-4F0D-430B-9418-D5CED411E758/websearch.py", line 181, in <module>
    raise err
TypeError: __init__() takes at least 7 arguments (6 given)
[12:53:13.866] Suffix Web Search[Script Filter] {
  "items": [
    {
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }, 
      "title": "__init__() takes at least 7 arguments (6 given)", 
      "valid": false
    }
  ]
}

 

Also, the default searches included with Alfred are not listed when invoking the workflow for some reason. I do have them enabled in Alfred preferences. I could easily get around this by creating my own custom searches in place of the default entries, if only I could resolve the aforementioned init error.

 

I'm running macOS Sonoma 14.5 (23F79) and Alfred 5.5 [2257]. I appreciate any help with this.

Edited by xyzen
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...