common.services.xmlrpc package

Submodules

common.services.xmlrpc.ProtocolErrorHidePw module

just import module to replace xmlrpclib.ProtocolError with ProtocolErrorHidePw

exception common.services.xmlrpc.ProtocolErrorHidePw.ProtocolErrorHidePw(url, errcode, errmsg, headers)

Bases: xmlrpc.client.ProtocolError

xmlrpclib ProtocolError class for hiding the password in the url attrbute

common.services.xmlrpc.SecureXmlRpcRequestHandler module

(this file was moved from awlofar.services.archive in Sep 2012)

class common.services.xmlrpc.SecureXmlRpcRequestHandler.SecureXmlRpcRequestHandler(request, client_ip_port, server, client_digest=None)

Bases: xmlrpc.server.SimpleXMLRPCRequestHandler

Request handler class for a secure XML RPC server.

Storing _client_ip and _client_port

When Authorization is present in the headers, this should contain the username and password.

Defined do_GET for an HTML overview of some stats.

do_GET()

handle HTTP GET

do_POST()

handle HTTP POST

getActiveCount()

return the number of active threads or processes

common.services.xmlrpc.SecureXmlRpcServerSsl module

SecureXmlRpcServerSsl.py - simple XML RPC server supporting SSL.

Based on this article :

and for SecureSocketServer :

This was previously implemented using M2Crypto, see SecureXmlRpcServer.py

WJ Vriend
class common.services.xmlrpc.SecureXmlRpcServerSsl.SecureForkedXmlRpcServer(address, key, cert, handler=<class 'common.services.xmlrpc.SecureXmlRpcRequestHandler.SecureXmlRpcRequestHandler'>)

Bases: socketserver.ForkingMixIn, common.services.xmlrpc.SecureXmlRpcServerSsl.SecureXmlRpcServer

Forked version of the Secure Xml Rpc Server Each request is handled in separate process

collect_children(finished_only=False)

This overwrties the method collect_children in SocketServer.py

If finished_only is set then only the finished (and defunct) processes are handled otherwise the original collect_children is called.

finish_request(request, client_address)

Finish one request by instantiating RequestHandlerClass.

max_children = 100
process_request(request, client_address)

Raise call_counter and call base class process_request()

class common.services.xmlrpc.SecureXmlRpcServerSsl.SecureSocketServer(addr, key_file, cert_file, requestHandler)

Bases: socketserver.TCPServer

collect_children(finished_only=False)

handle all child (forked) processes, see ForkingMixin implementation

class common.services.xmlrpc.SecureXmlRpcServerSsl.SecureThreadedXmlRpcServer(address, key, cert, handler=<class 'common.services.xmlrpc.SecureXmlRpcRequestHandler.SecureXmlRpcRequestHandler'>)

Bases: socketserver.ThreadingMixIn, common.services.xmlrpc.SecureXmlRpcServerSsl.SecureXmlRpcServer

Threaded version of the Secure Xml Rpc Server Each request is handled in separate threat

process_request(request, client_address)

Raise call_counter and call base class process_request()

class common.services.xmlrpc.SecureXmlRpcServerSsl.SecureXmlRpcServer(address, key, cert, handler=<class 'common.services.xmlrpc.SecureXmlRpcRequestHandler.SecureXmlRpcRequestHandler'>)

Bases: common.services.xmlrpc.SecureXmlRpcServerSsl.SecureSocketServer, xmlrpc.server.SimpleXMLRPCServer

common.services.xmlrpc.Worker module

(this file was moved from awlofar.services.archive in Sep 2012)

class common.services.xmlrpc.Worker.Worker(server)

Bases: object

class for a worker thread, periodically doing some work

bytes_to_send = 10000
destructor()

cleanup

do_not_mail = 'do_not_mail'
do_work(last=False)

method which is called every X seconds, set last to make this the last work action

extra_work()

(override) implement this method in derived class to do extra work Derive a class and point to it in the cfg file via worker_thread

log_filename = 'worker_error.log'
mail_error_file()

check if we need to mail the error file

send_mail()

send the mail file using the local mail server or run mail over ssh

send_mail_to = 'wjvriend@astro.rug.nl'
start_timer()

start the timer

work_time = 300

common.services.xmlrpc.XmlRpcMethods module

myMethods(MethodsBase) :

def my_method(self):
return ‘my_method’
def _getErrorReturn(self, msg) :
# return error just as string, a bit more fancy would be a dictionary return ‘An error occured: ‘ + msg

(parts of this file were moved from awlofar.services.archive in Sep 2012)

class common.services.xmlrpc.XmlRpcMethods.MethodsBase

Bases: object

Base class for XmlRpc methods class For each XmlRpc method (that does not start with _) : * the log is initialized and attributes are logged * the method is tried, in case of Exception, the error log is written

arg_value_log_len = 1000
exception common.services.xmlrpc.XmlRpcMethods.XmlRpcMethodsError(message, error_nr=-1)

Bases: Exception

The base class for all Errors in the xml-rpc server An error has a string message and optional number

common.services.xmlrpc.XmlRpcRequestHandler module

(this file was moved from awlofar.services.archive in Sep 2012)

class common.services.xmlrpc.XmlRpcRequestHandler.RequestHandler(request, client_ip_port, server)

Bases: xmlrpc.server.SimpleXMLRPCRequestHandler

Xml RequestHandler class stores the ip and port of the client,

common.services.xmlrpc.XmlRpcServerLock module

Different locking mechanisms for the xml-rpc server

For threads Lock from multiprocessing is used For process (forking) sqlite3 is used

class common.services.xmlrpc.XmlRpcServerLock.BaseLock(verbose=True)

Bases: object

base class for Locking

acquire(*args, **kwargs)

acquire a lock

default_lock_name = 'default_lock'
message(msg)

Only Message when in verbose mode

release(*args, **kwargs)

release a lock

class common.services.xmlrpc.XmlRpcServerLock.DummyLock(verbose=True)

Bases: common.services.xmlrpc.XmlRpcServerLock.BaseLock

acquire(*args, **kwargs)
release(*args, **kwargs)
class common.services.xmlrpc.XmlRpcServerLock.ProcessLock(time_lock_wait_warning=10, lock_db_filename='', **kwargs)

Bases: common.services.xmlrpc.XmlRpcServerLock.BaseLock

class for process locking, using sqlite3

acquire(lock_name='')

acquire lock for the class and identifiers

database_path = '/dev/shm'
date_format = '%Y-%m-%d %H:%M:%S'
get_db_connection()

make and return database connection

classmethod get_db_filename()

return the filename of the database, use name of the database

classmethod get_lock_count(cursor, lock_name)

get and return the count from Lock table

isolation_level = 'EXCLUSIVE'
make_lock_database()
release(lock_name='')

release the lock

sql_create_lock_table = 'CREATE TABLE IF NOT EXISTS Lock (\nlock_name TEXT NOT NULL UNIQUE,\ncreation_date TEXT )'
timeout = 10
class common.services.xmlrpc.XmlRpcServerLock.ThreadLock(lock_names=[], **kwargs)

Bases: common.services.xmlrpc.XmlRpcServerLock.BaseLock

class for Thread Locking within a xml rpc service using Lock from multiprocessing

acquire(lock_name='')

acquire a lock

release(lock_name='')

release a lock

common.services.xmlrpc.XmlRpcServerLock.main()

show content of lock database

common.services.xmlrpc.XmlRpcStats module

Python class for storing xml-rpc calls in a sqlite database

class common.services.xmlrpc.XmlRpcStats.XmlRpcStats(filepath, archive='', locker=None)

Bases: object

archive_now_filename = 'archive_now'
date_format = '%Y-%m-%d %H:%M:%S'
get_db_connection()

make and return database connection

insert_method_call(method_name, method_start, method_end, method_duration, arguments)

insert entry for a method call

isolation_level = 'EXCLUSIVE'
lock_name = 'XmlRpcStats'
make_database()

make the database strucuture

sql_create_stats_table = 'CREATE TABLE IF NOT EXISTS Stats (\nid INTEGER PRIMARY KEY AUTOINCREMENT,\nxml_rpc_method TEXT,\ncall_start TEXT,\ncall_end TEXT,\ncall_duration REAL,\ncall_concurrency INTEGER,\nmethod_arguments TEXT )'
exception common.services.xmlrpc.XmlRpcStats.XmlRpcStatsError

Bases: Exception

common.services.xmlrpc.myXmlRpcServer module

import xmlrpclib client = xmlrpclib.ServerProxy(‘https://username:password@localhost:8080’) result = client.my_method(arg1, arg2, …)

(this file was moved from awlofar.services.archive in Sep 2012)

exception common.services.xmlrpc.myXmlRpcServer.StopRunning

Bases: Exception

common.services.xmlrpc.myXmlRpcServer.main()

the main method

class common.services.xmlrpc.myXmlRpcServer.myConfigParser(defaults=None, dict_type=<class 'collections.OrderedDict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<object object>, converters=<object object>)

Bases: configparser.RawConfigParser

get(section, key)

Module contents