[tor-commits] [oonib/master] Add report_id to filepath

art at torproject.org art at torproject.org
Mon May 9 17:57:02 UTC 2016


commit 8de4e05f7c2b64e2944d5a97dcdc98dfe017ca16
Author: Arturo Filastò <arturo at filasto.net>
Date:   Fri Feb 5 20:49:11 2016 +0100

    Add report_id to filepath
---
 oonib/report/handlers.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/oonib/report/handlers.py b/oonib/report/handlers.py
index 30d66c6..b27a943 100644
--- a/oonib/report/handlers.py
+++ b/oonib/report/handlers.py
@@ -16,7 +16,8 @@ from oonib import randomStr, otime, log, json_dumps
 from oonib.config import config
 
 
-def report_file_name(archive_dir, report_details):
+def report_file_name(archive_dir, report_details,
+                     report_id='no_report_id'):
     timestamp = datetime.fromtimestamp(report_details['start_time'])
     if report_details['format'] == 'json':
         ext = 'json'
@@ -34,9 +35,10 @@ def report_file_name(archive_dir, report_details):
         hour=timestamp.strftime("%H"),
         minute=timestamp.strftime("%M"),
         second=timestamp.strftime("%S"),
-        ext=ext
+        ext=ext,
+        report_id=report_id
     )
-    report_file_template = "{iso8601_timestamp}-{test_name}-{probe_asn}-{probe_cc}-probe-0.2.0.{ext}"
+    report_file_template = "{iso8601_timestamp}-{test_name}-{report_id}-{probe_asn}-{probe_cc}-probe-0.2.0.{ext}"
     if config.main.report_file_template:
         report_file_template = config.main.report_file_template
     dst_filename = os.path.join(archive_dir, report_file_template.format(**keys))
@@ -90,8 +92,9 @@ class Report(object):
         except IOError:
             raise e.ReportNotFound
 
-        dst_filename = report_file_name(self.archive_dir,
-                                        self.report_details)
+        dst_filename = report_file_name(archive_dir=self.archive_dir,
+                                        report_details=self.report_details,
+                                        report_id=self.report_id)
         shutil.move(report_filename, dst_filename)
 
         if not self.delayed_call.called:





More information about the tor-commits mailing list