ARPA-SIMC / arkimaps

generazione mappe meteorologiche da modelli previsionali
GNU General Public License v2.0
0 stars 1 forks source link

can't use stdin in `arkimaps dispatch` #171

Closed brancomat closed 2 months ago

brancomat commented 2 months ago

something has changed between arkimaps 1.19 and 1.20 (current version) in the positional arguments:

v1.19

$ arkimaps dispatch -h
usage: arkimaps dispatch [-h] [-v] [--debug] [--flavours FLAVOURS]
                         [--filter {arkimet|eccodes}] [--grib] [--recipes dir]
                         dir

positional arguments:
  dir                   working directory

optional arguments:
(...)

v1.20

$ arkimaps dispatch -h
usage: arkimaps dispatch [-h] [-v] [--debug] [--recipes dir]
                         [--flavours FLAVOURS] [--filter {arkimet|eccodes}]
                         [--grib]
                         dir input

positional arguments:
  dir                   working directory
  input                 input file to dispatch. Default: stdin

options:
(...)

This broke somehow the stdin input:

$ arki-query --sort=day:timerange --inline 'Reftime:=2024-09-04 09:00; Product : GRIB2,,,,,, ; Level : GRIB2S,,, or GRIB2D,,,,,' http://arkiope.metarpa:8090/dataset/cosmo1ch | arkimaps dispatch 
usage: arkimaps dispatch [-h] [-v] [--debug] [--recipes dir]
 [--flavours FLAVOURS] [--filter {arkimet|eccodes}]
 [--grib]
 dir input
 arkimaps dispatch: error: the following arguments are required: input

Even using -:

$ arki-query --sort=day:timerange --inline 'Reftime:=2024-09-04 09:00; Product : GRIB2,,,,,, ; Level : GRIB2S,,, or GRIB2D,,,,,' http://arkiope.metarpa:8090/dataset/cosmo1ch | arkimaps dispatch /tmp/d_devel.crontab.salop.mappomatic2.5AkGpq1qkl/dispatch -
 Traceback (most recent call last):
 File "/usr/bin/arkimaps", line 48, in <module>
 main()
 File "/usr/bin/arkimaps", line 39, in main
 res = handler.run()
 ^^^^^^^^^^^^^
 File "/usr/lib/python3.11/site-packages/arkimapslib/cli.py", line 468, in run
 self.kitchen.fill_pantry(path=Path(self.args.input) if self.args.input else None, flavours=self.flavours)
 File "/usr/lib/python3.11/site-packages/arkimapslib/kitchen.py", line 100, in fill_pantry
 self.pantry.fill(path, input_filter=all_inputs)
 File "/usr/lib/python3.11/site-packages/arkimapslib/pantry.py", line 300, in fill
 with self.open_dispatch_input(path=path) as infd:
 File "/usr/lib64/python3.11/contextlib.py", line 137, in __enter__
 return next(self.gen)
 ^^^^^^^^^^^^^^
 File "/usr/lib/python3.11/site-packages/arkimapslib/pantry.py", line 107, in open_dispatch_input
 with path.open("rb") as fd:
 ^^^^^^^^^^^^^^^
 File "/usr/lib64/python3.11/pathlib.py", line 1044, in open
 return io.open(self, mode, buffering, encoding, errors, newline)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 FileNotFoundError: [Errno 2] No such file or directory: '-'
brancomat commented 2 months ago

This was fixed in f54ef2e (thanks @edigiacomo).

The ending hyphen (-) still doesn't work (but I'm not sure it ever did) still giving a FileNotFoundError

I'll leave the issue open assigned to @spanezz for a quick code review on the fix