]> arthur.barton.de Git - bup.git/blobdiff - cmd/bloom-cmd.py
Don't import * from helpers
[bup.git] / cmd / bloom-cmd.py
index 51e594bdf11784c24c63ac60714b7f9b85d0017b..f968fa02e398fab2b55e85a62af30deb9435e7aa 100755 (executable)
@@ -1,7 +1,15 @@
-#!/usr/bin/env python
-import sys, glob, tempfile
+#!/bin/sh
+"""": # -*-python-*-
+bup_python="$(dirname "$0")/bup-python" || exit $?
+exec "$bup_python" "$0" ${1+"$@"}
+"""
+# end of bup preamble
+
+import glob, os, sys, tempfile
+
 from bup import options, git, bloom
-from bup.helpers import *
+from bup.helpers import (debug1, handle_ctrl_c, log, progress, qprogress,
+                         saved_errors)
 
 optspec = """
 bup bloom [options...]
@@ -109,8 +117,7 @@ def do_bloom(path, outfilename):
     tfname = None
     if b is None:
         tfname = os.path.join(path, 'bup.tmp.bloom')
-        tf = open(tfname, 'w+')
-        b = bloom.create(tfname, f=tf, expected=add_count, k=opt.k)
+        b = bloom.create(tfname, expected=add_count, k=opt.k)
     count = 0
     icount = 0
     for name in add:
@@ -121,6 +128,10 @@ def do_bloom(path, outfilename):
         count += 1
         icount += len(ix)
 
+    # Currently, there's an open file object for tfname inside b.
+    # Make sure it's closed before rename.
+    b.close()
+
     if tfname:
         os.rename(tfname, outfilename)