Testing implementation

This commit is contained in:
Joshua Ogunyinka
2019-08-16 03:37:50 +01:00
parent ee47cac4ab
commit ab34aca3b2
6 changed files with 40 additions and 30 deletions

12
.github/FUNDING.yml vendored
View File

@@ -1,12 +0,0 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: PayPal.Me/codingo

1
.gitignore vendored
View File

@@ -23,6 +23,7 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
*.test
MANIFEST
# PyInstaller

View File

@@ -31,7 +31,7 @@ def main():
output.print_banner()
pool = Pool(arguments.threads, build_queue(arguments, output), arguments.timeout, output, arguments.sober)
pool.run()
# pool.run()
if __name__ == "__main__":

View File

@@ -121,12 +121,23 @@ class InputHelper(object):
@staticmethod
def _replace_variable_with_commands(commands, variable, replacements):
for replacement in replacements:
data = set()
for command in commands:
if isinstance(command, TaskBlock):
InputHelper._replace_variable_with_commands(command, variable, replacements)
else:
command.replace(variable, str(replacement))
is_task_block = isinstance(command, TaskBlock)
for replacement in replacements:
if not is_task_block and command.name().find(variable) != -1:
new_task = command.clone()
new_task.replace(variable, replacement)
data.add(new_task)
elif not is_task_block and command not in data:
data.add(command)
elif is_task_block:
new_task_block = TaskBlock(command.name())
result = InputHelper._replace_variable_with_commands(command.get_tasks(), variable, replacements)
for r in result:
new_task_block.add_task(r)
data.add(new_task_block)
return set(data)
@staticmethod
def _replace_variable_array(commands, variable, replacement):
@@ -166,14 +177,17 @@ class InputHelper(object):
target_file = arguments.target_list
if not sys.stdin.isatty():
target_file = sys.stdin
ranges.update([target for target in target_file if target.strip()])
ranges.update([target.strip() for target in target_file if target.strip()])
# process exclusions first
if arguments.exclusions:
exclusions_ranges.add(arguments.exclusions)
else:
if arguments.exclusions_list:
exclusions_ranges.update([exclusion for exclusion in arguments.exclusions_list if exclusion.strip()])
for exclusion in arguments.exclusions_list:
exclusion = exclusion.strip()
if exclusion:
exclusions.add(exclusion)
# removing elements that may have spaces (helpful for easily processing comma notation)
InputHelper._pre_process_hosts(ranges, targets, arguments)
@@ -191,24 +205,24 @@ class InputHelper(object):
tasks = InputHelper._pre_process_commands(arguments.command_list, '')
commands.update(tasks.get_tasks())
InputHelper._replace_variable_with_commands(commands, "_target_", targets)
InputHelper._replace_variable_with_commands(commands, "_host_", targets)
commands = InputHelper._replace_variable_with_commands(commands, "_target_", targets)
commands = InputHelper._replace_variable_with_commands(commands, "_host_", targets)
if arguments.port:
InputHelper._replace_variable_with_commands(commands, "_port_", ports)
commands = InputHelper._replace_variable_with_commands(commands, "_port_", ports)
if arguments.realport:
InputHelper._replace_variable_with_commands(commands, "_realport_", real_ports)
commands = InputHelper._replace_variable_with_commands(commands, "_realport_", real_ports)
if arguments.output:
InputHelper._replace_variable_with_commands(commands, "_output_", [arguments.output])
commands = InputHelper._replace_variable_with_commands(commands, "_output_", [arguments.output])
if arguments.proto:
if "," in arguments.proto:
protocols = arguments.proto.split(",")
else:
protocols = arguments.proto
InputHelper._replace_variable_with_commands(commands, "_proto_", protocols)
commands = InputHelper._replace_variable_with_commands(commands, "_proto_", protocols)
# process proxies
if arguments.proxy_list:

View File

@@ -11,9 +11,18 @@ class Task(object):
self._lock = None
self._waiting_for_task = False
def __cmp__(self, other):
return self.name() == other.name()
def __hash__(self):
return self.task.__hash__()
def clone(self):
new_task = Task(self.task)
new_task._lock = self._lock
new_task._waiting_for_task = self._waiting_for_task
return new_task
def replace(self, old, new):
self.task = self.task.replace(old, new)

View File

@@ -10,7 +10,7 @@ def dependencies(imported_file):
with open("README.md") as file:
num_installed = False
num_installed = True
try:
import numpy
num_installed = True
@@ -35,7 +35,5 @@ with open("README.md") as file:
]
},
install_requires=dependencies('requirements.txt'),
setup_requires=['pytest-runner',
'' if num_installed else 'numpy==1.16.0'],
tests_require=dependencies('test-requirements.txt'),
include_package_data=True)