Jump to content

Recommended Posts

  • 3 months later...
8 hours ago, Hattrick said:

Can I suggest moving workflow settings from alfred_workflow_data to alfred_preferences instead?

 

It can't really be done for implementation reasons (the library stores machine-specific data in the settings file). It would also break the API, which is a no-go. Finally, it's not clear that syncing the data are better than not syncing them. In some cases, sure. But not in all.

 

It's likely that I'll add a separate API for writing to a folder within the prefs bundle at some point in the future.

Link to comment
  • 1 month later...

V2 will be a Python 3-only rewrite. The question is when I'll get round to writing it. Motivation is currently zero.

 

I'm one of the many people who looked at the catastrophic Py2 to Py3 transition and moved to Go instead. I still use Python, but rarely for workflows: Go is just so much better-suited to Alfred workflows (and a lot of other stuff I would have normally used Py2 for).

 

I also don't have Catalina (the only version of macOS with Python 3), and don't see myself installing it any time soon. I'm planning to buy a new Mac, but when I do, I'll be installing Mavericks on it.

 

I will try to do it sometime this year, but that's literally my time horizon: "sometime this year". And I make no promises on that. Py3 is, in my eyes, largely stupid.

Edited by deanishe
Link to comment
  • 1 month later...

@deanishe I need something like `Wofklow3.cache_data()` and `Workflow3.cached_data()` in a Python 3 workflow. Would it be easy to adapt alfred-workflow to work with Python 3 for those methods or you recommend me to simply write and read the cache files using Python 3?

Edited by xilopaint
Link to comment
32 minutes ago, xilopaint said:

Would be easy to adapt alfred-workflow to work with Python 3 for those methods


Don’t know, tbh. The library is Unicode-only, so there’s a lot of encoding/deciding code that’d need removing or rewriting.

 

If I were you, I’d probably just reimplement those bits. They’re not very complicated, but the current implementation is quite heavily tied to the rest of the API.

Link to comment
16 minutes ago, deanishe said:


Don’t know, tbh. The library is Unicode-only, so there’s a lot of encoding/deciding code that’d need removing or rewriting.

 

If I were you, I’d probably just reimplement those bits. They’re not very complicated, but the current implementation is quite heavily tied to the rest of the API.

 

Well, at the moment I'm getting `ModuleNotFoundError: No module named 'util'`. I should be missing something very basic. I have no clue why I'm getting this error.

Link to comment

Hey @deanishe, after fixing a lot of issues in the attempt of adapting the library for Python 3 I came across this:

 

10:01:18 workflow.py:2061 DEBUG    ---------- Alfred PDF Tools (2.16.0) ----------
10:01:18 workflow.py:1468 DEBUG    reading settings from /Users/xxxx/Library/Application Support/Alfred/Workflow Data/com.xilopaint.alfredapp.pdftools/settings.json
10:01:18 workflow.py:2338 INFO     checking for update ...
10:01:18 background.py:233 DEBUG    [__workflow_update_check] command cached: /Users/xxxx/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.xilopaint.alfredapp.pdftools/__workflow_update_check.argcache
10:01:18 background.py:237 DEBUG    [__workflow_update_check] passing job to background runner: ['/usr/bin/python', '/Users/xxxx/Developer/Alfred Workflows/Alfred PDF Tools/alfred-pdf-tools/src/workflow/background.py', '__workflow_update_check']
Traceback (most recent call last):
  File "/Users/xxxx/Developer/Alfred Workflows/Alfred PDF Tools/alfred-pdf-tools/src/workflow/background.py", line 28, in <module>
    from .workflow import Workflow
ValueError: Attempted relative import in non-package
10:01:18 background.py:241 ERROR    [__workflow_update_check] background runner failed with 1
10:01:18 workflow.py:2103 DEBUG    ---------- finished in 0.071s ----------

 

As you can see I changed `from workflow import Workflow` in background.py to `from .workflow import Workflow` but it doesn't work. What's the problem?

Link to comment
2 hours ago, deanishe said:

The background API also runs background.py as a script, which is why you're getting the error. Have you tried not changing the import path?

 

If I keep `from workflow import Workflow` in background.py I get this:

21:25:53 workflow.py:2061 DEBUG    ---------- Alfred PDF Tools (2.16.0) ----------
21:25:53 workflow.py:1468 DEBUG    reading settings from /Users/****/Library/Application Support/Alfred/Workflow Data/com.xilopaint.alfredapp.pdftools/settings.json
21:25:53 workflow.py:2338 INFO     checking for update ...
21:25:53 background.py:233 DEBUG    [__workflow_update_check] command cached: /Users/****/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.xilopaint.alfredapp.pdftools/__workflow_update_check.argcache
21:25:53 background.py:237 DEBUG    [__workflow_update_check] passing job to background runner: ['/usr/bin/python', '/Users/****/Developer/Alfred Workflows/Alfred PDF Tools/alfred-pdf-tools/src/workflow/background.py', '__workflow_update_check']
Traceback (most recent call last):
  File "/Users/****/Developer/Alfred Workflows/Alfred PDF Tools/alfred-pdf-tools/src/workflow/background.py", line 28, in <module>
    from workflow import Workflow
  File "/Users/****/Developer/Alfred Workflows/Alfred PDF Tools/alfred-pdf-tools/src/workflow/workflow.py", line 47, in <module>
    from .util import AcquisitionError  # noqa: F401
ValueError: Attempted relative import in non-package
21:25:53 background.py:241 ERROR    [__workflow_update_check] background runner failed with 1
21:25:53 workflow.py:2103 DEBUG    ---------- finished in 0.353s ----------

 

Edited by xilopaint
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...