Jump to content

Ulysses workflow


Recommended Posts

I've extracted the xcall part of ulysses-python-client into a separate project python-xcall. I think this could be quite a handy tool and I'll try and put this up on PyPi if I can work out how to distribute the lib folder including Martin's xcall.app. Seems like pip wheels are the key!

 

Then maybe after doing some actual work I'll include your ul command @dfayinto the ulysses workflow this thread is supposed to be about ;)

Edited by deanishe
fix URL
Link to comment

This reminds me I meant to post about a weird issue I had last night. I kept getting a message "xcall.app is no longer running". In activity monitor there were like nine instances of xcall active.  I had to kill them all manually before the workflow would work again.

Link to comment
4 minutes ago, dfay said:

This reminds me I meant to post about a weird issue I had last night. I kept getting a message "xcall.app is no longer running". In activity monitor there were like nine instances of xcall active.  I had to kill them all manually before the workflow would work again.

Uh oh! I must have called it thousands of times with automated testing and haven't noticed this. But I noticed sometimes when calling ulysses with a wrong id there are long delays in returning. Possibly there might be other causes of this too. I wonder if your issue might be caused by making a call before another has returned and it all getting out of sync? I'll see if I can reproduce.

 

Also, you mentioned a while back:

Quote

One thing I noticed, though, was that the authentication token I'd acquired earlier today no longer worked and I had to re-authenticate.  Have you been able to consistently use the same token without repeat re-authentication?

I've not seen a problem with this one. Even if you request new token, old ones seem to keep working.

Link to comment

Just ran into another issue when I sat down at my iMac for the first time in a week....workflows sync via Dropbox but of course Ulysses authentication tokens are not the same from one Mac installation to another.  I think I will need to do something like this 

 and pass the authentication token when I call the script in the Script Filter.  Unless you see a better way.

Link to comment
22 minutes ago, deanishe said:

 

@robwalton I'm looking over the workflow code. There's no need for such long imports. The AW API is defined in __init__.py.

 

from workflow import Workflow3

 

is enough, unless you're using some internal functions—at your peril ;)

Thanks Python tutor :). I've fixed this on my local development version (it did feel a bit clunky at the time). I have a huge project in my day job which would could probably do with using defining  package APIs in __init__s. Will look at that too. I did a huge refactor of that a while back to make it less Java-like, but I guess I still missed some Python tricks.

 

BTW, is there is there a good way to get Alfred to run off a git repo's working copy? Now I ask it: I guess I could just replace my e.g user.workflow.A661A55B-8CCD-4E74-BC15-54528262B74E folder with a symbolic link to my git working copy?

Link to comment
On 13/04/2017 at 1:43 AM, dfay said:

I poked around in the XML in the library a bit and it seems that the DisplayName for my root is set to "On My Mac" even though it is in fact in iCloud.  Seems like a Ulysses bug that is otherwise invisible but which the workflow may make evident by using the DisplayName?  Just a guess.

Hi there, just integrating the x-callback stuff into ulysses workflow. I think I will go back to supporting iCloud only for now as this seems more trouble than its worth (unless you got further analysing it?)

Link to comment
On 20/04/2017 at 5:56 PM, dfay said:

Just ran into another issue when I sat down at my iMac for the first time in a week....workflows sync via Dropbox but of course Ulysses authentication tokens are not the same from one Mac installation to another.  I think I will need to do something like this 

 and pass the authentication token when I call the script in the Script Filter.  Unless you see a better way.

Thanks @dfay, I'll get this bit working in the workflow first. 

 

I think that in bringing in the x-callback stuff, given the lack of tests in the workflow, I'll run old and new next to each other for a bit with some assertions. May still be a bit until I add your new commands, as will be working on foundations.

 

Thanks for your ideas, work and debugging to date! --Rob

Link to comment
On 20/04/2017 at 5:28 PM, robwalton said:

This reminds me I meant to post about a weird issue I had last night. I kept getting a message "xcall.app is no longer running". In activity monitor there were like nine instances of xcall active.  I had to kill them all manually before the workflow would work again.

Hi again, I tried pretty hard to reproduce by firing off call from threads in parallel, but seemed okay. I haven't checked if xcall is thrad/process safe yet, but a quick glance in the code makes me think not. For this, and your issue, python-xcall now throws an AssertionError if it finds xcall already running. There is 20-30ms period after making one call where a second will still go through though. It should help a bit--and it might help you diagnose want wrong for you? The real solution is (from the outside of xcall at least) is a file lock--but those cause so much grief! 

Link to comment
On 19/04/2017 at 6:42 AM, dfay said:

 

Actually there's a typo in Rob's code … in ulysses_calls.py --  open_recent() should call the URL that patgilmour pasted above.

 

Whoops! Thanks for spotting that. No tests for those bits. Have fixed the workflow on master. Will have to start thinking about a release when it settles down.

Link to comment
  • 3 months later...

This workflow is amazing. Thanks for sharing it!

 

I am getting a few issues though. 

 

un : this command only sometimes creates a new sheet. Mostly it opens ulysses and does nothing else. I believe, but am not certain, that it will never create a new sheet in a group I have created, but will always create a new sheet if I select the "inbox" as the destination.

 

uo : this command typically calls command-o to whatever app is open when I invoke it. Thus, it will work if Ulysses is already open, but not if some other app is open.

Link to comment
  • 2 months later...

Hi Rob

I am getting the same issue described above with uo .  

 

Also using any of u ug uf us throws a KeyError: 'displayName'

 

full message here:

[2017-10-28 10:51:16][ERROR: input.scriptfilter] Code 1: ulysses_items.py:124: SyntaxWarning: assertion is always true, perhaps remove parentheses?
  assert (os.path.exists(args.limit_scope_dir),
10:51:15 workflow.py:2249 DEBUG    workflow version: 1.0.0
10:51:15 workflow.py:1657 DEBUG    reading settings from /Users/usernamehere/Library/Application Support/Alfred 3/Workflow Data/com.github.robwalton.alfred-ulysses-workflow/settings.json
10:51:15 workflow.py:2532 DEBUG    Update check not due
10:51:15 ulysses_items.py:57 INFO     ulysses_items.main(wf): args = 
Namespace(kind='sheet', limit_scope_dir=None, query='', search_content=False, search_ulysses_path=True)
10:51:15 workflow.py:1884 DEBUG    loading cached data: /Users/usernamehere/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.github.robwalton.alfred-ulysses-workflow/__workflow_update_status.cpickle
10:51:15 workflow.py:2462 DEBUG    update_data: {u'available': False}
10:51:15 ulysses_items.py:82 INFO     Added iCloud items from '/Users/usernamehere/Library/Mobile Documents/X5AZV975AG~com~soulmen~ulysses3/Documents/Library/Groups-ulgroup'
10:51:16 ulysses_items.py:82 INFO     Added iCloud Inbox items from '/Users/usernamehere/Library/Mobile Documents/X5AZV975AG~com~soulmen~ulysses3/Documents/Library/Unfiled-ulgroup'
10:51:16 workflow.py:2267 ERROR    'displayName'
Traceback (most recent call last):
  File "/Users/usernamehere/Dropbox/Sync/Alfred/Alfred.alfredpreferences/workflows/user.workflow.8A4FD89F-3A79-4823-934E-855B611DA3DD/workflow/workflow.py", line 2260, in run
    func(self)
  File "ulysses_items.py", line 85, in main
    include_sheets)
  File "ulysses_items.py", line 145, in parse_ulysses_for_groups_and_sheets
    groups_tree = parse_ulysses.create_tree(root_dir, None)
  File "/Users/usernamehere/Dropbox/Sync/Alfred/Alfred.alfredpreferences/workflows/user.workflow.8A4FD89F-3A79-4823-934E-855B611DA3DD/parse_ulysses.py", line 113, in create_tree
    group = Group(rootgroupdir, parent_group)
  File "/Users/usernamehere/Dropbox/Sync/Alfred/Alfred.alfredpreferences/workflows/user.workflow.8A4FD89F-3A79-4823-934E-855B611DA3DD/parse_ulysses.py", line 63, in __init__
    join(self.dirpath, 'Info.ulgroup'))['displayName']
KeyError: 'displayName'
10:51:16 workflow.py:2269 INFO     for assistance, see: https://github.com/robwalton/alfred-ulysses-workflow
10:51:16 workflow.py:2290 DEBUG    workflow finished in 0.313 seconds

 

Link to comment
  • 4 weeks later...
  • 3 weeks later...

Hi @40-02, @apoc527, @dfay (thanks for the stack trace). Thanks for the reports that the workflow is broken with Ulysses 12.

 

I had the same problem. Try this new release  v1.0.2. Please let me know if it looks okay and I'll upload it to Packal later and close issue. Thanks.

 

EDIT: updated link to v1.0.2 as I've also fixed the 'uo' command to work with the new app name (although this one always has mixed results and I've tweaked the way it wants for ulysses to be ready to receive cmd-O.

 

 

 

Edited by robwalton
Link to comment
  • 3 weeks later...
On 08/01/2018 at 4:23 AM, alfredclough said:

Just want to say this workflow is amazing--it makes working with Ulysses so much more efficient.

Thanks for the positive feedback. I've started using Ulysses after a bit of a break and I'm just remembering how the workflow works again!

Link to comment

How would a ulysses temporary 'context' work?

 

I'm finding myself spending more extended periods working in one group than I used to. I'm imaging two new commands:

usc -- Select a group to act as a search-limiting context and open that group; no argument to clear.

uc -- Open a sheet or group from within the search-limiting context; warns if no context set.

 

Would anyone else use this? or any better suggestions!

 

Edited by robwalton
typo
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...