[Bug]: MAD-X Wrapper expects all arguments when ran from the command-line
Mael-Le-Garrec opened this issue · comments
Documentation
- Yes
Operating System
Linux
Python Version
3.10.2
Package Version
0.2.3
Bug Description
The main of the script madx_wrapper.py
expects all arguments to exist in order to run from the CLI.
It is though specified that the script can run without some parameters, such as output
.
The problem comes from Path(opt.output)
which throws an exception if None
.
https://github.com/pylhc/omc3/blob/master/omc3/madx_wrapper.py#L71
Steps to Reproduce
python omc3/madx_wrapper.py --file test
Relevant output
Traceback (most recent call last):
File "/home/mlegarre/git/omc3/omc3/madx_wrapper.py", line 203, in <module>
main()
File "/home/mlegarre/.local/lib/python3.10/site-packages/generic_parser/entrypoint_parser.py", line 424, in wrapper
return func(self.parse(*args, **kwargs))
File "/home/mlegarre/git/omc3/omc3/madx_wrapper.py", line 71, in main
output_file=Path(opt.output),
File "/usr/lib/python3.10/pathlib.py", line 958, in __new__
self = cls._from_parts(args)
File "/usr/lib/python3.10/pathlib.py", line 592, in _from_parts
drv, root, parts = self._parse_args(args)
File "/usr/lib/python3.10/pathlib.py", line 576, in _parse_args
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Possible Fix Implementation
Check the type of the parameter before converting to a Path
object
Closed by #364