Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Abente <martin.abente.lahaye@gmail.com>2011-03-31 16:40:06 (GMT)
committer Martin Abente <martin.abente.lahaye@gmail.com>2011-03-31 16:40:06 (GMT)
commit8b233b0876a7aa4d0eae11ee0e0114ad5a92d29f (patch)
tree8429c26c5b72edfcfa660940958c319120481b1e
parentc031813662f332e56ad1f6f27ca778f485e03407 (diff)
Save report file at last
-rw-r--r--fbserver.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/fbserver.py b/fbserver.py
index 0a4b448..1adf9e8 100644
--- a/fbserver.py
+++ b/fbserver.py
@@ -27,6 +27,8 @@ from SocketServer import ThreadingMixIn, TCPServer, BaseServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
from OpenSSL import SSL
+REPORT_INFO = 'report'
+
config = ConfigParser()
script_path = os.path.abspath(__file__)
config_path = os.path.join(os.path.dirname(script_path), 'config.ini')
@@ -67,13 +69,25 @@ class RequestHandler(SimpleHTTPRequestHandler):
try:
tar = tarfile.open(fileobj=StringIO(tar_content[0]), mode='r:gz')
- unique_path = self._unique_path()
- tar.extractall(path=unique_path)
+ self._extract_report(tar)
self._reply(200, 'Report was accepted')
- except Exception:
- logging.exception('Cannot process request')
+ except Exception, e:
+ logging.exception('Cannot process request: %s' % str(e))
self._reply(403, 'Cannot process request')
+ def _extract_report(self, tar):
+ # XXX this hack is necessary so the mailer script won't
+ # send this report incomplete.
+
+ report_files = tar.getnames()
+ report_files.remove(REPORT_INFO)
+ unique_path = self._unique_path()
+
+ for report_file in report_files:
+ tar.extract(report_file, unique_path)
+
+ tar.extract(REPORT_INFO, unique_path)
+
def log_message(self, format, *args):
timestamp = self.log_date_time_string()
client_addr = self.address_string()