Doing data validation with a Debian package is not something I have figured
out. Maybe Matthew has.

You can't simply flag an error and ask the user to try again because
db_input, the mechanism for adding things to the debconf database, may not
be in an interactive session.

If you do a pip install and use weectl station create, it will validate
your input unless you specify --no-prompt.

On Sun, Mar 26, 2023 at 6:14 PM Ernest Jillson <[email protected]> wrote:

> I decided to give this a whirl on a development pi zero I have. I made a
> typo in the setup program when selecting my elevation and units. I put
> "feet" instead of "foot". It didn't end well :).
>
> It might be worth either allowing foot/feet and/or mooter/meter (ok, I
> made that up. meter/meters) so dumbos like me can succeed :).
>
> Would it be possible to check the input and give an error message and a
> chance to retry instead of just failing?
>
> Again, it was my dumbassery that lead to the issue. Just thinking ahead
> for others that could potentially make the same mistake that I did.  Here
> is the error message:
>
> Unpacking python3-weewx (5.0.0a25-1) ...
> Setting up python3-usb (1.0.2-2) ...
> Setting up python3-cheetah (3.2.6-1+b1) ...
> Setting up python3-configobj (5.0.6-4) ...
> Setting up python3-weewx (5.0.0a25-1) ...
> The configuration file /etc/weewx/weewx.conf will be used.
> Processing configuration file /etc/weewx/weewx.conf.
> Traceback (most recent call last):
>   File "/usr/share/weewx/weectl.py", line 53, in <module>
>     main()
>   File "/usr/share/weewx/weectl.py", line 45, in main
>     namespace.func(namespace)
>   File "/usr/share/weewx/weectllib/parse_station.py", line 233, in
> reconfigure_s                                 tation
>     weecfg.station_config.station_reconfigure(config_path=namespace.config,
>   File "/usr/share/weewx/weecfg/station_config.py", line 102, in
> station_reconfi                                 gure
>     config_config(config_path, config_dict, dry_run=dry_run, *args,
> **kwargs)
>   File "/usr/share/weewx/weecfg/station_config.py", line 131, in
> config_config
>     config_altitude(config_dict, altitude=altitude, no_prompt=no_prompt)
>   File "/usr/share/weewx/weecfg/station_config.py", line 181, in
> config_altitude
>     raise ValueError(f"Unknown altitude unit {unit}")
> ValueError: Unknown altitude unit feet
> dpkg: error processing package python3-weewx (--configure):
>  installed python3-weewx package post-installation script subprocess
> returned er                                 ror exit status 1
> Processing triggers for man-db (2.9.4-2) ...
> Errors were encountered while processing:
>  python3-weewx
> E: Sub-process /usr/bin/dpkg returned an error code (1)
>
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-development/726e92f2-012d-412a-91d2-bdba93ae1fd9n%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-development/726e92f2-012d-412a-91d2-bdba93ae1fd9n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/CAPq0zECasgKudnD3x5waVR6KoeguvSzEMU1fAJ39GX_Us1c3Jw%40mail.gmail.com.

Reply via email to