aboutsummaryrefslogtreecommitdiffstats
path: root/tools/indexcap.py
diff options
context:
space:
mode:
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-25 17:03:44 +0000
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-25 17:03:44 +0000
commit2216640d8cfe8f0a42d25e19d5c73a0f1e32110d (patch)
tree4131476e597c0c3911ef354429b88609973fc3de /tools/indexcap.py
parent50b7a98610acb77cbeb3f84531129ad8898b1c7f (diff)
* Handle some error path more gracefully
* Add more verbose output svn path=/trunk/; revision=30147
Diffstat (limited to 'tools/indexcap.py')
-rw-r--r--tools/indexcap.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/tools/indexcap.py b/tools/indexcap.py
index 43a1a0fdc7..4ecc7cc08a 100644
--- a/tools/indexcap.py
+++ b/tools/indexcap.py
@@ -40,6 +40,7 @@ def process_capture_file(args):
(stdout, stderr) = p.communicate()
if p.returncode != 0:
print "SKIP:", file
+ return (None, None)
else:
print "PROCESSED:", file
@@ -77,17 +78,16 @@ def main():
exit(1)
index_file_name = args.pop(0)
- index_file = open(index_file_name, "r")
- print "index_file:", index_file.name, "[OPENED]",
try:
+ index_file = open(index_file_name, "r")
+ print "index file:", index_file.name, "[OPENED]",
cap_hash = pickle.load(index_file)
- print "[REUSING]"
+ index_file.close()
+ print len(cap_hash), "files"
except IOError:
+ print "index file:", index_file_name, "[NEW]"
cap_hash = {}
- print "[NEW]"
- finally:
- index_file.close()
paths = args
cap_files = []
@@ -100,15 +100,16 @@ def main():
cap_files.append(path)
cap_files.sort()
+ print len(cap_files), "total files,",
cap_files = cap_files[:options.max_files]
+ print len(cap_files), "indexable files"
pool = Pool(options.num_procs)
proc_args = [(tshark, file) for file in cap_files]
results = pool.map(process_capture_file, proc_args)
- cap_hash = dict(results)
+ cap_hash.update(dict(results))
- print cap_hash
- index_file = open(index_file_name, "a")
+ index_file = open(index_file_name, "w")
pickle.dump(cap_hash, index_file)
index_file.close()