summaryrefslogtreecommitdiff
path: root/tools/indexcap.py
diff options
context:
space:
mode:
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-25 19:02:32 +0000
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-25 19:02:32 +0000
commit7658f9a43a28c75b10018d53337a7cbe78afed38 (patch)
treeb03234be58cddf0ad5f19e1c0c0f068e83b4bf76 /tools/indexcap.py
parentcbc3d3f772627505d9c695e7a414b91e83915c84 (diff)
downloadwireshark-7658f9a43a28c75b10018d53337a7cbe78afed38.tar.gz
Use apply_async and print out file progress in the parent process
svn path=/trunk/; revision=30152
Diffstat (limited to 'tools/indexcap.py')
-rw-r--r--tools/indexcap.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/indexcap.py b/tools/indexcap.py
index 4b67e7c0b0..f9ff217c7a 100644
--- a/tools/indexcap.py
+++ b/tools/indexcap.py
@@ -33,16 +33,12 @@ import subprocess
import re
import pickle
-def process_capture_file(args):
- tshark, file = args
+def process_capture_file(tshark, file):
cmd = [tshark, "-Tfields", "-e", "frame.protocols", "-r", file]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
if p.returncode != 0:
- print "SKIP:", file
- return (None, None)
- else:
- print "PROCESSED:", file, os.path.getsize(file), "bytes"
+ return None
proto_hash = {}
for line in stdout.splitlines():
@@ -134,9 +130,16 @@ def main():
print "\n"
pool = Pool(options.num_procs)
- proc_args = [(tshark, file) for file in cap_files]
- results = pool.map(process_capture_file, proc_args)
- cap_hash.update(dict(results))
+ results = [pool.apply_async(process_capture_file, [tshark, file]) for file in cap_files]
+ cur_item_num = 0
+ for result in results:
+ cur_item_num += 1
+ file_result = result.get()
+ if file_result is None:
+ continue
+
+ print "PROCESSED [%u/%u] %s %u bytes" % (cur_item_num, options.max_files, file_result[0], os.path.getsize(file_result[0]))
+ cap_hash.update(dict([file_result]))
index_file = open(index_file_name, "w")
pickle.dump(cap_hash, index_file)