1111else :
1212 shell = None
1313
14+
1415class Task (object ):
15- def __init__ (self , command ):
16+ def __init__ (self , command , silent = False ):
1617 self .task = command
1718 self .self_lock = None
1819 self .sibling_locks = []
20+ self .silent = silent
1921
2022 def __cmp__ (self , other ):
2123 return self .name () == other .name ()
@@ -24,7 +26,7 @@ def __hash__(self):
2426 return self .task .__hash__ ()
2527
2628 def clone (self ):
27- new_task = Task (self .task )
29+ new_task = Task (self .task , self . silent )
2830 new_task .self_lock = self .self_lock
2931 new_task .sibling_locks = self .sibling_locks
3032 return new_task
@@ -53,11 +55,20 @@ def get_lock(self):
5355 return self .self_lock
5456
5557 def _run_task (self , t = False ):
56- s = subprocess .Popen (self .task , shell = True ,
57- stdout = subprocess .PIPE ,
58- encoding = "utf-8" ,
59- executable = shell )
60- out , _ = s .communicate ()
58+ if self .silent :
59+ s = subprocess .Popen (self .task , shell = True ,
60+ stdout = subprocess .DEVNULL ,
61+ encoding = "utf-8" ,
62+ executable = shell )
63+ out , _ = s .communicate ()
64+
65+ return
66+ else :
67+ s = subprocess .Popen (self .task , shell = True ,
68+ stdout = subprocess .PIPE ,
69+ encoding = "utf-8" ,
70+ executable = shell )
71+ out , _ = s .communicate ()
6172
6273 if out != "" :
6374 if t :
@@ -89,7 +100,7 @@ def __call__(self):
89100
90101
91102class Pool (object ):
92- def __init__ (self , max_workers , task_queue , timeout , output , progress_bar ):
103+ def __init__ (self , max_workers , task_queue , timeout , output , progress_bar , silent = False ):
93104
94105 # convert stdin input to integer
95106 max_workers = int (max_workers )
@@ -109,7 +120,7 @@ def __init__(self, max_workers, task_queue, timeout, output, progress_bar):
109120 self .output = output
110121 self .max_workers = min (tasks_count , max_workers )
111122
112- if not progress_bar :
123+ if not progress_bar and not silent :
113124 self .tqdm = tqdm (total = tasks_count )
114125 else :
115126 self .tqdm = True
0 commit comments