This is

as days pass by, by Stuart Langridge

. Here I write about many things. In the past I wrote about other things but the past is past. I write code for people to play with, I write about my life on Twitter, and I write here.

On I wrote Adding tasks to Evolution from Python, on the subject of Evolution, HOWTOs, and Hacks.

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?

Danilo

I can't help hugely, but do note that this does create storage in ~/.local/share/evolution/tasks/`new_list_source.get_uid()`/tasks.ics — why it doesn't get tied up with Evolution beats me though :)

(I've recently been fighting similar issues with the address-book component, so I am kind of interested in this as well)

sil

Danilo: ahaha! So it's not failing to create; it's just failing to refresh Evolution's view! This is useful information, indeed :)

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

Web Designer Uk

That is great post. It's great post. Thanks for shearing your ideas.

ver tv online

nice post :-)

kallymoral

very well written and informative post.. thanks for sharing!

Simon

We'd take your calendar code a lot more seriously if the pubDate in the feed wasn't dated 1901?!

This website belongs to Stuart Langridge. Contact details are available. Don't eat yellow snow. Valid HTML5, at least in theory, except for the bits that aren't because I'm that futuristic that I'm ahead of the spec, oh yes. HTML5 help from Bruce Lawson, among others. Fonts from the superb FontSquirrel. End.