The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Python OmniFocus library for generating reports (http://forums.omnigroup.com/showthread.php?t=28191)

psidnell 2013-02-09 08:33 AM

Python OmniFocus library for generating reports
 
I've wanted a reasonably flexible way of generating mardown/taskpaper/html reports of completed tasks from OmniFocus - but never quite found any love for AppleScript.

So I've developed a python library that directly reads the OF database and builds a complete model of the task/project/context hierarchy that can then be used to generate whatever you wish.

It's early days at the moment (there's no help at all yet) but there are example report generating scripts (for my purposes) that should get you going if you know python and sample AppleScript wrappers so you can add buttons that drive the scripts from the OF toolbar.

I've been using this for a few months now with no issues, but bear in mind that the problem of this approach (i.e. scraping the database) is that Omni make no guarantees about compatibility or support going forward. And nor do I :-)

Comments welcome.

The freshly minted GitHub repo is [URL="https://github.com/psidnell/omnifocus"]here[/URL].

Thanks

whpalmer4 2013-02-09 12:48 PM

Now if only I could run this in Python on the iPad :-)

Any particular version of Python required?

psidnell 2013-02-09 02:03 PM

[QUOTE=whpalmer4;120205]Now if only I could run this in Python on the iPad :-)[/QUOTE]

Give it a try, tell me how it goes :-)

[QUOTE=whpalmer4;120205]Any particular version of Python required[/QUOTE]

I'm using 2.7.3 I think (on my ipad right now), but I'm not doing anything clever so the built in version should do.

One odd problem I have at the moment seems to relate to wide character support, but only if launched from AppleScript, it's fine when started from the console - haven't got to the bottom of that one yet...

RobTrew 2013-02-09 02:13 PM

I like the elegance of the hierarchy handling – thank you !

psidnell 2013-02-09 02:31 PM

Thankyou! It's actually my first Python program, it probably smells of Java :-)

whpalmer4 2013-02-09 05:14 PM

I'm a Python novice, maybe I'm doing something wrong, but I get nothing when I try any of the reports. I did fix the obvious problem with my home directory being something other than /Users/psidnell, but if I try to run linkgen.py I get
[code]
bash-3.2$ python linkgen.py
File "linkgen.py", line 6
def __init__ (self, out, types = {'Folder', 'Project', 'Task'}, indent=4):
^
SyntaxError: invalid syntax
bash-3.2$
[/code]

and the most I can get out of any of the other scripts is
[code]
# Weekly Progress Report

## Bill Palmer Sat Feb 09 2013

---

[/code]

I'm running Python 2.6.1 on 10.6.8. Any suggestions on my next troubleshooting step?

psidnell 2013-02-10 01:29 AM

Hmm - that first error in linkgen.py is odd.

I'm using Python V2.7.2 and OSX 10.8.2 the same as you. The line itself is valid - have you added any code above it? The syntax looks the same as mine.

It's a shame you're having issues with linkgen.py since that's the report I'd recommend starting with since it just dumps everything to html and then opens the browser on it.

As for the second issue with weekly report.py, it looks like the report is running but finding nothing to produce. This is most likely because of other config personal to my work flow:

1. weeklyreport.py looks throught all the folders for one called "Work" and only descends into that. Getting rid of that test should help.

2. donereport.py (which weeklyreport.py imports) looks for completed tasks in a context whose name starts with "Log" (I move only some completed tasks into a Log context at the end of the day so I can control what appears in it).

Let me know if this helps.

psidnell 2013-03-02 07:37 AM

1 Attachment(s)
Just added an OPML printer, this is the output viewed in OmniOutliner:

TeamTeaTime 2013-03-07 06:11 AM

Great work! I look forward to testing this out.

It wasn't working initially for me because I'm using the App store OF.

Once I pointed it to the correct db everything was working, but for anyone else's reference:

DATABASE = environ['HOME'] + '/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2'

DATABASE = environ['HOME'] + '/Library/Caches/com.omnigroup.OmniFocus.MacAppStore/OmniFocusDatabase2'

psidnell 2013-03-14 12:00 PM

Thanks! I didn't realise there were two locations.

I might get it to check for both in the next update...

psidnell 2013-03-16 03:56 AM

[QUOTE=psidnell;121382]Thanks! I didn't realise there were two locations.

I might get it to check for both in the next update...[/QUOTE]

The latest version now checks both locations for the database stopping on the first match.

RobTrew 2013-03-16 11:42 PM

[QUOTE=psidnell;121433]checks both locations ... stopping on the first match.[/QUOTE]

For edge cases where both locations exist (i.e, where installation history has been complex – retreats from the AppStore, multiple testing versions etc) you can use an osascript system call to get the bundle name of the active installation, and use this to decide whether to look in the .MacAppStore folder or the vanilla OF folder.

Something like:

[CODE]tell application "Finder" to id of application file id "OFOC"[/CODE]

will either return:[LIST=1][*]com.omnigroup.OmniFocus[*]com.omnigroup.OmniFocus.MacAppStore, or[*]an error if neither is installed.[/LIST]
FWIW there's more on first-aid for the appstore version at:

[url]http://forums.omnigroup.com/showthread.php?t=21496[/url]

psidnell 2013-03-17 01:08 AM

Cool - thanks. There's no escaping applescript though is there :-)

psidnell 2013-04-08 11:26 AM

This has mutated into a more general purpose command line utility for exporting reports into html, opml, text, markdown or taskpaper with various filters.

I've finally got around to writing some documentation [URL="https://github.com/psidnell/omnifocus/blob/master/DOCUMENTATION.md"]HERE[/URL]. Not quite finished, but a start...

There's still plenty more I want to add but it should be useable, particularly for exporting reports of completed tasks.

psidnell 2013-04-11 11:54 PM

Given the changes I've renamed the repo from "omnifocus" to "ofexport".

The documentation is now [URL="https://github.com/psidnell/ofexport/blob/master/DOCUMENTATION.md"]here[/URL].

I'll add a new post in the forum with a more helpful title.


All times are GMT -8. The time now is 10:10 PM.

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