I have a python script which has been packaged up as a command line script (dbtoyaml.py in Pyrseas since you ask).
I am running another python script from which I want to call this script. Is there no way to import the module and artificially populate the required arguments from my second script to avoid changing any of the pyrseas code at all?
from pyrseas import dbtoyaml
-- My initial script, which also takes arguments
dbtoyaml.main(['-m','-H MYHOSTNAME' .... other options])
Hasn't yet worked for me.
I get a strange error:
usage: checkSchemaChanges.py [-h] [-H HOST] [-p PORT] [-U USERNAME] [-W]
[-c CONFIG] [-r REPOSITORY] [-o OUTPUT]
[--version] [-m] [-O] [-x] [-n SCHEMA]
[-N SCHEMA] [-t TABLE] [-T TABLE]
dbname
checkSchemaChanges.py: error: unrecognized arguments: MYHOSTNAME mydatabaseuser
Which is a mixture of my new script (checkSchemaChanges.py, and MYHOSTNAME and mydatabaseuser at the bottom) and the parameters from dbtoyaml, which are all correct.
Could it be the double set of parameters which is confusing argparse?