Added in check for if output is defined. Also attempting fixing code smells with variable replacement

This commit is contained in:
ProDigySML
2019-01-31 23:09:26 -08:00
parent f0922624fe
commit 3a8880bf03

View File

@@ -59,6 +59,17 @@ class InputHelper(object):
return ips
@staticmethod
def _replace_variable_for_commands(commands, variable, replacements):
tmp_commands = set()
for replacement in replacements:
for command in commands:
tmp_commands.add(str(command).replace(variable, command))
return tmp_commands
@staticmethod
def process_commands(arguments):
commands = set()
@@ -70,6 +81,7 @@ class InputHelper(object):
output = OutputHelper(arguments)
# checking for whether output is writable and whether it exists
if arguments.output:
if not access(arguments.output, W_OK):
raise Exception("Directory provided isn't writable")
@@ -155,6 +167,9 @@ class InputHelper(object):
for command in arguments.command_list:
commands.add(command.strip())
if arguments.port:
print(InputHelper._replace_variable_for_commands(commands, "__port__", ports))
# expand commands to all known targets
for target in targets:
# replace flags