[tor-commits] [ooni-probe/master] Refactor report writing function to get rid of bug.

art at torproject.org art at torproject.org
Mon Jun 25 17:16:41 UTC 2012


commit 83a6da92f2a119d825db0daf23f81eb7e8c98ae4
Author: Arturo Filastò <hellais at torproject.org>
Date:   Mon Jun 25 19:15:05 2012 +0200

    Refactor report writing function to get rid of bug.
---
 ooni/plugoo/reports.py |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/ooni/plugoo/reports.py b/ooni/plugoo/reports.py
index 6140294..6d4c90c 100644
--- a/ooni/plugoo/reports.py
+++ b/ooni/plugoo/reports.py
@@ -1,6 +1,8 @@
 import os
 import yaml
 
+from __future__ import with_statement
+
 import itertools
 from ooni import log, date
 
@@ -84,14 +86,8 @@ class Report:
         """
         if not file:
             file = self.file
-        try:
-            f = open(file, mode)
+        with open(file, mode) as f:
             f.write(data)
-        except Exception, e:
-            raise e
-        finally:
-            f.close()
-
 
     def tcp_report(self, data):
         """



More information about the tor-commits mailing list