This repository has been archived on 2021-03-01. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
kaneton/test/packages/ktp/xmlrpc.py
Mercier Pierre-Olivier fee4dd4e6d Initial snapshot
2013-02-11 22:04:30 +01:00

60 lines
1.2 KiB
Python

#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/test/packages/ktp/xmlrpc.py
#
# created julien quintard [mon oct 25 19:44:10 2010]
# updated julien quintard [tue feb 8 17:39:08 2011]
#
#
# ---------- packages ---------------------------------------------------------
#
import xmlrpclib
import sys
import ktp
#
# ---------- functions --------------------------------------------------------
#
#
# this method wraps a call to a remote method.
#
def Call(value):
type = None
data = None
# retrieve the type.
type = value[0]
# transform the data should it be in binary form.
if isinstance(value[1], xmlrpclib.Binary) == True:
data = str(value[1])
else:
data = value[1]
# display an error if the type indicates so.
if type == ktp.StatusError:
print("[error] " + data)
sys.exit(42)
return data
#
# this method connects to an XMLRPC server.
#
def Connect(server):
handle = None
# issue the connection request.
handle = xmlrpclib.Server(server,
allow_none = True)
return handle