mirror of
https://github.com/codingo/Interlace.git
synced 2025-12-17 23:04:24 +01:00
Cleaned up debug prints
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from Interlace.lib.core.input import InputParser, InputHelper
|
from Interlace.lib.core.input import InputParser, InputHelper
|
||||||
from Interlace.lib.core.output import OutputHelper, Level
|
from Interlace.lib.core.output import OutputHelper, Level
|
||||||
from Interlace.lib.threader import Pool
|
from Interlace.lib.threader import Pool
|
||||||
@@ -14,10 +16,7 @@ def build_queue(arguments, output):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = InputParser()
|
parser = InputParser()
|
||||||
args = ["-cL", "C:\\Users\\user\\Documents\\PythonProjects\\Interlace\\foo.test",
|
arguments = parser.parse(sys.argv[1:])
|
||||||
"-tL", "C:\\Users\\user\\Documents\\PythonProjects\\Interlace\\bar.test"]
|
|
||||||
arguments = parser.parse(args)
|
|
||||||
# arguments = parser.parse(sys.argv[1:])
|
|
||||||
|
|
||||||
output = OutputHelper(arguments)
|
output = OutputHelper(arguments)
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,12 @@ class InputHelper(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _pre_process_commands(command_list, task_name, is_global_task=True):
|
def _pre_process_commands(command_list, task_name, is_global_task=True):
|
||||||
|
"""
|
||||||
|
:param command_list:
|
||||||
|
:param task_name: all tasks have 'scope' and all scopes have unique names, global scope defaults ''
|
||||||
|
:param is_global_task: when True, signifies that all global tasks are meant to be run concurrently
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
task_block = []
|
task_block = []
|
||||||
sibling = None
|
sibling = None
|
||||||
global_task = None
|
global_task = None
|
||||||
@@ -83,21 +89,29 @@ class InputHelper(object):
|
|||||||
command = str(command).strip()
|
command = str(command).strip()
|
||||||
if not command:
|
if not command:
|
||||||
continue
|
continue
|
||||||
|
# the start or end of a command block
|
||||||
if command.startswith('_block:') and command.endswith('_'):
|
if command.startswith('_block:') and command.endswith('_'):
|
||||||
new_task_name = command.split('_block:')[1][:-1].strip()
|
new_task_name = command.split('_block:')[1][:-1].strip()
|
||||||
|
# if this is the end of a block, then we're done
|
||||||
if task_name == new_task_name:
|
if task_name == new_task_name:
|
||||||
return task_block
|
return task_block
|
||||||
|
# otherwise pre-process all the commands in this new `new_task_name` block
|
||||||
for task in InputHelper._pre_process_commands(command_list, new_task_name, False):
|
for task in InputHelper._pre_process_commands(command_list, new_task_name, False):
|
||||||
task_block.append(task)
|
task_block.append(task)
|
||||||
sibling = task
|
sibling = task
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
# if a blocker is encountered, all commands following the blocker must wait until the last
|
||||||
|
# command in the block is executed. All block commands are synchronous
|
||||||
if command == '_blocker_':
|
if command == '_blocker_':
|
||||||
global_task = sibling
|
global_task = sibling
|
||||||
continue
|
continue
|
||||||
task = Task(command)
|
task = Task(command)
|
||||||
|
# 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 global_task:
|
if is_global_task and global_task:
|
||||||
task.wait_for(global_task.get_lock())
|
task.wait_for(global_task.get_lock())
|
||||||
|
# all but the first command in a block scope wait for its predecessor
|
||||||
elif sibling and not is_global_task:
|
elif sibling and not is_global_task:
|
||||||
task.wait_for(sibling.get_lock())
|
task.wait_for(sibling.get_lock())
|
||||||
task_block.append(task)
|
task_block.append(task)
|
||||||
@@ -144,7 +158,6 @@ class InputHelper(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _replace_variable_array(commands, variable, replacement):
|
def _replace_variable_array(commands, variable, replacement):
|
||||||
# TODO
|
|
||||||
if variable not in sample(commands, 1)[0]:
|
if variable not in sample(commands, 1)[0]:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -173,8 +186,8 @@ class InputHelper(object):
|
|||||||
ranges.add(arguments.target)
|
ranges.add(arguments.target)
|
||||||
else:
|
else:
|
||||||
target_file = arguments.target_list
|
target_file = arguments.target_list
|
||||||
# if not sys.stdin.isatty():
|
if not sys.stdin.isatty():
|
||||||
# target_file = sys.stdin
|
target_file = sys.stdin
|
||||||
ranges.update([target.strip() for target in target_file if target.strip()])
|
ranges.update([target.strip() for target in target_file if target.strip()])
|
||||||
|
|
||||||
# process exclusions first
|
# process exclusions first
|
||||||
|
|||||||
Reference in New Issue
Block a user