[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Clean up filenames of generated reports



commit afa72fbc40dddcc1d5ea93003f3dba1aff48e791
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Sun Nov 11 13:09:39 2012 +0100

    Clean up filenames of generated reports
    * They now follow the format $testName_report_$timestamp.yamloo
---
 ooni/config.py  |    9 +++++----
 ooni/oonicli.py |    8 ++++++--
 ooni/runner.py  |    2 +-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/ooni/config.py b/ooni/config.py
index a2ce917..29255c1 100644
--- a/ooni/config.py
+++ b/ooni/config.py
@@ -17,16 +17,17 @@ def get_root_path():
     root = os.path.abspath(root)
     return root
 
-def oreport_filenames():
+def oreport_filenames(file_name):
     """
     returns the filenames for the pcap file and the yamloo report
 
     returns
     yamloo_filename, pcap_filename
     """
-    base_filename = "%s_"+otime.timestamp()+".%s"
-    yamloo_filename = base_filename % ("report", "yamloo")
-    pcap_filename = base_filename % ("packets", "pcap")
+    test_name = '.'.join(file_name.split(".")[:-1])
+    base_filename = "%s_%s_"+otime.timestamp()+".%s"
+    yamloo_filename = base_filename % (test_name, "report", "yamloo")
+    pcap_filename = base_filename % (test_name, "packets", "pcap")
     return yamloo_filename, pcap_filename
 
 config_file = os.path.join(get_root_path(), 'ooniprobe.conf')
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index 25da8c3..9287174 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -93,7 +93,12 @@ def run():
     if cmd_line_options['debug-stacktraces']:
         defer.setDebugging(True)
 
-    yamloo_filename, pcap_filename = config.oreport_filenames()
+    log.start(cmd_line_options['logfile'])
+
+    test_file_name = os.path.basename(cmd_line_options['test'])
+    log.debug("Running script %s" % test_file_name)
+
+    yamloo_filename, pcap_filename = config.oreport_filenames(test_file_name)
 
     if cmd_line_options['reportfile']:
         yamloo_filename = cmd_line_options['reportfile']
@@ -108,7 +113,6 @@ def run():
         log.msg("Renaming it to %s" % pcap_filename+'.old')
         os.rename(pcap_filename, pcap_filename+'.old')
 
-    log.start(cmd_line_options['logfile'])
     classes = runner.findTestClassesFromConfig(cmd_line_options)
     test_cases, options = runner.loadTestsAndOptions(classes, cmd_line_options)
     if config.privacy.includepcap:
diff --git a/ooni/runner.py b/ooni/runner.py
index c6679c0..23ff898 100644
--- a/ooni/runner.py
+++ b/ooni/runner.py
@@ -221,7 +221,7 @@ def runTestCases(test_cases, options,
             log.msg("Could not find inputs!")
             log.msg("options[0] = %s" % first)
             test_inputs = [None]
-
+    
     reportFile = open(yamloo_filename, 'w+')
     oreporter = reporter.YAMLReporter(reportFile)
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits