The Artima Developer Community
Sponsored Link

Web Buzz Forum
Adding tasks to Evolution from Python

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Stuart Langridge

Posts: 2006
Nickname: aquarius
Registered: Sep, 2003

Stuart Langridge is a web, JavaScript, and Python hacker, and sometimes all three at once.
Adding tasks to Evolution from Python Posted: Mar 11, 2011 10:04 PM
Reply to this message Reply

This post originated from an RSS feed registered with Web Buzz by Stuart Langridge.
Original Post: Adding tasks to Evolution from Python
Feed Title: as days pass by
Feed URL: http://feeds.feedburner.com/kryogenix
Feed Description: scratched tallies on the prison wall
Latest Web Buzz Posts
Latest Web Buzz Posts by Stuart Langridge
Latest Posts From as days pass by

Advertisement

It occurred to me that it'd be useful to have some of my scripts throw tasks into my task list in Evolution. Now, this is entirely possible: there's an API to interact with Evolution from Python code (in Ubuntu as python-evolution. And it works.

>>> import evolution.ecal
>>> print evolution.ecal.list_task_sources()
[('Personal', 'local:system'), ('Shopping', 'local:1299834516.3294.1@giles')]
>>> personal_list_uri = evolution.ecal.list_task_sources()[0][1]
>>> personal_list_source = evolution.ecal.open_calendar_source(personal_list_uri, 
    evolution.ecal.CAL_SOURCE_TYPE_TODO)
** (process:14939): DEBUG: Opening calendar source uri: local:system
>>> print [obj.get_summary() for obj in personal_list_source.get_all_objects()]
['My first task', 'My second task']

And we can also add new tasks to an existing list:

>>> new_task = evolution.ecal.ECalComponent(evolution.ecal.CAL_COMPONENT_TODO)
>>> new_task.set_summary('Write task scripts')
>>> personal_list_source.add_object(new_task)

What I can't seem to do, though, is create a new task list. I ought to be able to. Lists created in Evolution itself seem to have a list uri that looks like local:(time).(number)@(machinename). So I think this should work:

>>> new_list_source = evolution.ecal.open_calendar_source_new_with_absolute_uri('Created from Python', 
  'local:%s00.2.giles' % time.time(),
  evolution.ecal.CAL_SOURCE_TYPE_TODO)
>>> new_task_2 = evolution.ecal.ECalComponent(evolution.ecal.CAL_COMPONENT_TODO)
>>> new_task_2.set_summary('New task in a new list')
>>> new_list_source.add_object(new_task_2)

...but it does not. No errors are thrown, and the newly created source doesn't seem to be invalid (that is: I can add a newly created task to it, and that doesn't throw an error either), but... the newly created list (or task) doesn't show up in Evolution. No idea what I'm doing wrong here; I would guess that I need to somehow "save" the new task list, but I can't see how? Any suggestions?

Read: Adding tasks to Evolution from Python

Topic: Your iPhone is Your Personal “Black Box” with Buddy Guard VIP (Free!) Previous Topic   Next Topic Topic: Tips for Achieving High Google Ranking

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use