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() >>> 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
>>> 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?