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

[tor-commits] [ooni-probe/master] This is a possible fix for https://trac.torproject.org/projects/tor/ticket/7664



commit 2becc29d40f837732f5a62205116cf6b3f74f014
Author: Flavio Amieiro <amieiro.flavio@xxxxxxxxx>
Date:   Fri Dec 7 17:58:47 2012 -0200

    This is a possible fix for https://trac.torproject.org/projects/tor/ticket/7664
    
    In my tests, running a deck with this patch gave the desired output (one report
    by test). This doesn't mean this fix is the best one, and I don't feel
    confortable enough with the codebase to even know if this is the right
    direction.
    
    The underlying problem seems to be that this code is using a global variable
    "reports" (imported from config.py) to store the report filename, and this is
    getting overwritten for each test that's added. Because of that, the last
    reportfile described in the deck (for before_i_commit.deck it was
    http_host.yamloo) was beeing used every time. Since the reporter saved a backup
    of the file if it already existed, it saved the output of the last test (for
    before_i_commit.deck it was dns_tamper) in and .old file.
---
 ooni/reporter.py |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/ooni/reporter.py b/ooni/reporter.py
index 12e4dc8..f365a6a 100644
--- a/ooni/reporter.py
+++ b/ooni/reporter.py
@@ -194,13 +194,13 @@ class YAMLReporter(OReporter):
     These are useful functions for reporting to YAML format.
     """
     def __init__(self, cmd_line_options):
-        if os.path.exists(config.reports.yamloo):
-            log.msg("Report already exists with filename %s" % config.reports.yamloo)
-            log.msg("Renaming it to %s" % config.reports.yamloo+'.old')
-            os.rename(config.reports.yamloo, config.reports.yamloo+'.old')
+        if os.path.exists(cmd_line_options['reportfile']):
+            log.msg("Report already exists with filename %s" % cmd_line_options['reportfile'])
+            log.msg("Renaming it to %s" % cmd_line_options['reportfile']+'.old')
+            os.rename(cmd_line_options['reportfile'], cmd_line_options['reportfile']+'.old')
 
-        log.debug("Creating %s" % config.reports.yamloo)
-        self._stream = open(config.reports.yamloo, 'w+')
+        log.debug("Creating %s" % cmd_line_options['reportfile'])
+        self._stream = open(cmd_line_options['reportfile'], 'w+')
         OReporter.__init__(self, cmd_line_options)
 
     def _writeln(self, line):



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