When I write a command line script, I often design my script, so this is possible. The key is to parse the arguments separately from the main function.
For example, the main function might look like this:
def main(**kwargs):
Then, in another place in the module, I will configure the arg parser, parse the arguments and pass the result to the main script:
def run(): parser = ...
Thus, if someone wants to call a script from Python, they can do it (this also simplifies testing):
import somescript somescript.main(option='value', option2='value2')
Unfortunately, it seems that the authors of the script you used did nothing of the sort. As pointed out in another answer, you can overwrite sys.argv and then import the script. Although this may seem like a hacker, it should be less resource intensive than opening a new process and invoking a command separately.
source share