mirror of
https://github.com/codingo/Interlace.git
synced 2025-12-17 06:44:23 +01:00
Added in suppression when --silent is used
This commit is contained in:
@@ -36,6 +36,7 @@ def main():
|
||||
arguments.timeout,
|
||||
output,
|
||||
arguments.sober,
|
||||
silent=arguments.silent,
|
||||
)
|
||||
pool.run()
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class InputHelper(object):
|
||||
return [port_type]
|
||||
|
||||
@staticmethod
|
||||
def _pre_process_commands(command_list, task_name=None, is_global_task=True):
|
||||
def _pre_process_commands(command_list, task_name=None, is_global_task=True, silent=False):
|
||||
"""
|
||||
:param command_list:
|
||||
:param task_name: all tasks have 'scope' and all scopes have unique names, global scope defaults None
|
||||
@@ -85,7 +85,7 @@ class InputHelper(object):
|
||||
if task_name and task_name == new_task_name:
|
||||
return task_block
|
||||
# otherwise pre-process all the commands in this new `new_task_name` block
|
||||
tasks = InputHelper._pre_process_commands(command_list, new_task_name, False)
|
||||
tasks = InputHelper._pre_process_commands(command_list, new_task_name, False, silent)
|
||||
if blocker:
|
||||
for task in tasks:
|
||||
task.wait_for(task_block)
|
||||
@@ -99,7 +99,7 @@ class InputHelper(object):
|
||||
if command == '_blocker_':
|
||||
blocker = sibling
|
||||
continue
|
||||
task = Task(command)
|
||||
task = Task(command, silent)
|
||||
# if we're in the global scope and there was a previous _blocker_ encountered, we wait for the last
|
||||
# child of the block
|
||||
if is_global_task and blocker:
|
||||
@@ -270,9 +270,9 @@ class InputHelper(object):
|
||||
|
||||
tasks = list()
|
||||
if arguments.command:
|
||||
tasks.append(Task(arguments.command.rstrip('\n')))
|
||||
tasks.append(Task(arguments.command.rstrip('\n'), arguments.silent))
|
||||
else:
|
||||
tasks = InputHelper._pre_process_commands(arguments.command_list)
|
||||
tasks = InputHelper._pre_process_commands(arguments.command_list, silent=arguments.silent)
|
||||
|
||||
if arguments.proto:
|
||||
protocols = arguments.proto.split(",")
|
||||
|
||||
@@ -12,10 +12,11 @@ else:
|
||||
shell = None
|
||||
|
||||
class Task(object):
|
||||
def __init__(self, command):
|
||||
def __init__(self, command, silent=False):
|
||||
self.task = command
|
||||
self.self_lock = None
|
||||
self.sibling_locks = []
|
||||
self.silent = silent
|
||||
|
||||
def __cmp__(self, other):
|
||||
return self.name() == other.name()
|
||||
@@ -24,7 +25,7 @@ class Task(object):
|
||||
return self.task.__hash__()
|
||||
|
||||
def clone(self):
|
||||
new_task = Task(self.task)
|
||||
new_task = Task(self.task, self.silent)
|
||||
new_task.self_lock = self.self_lock
|
||||
new_task.sibling_locks = self.sibling_locks
|
||||
return new_task
|
||||
@@ -53,11 +54,20 @@ class Task(object):
|
||||
return self.self_lock
|
||||
|
||||
def _run_task(self, t=False):
|
||||
s = subprocess.Popen(self.task, shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
encoding="utf-8",
|
||||
executable=shell)
|
||||
out, _ = s.communicate()
|
||||
if self.silent:
|
||||
s = subprocess.Popen(self.task, shell=True,
|
||||
stdout=subprocess.DEVNULL,
|
||||
encoding="utf-8",
|
||||
executable=shell)
|
||||
out, _ = s.communicate()
|
||||
|
||||
return
|
||||
else:
|
||||
s = subprocess.Popen(self.task, shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
encoding="utf-8",
|
||||
executable=shell)
|
||||
out, _ = s.communicate()
|
||||
|
||||
if out != "":
|
||||
if t:
|
||||
@@ -89,7 +99,7 @@ class Worker(object):
|
||||
|
||||
|
||||
class Pool(object):
|
||||
def __init__(self, max_workers, task_queue, timeout, output, progress_bar):
|
||||
def __init__(self, max_workers, task_queue, timeout, output, progress_bar, silent=False):
|
||||
|
||||
# convert stdin input to integer
|
||||
max_workers = int(max_workers)
|
||||
@@ -109,7 +119,7 @@ class Pool(object):
|
||||
self.output = output
|
||||
self.max_workers = min(tasks_count, max_workers)
|
||||
|
||||
if not progress_bar:
|
||||
if not progress_bar and not silent:
|
||||
self.tqdm = tqdm(total=tasks_count)
|
||||
else:
|
||||
self.tqdm = True
|
||||
|
||||
Reference in New Issue
Block a user