Sven van den Boogaart
Sven van den Boogaart

Reputation: 12327

python run script from script with arguments

For a python 2.7 project I want to read robotframework output.xml to a sqlite database, I found the package DbBot which does exactly that. However i want to run it from a script instead of from the command line. The command I use on the command line is:

python -m dbbot.run -k output.xml

which does exactly what I want (generate a sqlite database with the right data). I tried the following:

modl = imp.load_source('modulename', 'C:/Python27/Lib/site-packages/dbbot/run.py')
someRunner = modl.DbBot()

which returns:

Run.py: error: at least one input file is required

which I understand as i did not add a file src like i did in the terminal by adding output.xml

I cant add output.xml as paramter to modl.DbBot() as it takes no parameters. How does one pass the -k flag and the output.xml (file src) from withing a script?

Upvotes: 0

Views: 186

Answers (1)

Elis Byberi
Elis Byberi

Reputation: 1452

Use subprocess package:

import subprocess

# run separate process
subprocess.call(['python', '-m', 'dbbot.run', '-k', 'output.xml'], shell=False)

dbbot.run is not coded to run from inside another script.

Upvotes: 1

Related Questions