Hi,
Am Freitag, 17. September 2021, 15:18:36 CEST schrieb
stuartp...@gmail.com:
>
> Python-ICAT raises an exception when I try to create the configuration
> object*. I think it is trying to read the commandline options and finding
> the Jupyter script's options not python-icat options.
Yes, that seem to be the issue here. The icat.config module takes
configuration from command line arguments, environment variables, and
configuration files. The command line arguments are taken from
sys.argv by default. In your case, these seem to be the command line
arguments from the Jupyter script, which do not make much sense to
icat.config.
> Is there a way to create a config object from a config file without
> also reading the commandline options?
Yes, this default can be overridden using the 'args' keyword argument
in Config().
> #------------------------
> import icat.config
>
> config = icat.config.Config()
> client, conf = config.getconfig()
> #--------------------------
You may use the following to pretend not having any command line
arguments:
| config = icat.config.Config(args=())
| client, conf = config.getconfig()
Or you may use that to inject some configuration from your script:
E.g. set the config section to read:
| cfgsection = 'isis'
| config = icat.config.Config(args=('-s', cfgsection))
| client, conf = config.getconfig()
or set username and password:
| cfgsection = 'isis'
| user = 'jdoe'
| pw = 'secret'
| config = icat.config.Config(args=('-s', cfgsection, '-u', user, '-p', pw))
| client, conf = config.getconfig()
Best regards,
Rolf
--
Rolf Krahl <
rolf....@helmholtz-berlin.de>
Helmholtz-Zentrum Berlin für Materialien und Energie (HZB)
Albert-Einstein-Str. 15, 12489 Berlin
Tel.:
+49 30 8062 12122