26 Jan 2005 titus   » (Journeyer)

Poor man's advogato pull script

People seem to be losing diary entries occasionally, so I instituted a backup policy for my advogato diary. Here's the script.

(Kudos to advogato for having an XMLRPC API...)

#! /usr/bin/env python
import xmlrpclib, os, time, stat

server = xmlrpclib.Server("http://www.advogato.org/XMLRPC") n = server.diary.len('titus')

entries = [] for i in range(n): print '... entry', i, created, modified = server.diary.getDates('titus', i) created = time.mktime(time.strptime(created.value, "%Y%m%dT%H:%M:%S")) modified = time.mktime(time.strptime(modified.value, "%Y%m%dT%H:%M:%S"))

filename = '%d.txt' % (i,)

found = 0 try: info = os.stat(filename) found = 1 except OSError: pass if not found: print '--> changed/DNE'

entry = server.diary.get('titus', i) open(filename, 'w').write(entry) os.utime(filename, (created, modified,)) else: print 'unchanged.'

The only tricky part was figuring out how to extracted the created/modified value from the xmlrpc module, which required some digging...

--titus

p.s. apologies for the indentation; the actual HTML is properly indented, but it looks like advogato does funny things to it.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!