25 Jun 2006 cdfrey   » (Journeyer)


Advogato also has XMLRPC, with which you can do programmatic access to your diary. I do this in the hope that it saves advogato bandwidth.

Below is a small python beginner script that I cooked up just for this task. It checks the dates of the posts and saves the new ones as individual files.

If someone finds it useful, please feel free to use it. You can download it here.


import xmlrpclib import os import difflib

def Download(filename, entry): print "Downloading: " + filename out = open(filename, "w") create, update = server.diary.getDates("cdfrey", entry) out.write("%s\n" % update) out.write(server.diary.get("cdfrey", entry)) out.close()

def GetTimestamp(filename): inf = open(filename, "r") s = inf.readline() inf.close() return s[0:len(s)-1]

def Update(filename, entry): print "Updating: " + filename filetime = GetTimestamp(filename) webcreated, webupdated = server.diary.getDates("cdfrey", entry) if( filetime != webupdated ): print "Entry %d is out of date" % entry if os.access(filename + ".bak", 0): os.unlink(filename + ".bak") os.rename(filename, filename + ".bak") Download(filename, entry)

oldf = open(filename + ".bak", "r") newf = open(filename, "r") oldl = oldf.readlines() newl = newf.readlines() print ''.join(difflib.unified_diff(oldl, newl))

path = "/home/cdfrey/text/advogato/posts/" server = xmlrpclib.Server("http://www.advogato.org/XMLRPC")

entryCount = server.diary.len("cdfrey")

for entry in range(entryCount): filename = path + "advogato.%03d" % entry if os.access(filename, 0): Update(filename, entry) else: Download(filename, entry)

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!