diff options
author | David Sommerseth <davids@redhat.com> | 2009-09-24 19:41:01 +0200 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2009-09-24 19:41:01 +0200 |
commit | 556bfb7f74d5e4405e582e2eb9e43bd437e1036e (patch) | |
tree | a5bcfd14accf3ac2a02a94e5787e0974339c5334 /server/xmlrpc_API1.py | |
parent | a2d96978b29b07ec3e68e93e85d1ba770dc5dd3a (diff) | |
download | rteval-556bfb7f74d5e4405e582e2eb9e43bd437e1036e.tar.gz rteval-556bfb7f74d5e4405e582e2eb9e43bd437e1036e.tar.xz rteval-556bfb7f74d5e4405e582e2eb9e43bd437e1036e.zip |
Rewritten XML-RPC server to use rtevalConfig
Introduced a new rteval.conf section for configuring the xmlrpc server.
[xmlrpc_server]
datadir: <path to where to save copy of summary.xml report>
xsltpath: <path to where xmlparser.xsl can be found>
db_server: <hostname of PostgreSQL server to connect to>
db_port: <port number of PostgreSQL>
database: <database to use>
db_username: <connect to database as this user>
db_password: <password for the db account>
The default values of these parameters are:
datadir: /var/lib/rteval
xsltpath: /usr/share/rteval
db_server: localhost
db_port: 5432
database: rteval
db_username: xmlrpc
db_password: rtevaldb
The xmlrpc_server section in the /etc/rteval.conf file only need those
parameters which are different from the default values.
Diffstat (limited to 'server/xmlrpc_API1.py')
-rw-r--r-- | server/xmlrpc_API1.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/server/xmlrpc_API1.py b/server/xmlrpc_API1.py index b1cae0e..99c4624 100644 --- a/server/xmlrpc_API1.py +++ b/server/xmlrpc_API1.py @@ -34,12 +34,13 @@ import rtevaldb class XMLRPC_API1(): - def __init__(self, dataroot="/var/lib/rteval", debug=False, nodbaction=False): + def __init__(self, config=None, debug=False, nodbaction=False): # Some defaults - self.dataroot = dataroot self.fnametrans = string.maketrans("/\\", "::") # replace path delimiters in filenames self.debug = debug self.nodbaction = nodbaction + self.config = config + def __mkdatadir(self, dirpath): startdir = os.getcwd() @@ -64,9 +65,11 @@ class XMLRPC_API1(): return filename idx += 1 if comp: - filename = "%s/%s/%s-{%i}.bz2" % (self.dataroot, dir, fname.translate(self.fnametrans), idx) + filename = "%s/%s/%s-{%i}.bz2" % (self.config.datadir, dir, + fname.translate(self.fnametrans), idx) else: - filename = "%s/%s/%s-{%i}" % (self.dataroot, dir, fname.translate(self.fnametrans), idx) + filename = "%s/%s/%s-{%i}" % (self.config.datadir, dir, + fname.translate(self.fnametrans), idx) def Dispatch(self, method, params): @@ -87,14 +90,14 @@ class XMLRPC_API1(): # Save a copy of the report on the file system # Make sure we have a directory to write files into - self.__mkdatadir(self.dataroot + '/reports/' + clientid) + self.__mkdatadir(self.config.datadir + '/reports/' + clientid) fname = self.__getfilename('reports/' + clientid,'report.xml', False) xmldoc.saveFormatFileEnc(fname,'UTF-8',1) if self.debug: print "Copy of report: %s" % fname # Register the report into a database and return the rteval run id - (syskey, rterid) = rtevaldb.register_report('xmlparser.xsl', xmldoc, fname, + (syskey, rterid) = rtevaldb.register_report(self.config, xmldoc, fname, debug=self.debug, noaction=self.nodbaction) if self.nodbaction: rterid = 999999999 # Fake ID when no database registration is done @@ -110,7 +113,7 @@ class XMLRPC_API1(): data = base64.b64decode(bzb64data) # Make sure we have a directory to write files into - self.__mkdatadir(self.dataroot + '/uploads/' + clientid) + self.__mkdatadir(self.datadir + '/uploads/' + clientid) # Get a unique filename, as close as possible to the input filename fname = self.__getfilename('uploads/' + clientid, filename, not decompdata) |