#!/usr/bin/python # # blo.gs RSS ping for Movable Type # Mark Paschal # 1.0, 12 December 2002 # # Receives a weblogs.com XML-RPC weblogUpdates.ping, upgrading it # to a blo.gs weblogUpdates.extendedPing and reflecting it to # http://ping.blo.gs/ . # # # # Edit the weblogUrl and rssUrl settings below before using. # # # # blo.gs RSS ping for Movable Type # Copyright 2002 Mark Paschal # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # # The URL of your weblog. Only pings for this site will be upgraded to # extendedPings, though all pings are reflected. weblogUrl = "http://markpasc.org/weblog/" # The URL to provide as your RSS URL. rssUrl = "http://markpasc.org/weblog/index.xml" # Show debug information when sending ping to blo.gs, if greater than 0. verbose = 0 try: import sys import xmlrpclib # to read from stdin import xreadlines from cStringIO import StringIO # to put error traceback in unexpected fault import traceback from string import join # Read the posted data in. packetIO = StringIO() for line in xreadlines.xreadlines(sys.stdin): packetIO.write(line) packet = packetIO.getvalue() del(packetIO) (params, method) = xmlrpclib.loads(packet) del(packet) if "weblogUpdates.ping" <> method: fault = xmlrpclib.Fault(1, "This server doesn't support your procedure '%s'." % method) print "Content-type: text/xml" print print xmlrpclib.dumps(fault, methodresponse=1) sys.exit(0) # Do we add our RSS? if weblogUrl == params[1]: method = "weblogUpdates.extendedPing" params = (params[0], params[1], rssUrl, rssUrl) # Mirror to blo.gs. rpc = xmlrpclib.Server("http://ping.blo.gs/", verbose=verbose) response = apply(getattr(rpc, method), params) print "Content-type: text/xml" print print xmlrpclib.dumps((response,), methodresponse=1) except SystemExit: pass except Exception, x: fault = xmlrpclib.Fault(1, "%s: %s\n%s" % (x.__class__, x, join(apply(traceback.format_exception, sys.exc_info()), '')) ) print "Content-type: text/xml" print print xmlrpclib.dumps(fault, methodresponse=1)