mirror of
https://github.com/codingo/Interlace.git
synced 2025-12-18 23:34:19 +01:00
Added in check for if output is defined. Also attempting fixing code smells with variable replacement
This commit is contained in:
@@ -59,6 +59,17 @@ class InputHelper(object):
|
|||||||
|
|
||||||
return ips
|
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
|
@staticmethod
|
||||||
def process_commands(arguments):
|
def process_commands(arguments):
|
||||||
commands = set()
|
commands = set()
|
||||||
@@ -70,6 +81,7 @@ class InputHelper(object):
|
|||||||
output = OutputHelper(arguments)
|
output = OutputHelper(arguments)
|
||||||
|
|
||||||
# checking for whether output is writable and whether it exists
|
# checking for whether output is writable and whether it exists
|
||||||
|
if arguments.output:
|
||||||
if not access(arguments.output, W_OK):
|
if not access(arguments.output, W_OK):
|
||||||
raise Exception("Directory provided isn't writable")
|
raise Exception("Directory provided isn't writable")
|
||||||
|
|
||||||
@@ -155,6 +167,9 @@ class InputHelper(object):
|
|||||||
for command in arguments.command_list:
|
for command in arguments.command_list:
|
||||||
commands.add(command.strip())
|
commands.add(command.strip())
|
||||||
|
|
||||||
|
if arguments.port:
|
||||||
|
print(InputHelper._replace_variable_for_commands(commands, "__port__", ports))
|
||||||
|
|
||||||
# expand commands to all known targets
|
# expand commands to all known targets
|
||||||
for target in targets:
|
for target in targets:
|
||||||
# replace flags
|
# replace flags
|
||||||
|
|||||||
Reference in New Issue
Block a user