diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-30 15:16:14 +0200 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-30 15:16:14 +0200 |
commit | 83cbf839335770b511a1d94a6fca9e210eab995f (patch) | |
tree | 7bfe4c6213a93f4cad7a632edb813163f76b1428 /server/xmlrpc_API1.py | |
parent | 6247a6e158ce543e6c31c1f24df2f1a655fac28a (diff) | |
download | rteval-83cbf839335770b511a1d94a6fca9e210eab995f.tar.gz rteval-83cbf839335770b511a1d94a6fca9e210eab995f.tar.xz rteval-83cbf839335770b511a1d94a6fca9e210eab995f.zip |
Add XML-RPC submissions into a submission queue instead of parsing it directly
This is to avoid overloading the Apache process doing XML parsing and database
inserts on bigger XML reports. A separate parser process will need to pick files
from the submission queue and parse them in separate thread(s).
Diffstat (limited to 'server/xmlrpc_API1.py')
-rw-r--r-- | server/xmlrpc_API1.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/server/xmlrpc_API1.py b/server/xmlrpc_API1.py index 95390bd..7b61234 100644 --- a/server/xmlrpc_API1.py +++ b/server/xmlrpc_API1.py @@ -36,7 +36,7 @@ import rtevaldb class XMLRPC_API1(): def __init__(self, config=None, debug=False, nodbaction=False): # Some defaults - self.fnametrans = string.maketrans("/\\", "::") # replace path delimiters in filenames + self.fnametrans = string.maketrans("/\\.", "::_") # replace path delimiters in filenames self.debug = debug self.nodbaction = nodbaction self.config = config @@ -53,12 +53,12 @@ class XMLRPC_API1(): os.chdir(startdir) - def __getfilename(self, dir, fname, comp): + def __getfilename(self, dir, fname, ext, comp): idx = 0 if comp: - filename = "%s/%s/%s.bz2" % (self.config.datadir, dir, fname.translate(self.fnametrans)) + filename = "%s/%s/%s%s.bz2" % (self.config.datadir, dir, fname.translate(self.fnametrans), ext) else: - filename = "%s/%s/%s" % (self.config.datadir, dir, fname.translate(self.fnametrans)) + filename = "%s/%s/%s%s" % (self.config.datadir, dir, fname.translate(self.fnametrans), ext) while 1: if not os.path.exists(filename): @@ -90,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.config.datadir + '/reports/' + clientid) - fname = self.__getfilename('reports/' + clientid,'report.xml', False) + self.__mkdatadir(self.config.datadir + '/queue/') + fname = self.__getfilename('queue/', ('%s' % clientid), '.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(self.config, xmldoc, fname, + # Register the submission and put it in a parse queue + rterid = rtevaldb.register_submission(self.config, clientid, fname, debug=self.debug, noaction=self.nodbaction) if self.nodbaction: rterid = 999999999 # Fake ID when no database registration is done @@ -116,7 +116,7 @@ class XMLRPC_API1(): 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) + fname = self.__getfilename(('uploads/%s/%s' % clientid), filename, None, not decompdata) # Save and return filename used server side f = open(fname, "w") |