/usr/share/doc/python-twisted-web/examples/advogato.py is in python-twisted-web 13.2.0-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
This example demonstrates how to logon to a remote server and post a diary.
Usage:
$ python advogato.py <name> <diary entry file>
"""
import sys
from getpass import getpass
from twisted.web.xmlrpc import Proxy
from twisted.internet import reactor
class AddDiary:
def __init__(self, name, password):
self.name = name
self.password = password
self.proxy = Proxy('http://advogato.org/XMLRPC')
def __call__(self, filename):
self.data = open(filename).read()
d = self.proxy.callRemote('authenticate', self.name, self.password)
d.addCallbacks(self.login, self.noLogin)
def noLogin(self, reason):
print "could not login"
reactor.stop()
def login(self, cookie):
d = self.proxy.callRemote('diary.set', cookie, -1, self.data)
d.addCallbacks(self.setDiary, self.errorSetDiary)
def setDiary(self, response):
reactor.stop()
def errorSetDiary(self, error):
print "could not set diary", error
reactor.stop()
diary = AddDiary(sys.argv[1], getpass())
diary(sys.argv[2])
reactor.run()
|