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

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



commit 83a6da92f2a119d825db0daf23f81eb7e8c98ae4
Author: Arturo Filastò <hellais@xxxxxxxxxxxxxx>
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):
         """

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