The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
OmniFocus -> PagePacker Script [Python] Thread Tools Search this Thread Display Modes
Hi folks,

The PagePacker application looks like a great way to carry your context lists with you. It's fully scriptable, so I started looking at ways to link it into OmniFocus.

Unfortunately, there's no straightward way of scripting the "Save to PDF" functionality within OSX, so it's not easy to get the context lists out of OmniFocus in a nicely-formatted way. Fortunately, though, PagePacker handles plain-text files, so I decided to knock something together that pulls the context lists out of OmniFocus, and imports them into PagePacker as a series of plain text files.

The result is a bit ugly, but it seems to work fine. I'm not keen on writing AppleScript, so I implemented this in Python -- it should work on any copy of OSX, as Python comes pre-installed.

I've even added the ability to add your own PDF files to the PagePacker document (to add a custom title page, or whatever). Ultimately, I'd like to extend this using a toolkit I'm familiar with (a thing called ReportLab) that can create PDF files programmatically. With that, we'd get nicely-formatted context lists which could be imported into PagePacker directly -- assuming, of course, that Omni don't beat me to it by adding the functionality directly into OmniFocus (which would be the ideal way to handle this).

Anyway, I've attached my first cut at this script. There are instructions in the script itself, so if you open it in your favourite text editor, you should have everything you need to get going.

- Erik.

[Edited to upload newer version of script]
Attached Files
File Type: zip contexts_to_pagePacker_v0.3.zip (3.7 KB, 916 views)

Last edited by erik_westra; 2007-10-28 at 07:41 PM..
 
I get
Code:
Traceback (most recent call last):
  File "contexts_to_pagePacker.py", line 304, in ?
    main()
  File "contexts_to_pagePacker.py", line 251, in main
    task,project = line.split("\t")
ValueError: need more than 1 value to unpack
 
Quote:
Originally Posted by erik_westra View Post
The result is a bit ugly, but it seems to work fine. I'm not keen on writing AppleScript, so I implemented this in Python -- it should work on any copy of OSX, as Python comes pre-installed.
I don't know much about Python. Do you *have* to run the script in terminal? What I mean to ask if whether running it in terminal is the only way to run it.
 
Hi Craig,

Quote:
Originally Posted by Craig View Post
I get
Code:
Traceback (most recent call last):
  File "contexts_to_pagePacker.py", line 304, in ?
    main()
  File "contexts_to_pagePacker.py", line 251, in main
    task,project = line.split("\t")
ValueError: need more than 1 value to unpack
Strange...that should be impossible in theory. The Applescript used to extract the tasks must be returning a value without a project included.

This doesn't happen on my machine -- I suspect there's something about your set of tasks that is causing the script to crash.

I've just uploaded a new version of the script, which checks to see if a project name was included in the task's text extracted from OmniFocus. If not, is just leaves the project name blank, rather than crashing.

Please try re-downloading the newer version (I've called this version 0.2), and let me know if it works or not.

Thank,

- Erik
 
Hi dhm2006,

Quote:
Originally Posted by dhm2006 View Post
I don't know much about Python. Do you *have* to run the script in terminal? What I mean to ask if whether running it in terminal is the only way to run it.
Good question. In theory, I ought to be able to convert this to an "applet" that can be double-clicked from the Finder. I haven't done this myself, because in my work we create standalone applications from the Python source rather than applets. These standalone applications include the entire Python interpreter, as well as a bunch of 3rd party libraries, which makes for a 20mb download. That's hardly needed for something as simple a this!

I'll let you know if I can figure something out for you.

- Erik.
 
Hi dhm2006,

Quote:
Originally Posted by dhm2006 View Post
I don't know much about Python. Do you *have* to run the script in terminal? What I mean to ask if whether running it in terminal is the only way to run it.
I think I have a workaround to this -- I've created a simple shell script that should do what you want, and bundled it into a double-clickable application using a tool called "Platypus".

I've attached a zip archive which contains a small application called "Run Script". Place this application in the same directory as the "contexts_to_pagePacker.py" file, along with any PDF files you may want to add to the output (as described in the documentation at the top of the script). You can then double-click the application to run the script.

If you want to put this elsewhere, make an alias -- it's important that the application itself stays in the same directory as the Python script.

Hope this helps...

- Erik.
Attached Files
File Type: zip Run Script.zip (56.4 KB, 825 views)
 
Quote:
Originally Posted by erik_westra View Post
Please try re-downloading the newer version (I've called this version 0.2), and let me know if it works or not.
Nope, same problem (though this time with references to line 310 and line 257 respectively).
 
Hi Craig,

Quote:
Originally Posted by Craig View Post
Nope, same problem (though this time with references to line 310 and line 257 respectively).
Oops! Sorry about that -- I'd added the error-check, but forgot to delete the original line which caused the crash. Try v0.3...

- Erik.
 
Quote:
Originally Posted by erik_westra View Post
Try v0.3...
Now I get
Code:
53:66: execution error: OmniFocus got an error: NSReceiverEvaluationScriptError: 4 (1)
Error running Applescript: 256
EDIT: Ignore the above - I have it working now.

Last edited by Craig; 2007-10-29 at 06:40 AM..
 
Quote:
Originally Posted by erik_westra View Post
I think I have a workaround to this -- I've created a simple shell script that should do what you want, and bundled it into a double-clickable application using a tool called "Platypus".

I've attached a zip archive which contains a small application called "Run Script". Place this application in the same directory as the "contexts_to_pagePacker.py" file, along with any PDF files you may want to add to the output (as described in the documentation at the top of the script). You can then double-click the application to run the script.

If you want to put this elsewhere, make an alias -- it's important that the application itself stays in the same directory as the Python script.
Thank you. I had already been looking at the original script in Platypus, but could not find a "Run Script" command (like there is in Applescript Script Editor). I appreciate your creating this extra script for me (I hope others can use it as well -- I can't be the only person that doesn't like to muck around in the terminal).

Last edited by dhm2006; 2007-10-29 at 04:58 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python OmniFocus library for generating reports psidnell OmniFocus Extras 14 2013-04-11 11:54 PM
Omnifocus weekly report script.... fmantek OmniFocus Extras 13 2013-01-21 11:26 PM
Script: FoldingText to OmniFocus RobTrew OmniFocus Extras 47 2013-01-06 07:03 AM
PagePacker print service Schimmi OmniFocus Extras 9 2010-06-26 06:13 AM
Jott to OmniFocus Script posted MB_UST OmniFocus Extras 3 2008-01-03 05:07 AM


All times are GMT -8. The time now is 03:15 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.