[Pkg-bazaar-commits] ./bzr/unstable r403: - Don't give an error if the trace file can't be opened

Martin Pool mbp at sourcefrog.net
Fri Apr 10 07:52:11 UTC 2009


------------------------------------------------------------
revno: 403
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-05-09 13:03:55 +1000
message:
  - Don't give an error if the trace file can't be opened
modified:
  bzrlib/trace.py
-------------- next part --------------
=== modified file 'bzrlib/trace.py'
--- a/bzrlib/trace.py	2005-05-09 00:00:23 +0000
+++ b/bzrlib/trace.py	2005-05-09 03:03:55 +0000
@@ -106,23 +106,25 @@
     _rollover_trace_maybe(trace_fname)
 
     # buffering=1 means line buffered
-    _tracefile = codecs.open(trace_fname, 'at', 'utf8', buffering=1)
-    t = _tracefile
-
-    if os.fstat(t.fileno())[stat.ST_SIZE] == 0:
-        t.write("\nthis is a debug log for diagnosing/reporting problems in bzr\n")
-        t.write("you can delete or truncate this file, or include sections in\n")
-        t.write("bug reports to bazaar-ng at lists.canonical.com\n\n")
-
-    import bzrlib
-    _write_trace('bzr %s invoked on python %s (%s)'
-                 % (bzrlib.__version__,
-                    '.'.join(map(str, sys.version_info)),
-                    sys.platform))
-
-    _write_trace('  arguments: %r' % argv)
-    _write_trace('  working dir: ' + os.getcwdu())
-
+    try:
+        _tracefile = codecs.open(trace_fname, 'at', 'utf8', buffering=1)
+        t = _tracefile
+
+        if os.fstat(t.fileno())[stat.ST_SIZE] == 0:
+            t.write("\nthis is a debug log for diagnosing/reporting problems in bzr\n")
+            t.write("you can delete or truncate this file, or include sections in\n")
+            t.write("bug reports to bazaar-ng at lists.canonical.com\n\n")
+
+        import bzrlib
+        _write_trace('bzr %s invoked on python %s (%s)'
+                     % (bzrlib.__version__,
+                        '.'.join(map(str, sys.version_info)),
+                        sys.platform))
+
+        _write_trace('  arguments: %r' % argv)
+        _write_trace('  working dir: ' + os.getcwdu())
+    except IOError, e:
+        warning("failed to open trace file: %s" % (e))
 
 def close_trace():
     times = os.times()



More information about the Pkg-bazaar-commits mailing list