v4 setup.py removed option --no-prompt

91 views
Skip to first unread message

Vince Skahan

unread,
May 1, 2020, 9:18:47 PM5/1/20
to weewx-development
Looks like the --no-prompt option was removed from setup.py in https://github.com/weewx/weewx/commit/26a3a5a88fd7a8a47bd2a136e71b4f8f706386e7 or near there a month or so ago.

I use this to permit hands-off automation with Vagrant and other scripted installs where I want to default to the Simulator driver with no prompting of questions (which I can't answer of course, it's hands-off DevOps-like automation).

Is there an alternate way to have setup.py install the simulator, or could this option be put back in ?


Tom Keffer

unread,
May 1, 2020, 9:36:24 PM5/1/20
to Vince Skahan, weewx-development
What I use is

echo "hood river\n700,foot\n45\n-125\nmetric\n6\n\n\n" | python ./setup.py install

NB: this worked for V3.x. Version 4 asks the user whether s/he wants to register the station, so you'd have to add that.

-tk

--
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 weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/ed011528-5b99-4e41-b77f-45fb6d435bdd%40googlegroups.com.

Vince Skahan

unread,
May 1, 2020, 9:40:19 PM5/1/20
to weewx-development
On Friday, May 1, 2020 at 6:36:24 PM UTC-7, Tom Keffer wrote:
What I use is

echo "hood river\n700,foot\n45\n-125\nmetric\n6\n\n\n" | python ./setup.py install

NB: this worked for V3.x. Version 4 asks the user whether s/he wants to register the station, so you'd have to add that.



Cool - let me take a crack at it and see how it goes.

(but I still liked the old way :-)

Thanks !

Tom Mitchell

unread,
May 2, 2020, 2:11:28 PM5/2/20
to weewx-development
Vince, please do report back. I also liked the headless/default install for smoke testing my Docker images.

Vince Skahan

unread,
May 2, 2020, 8:43:27 PM5/2/20
to weewx-development
On Friday, May 1, 2020 at 6:36:24 PM UTC-7, Tom Keffer wrote:
echo "hood river\n700,foot\n45\n-125\nmetric\n6\n\n\n" | python ./setup.py install

NB: this worked for V3.x. Version 4 asks the user whether s/he wants to register the station, so you'd have to add that.


Yeah, that's a fail for me here.   No matter how many \n are in there, it barfs right around the altitude prompt.   You might want to try it on your system and see if you have better luck.


Rather than battle that much more, I'm trying to re-add the old --no-prompt option back in (and hopefully send you a PR) and I'd appreciate some pointers on my approach.  What I was thinking was adding a command-line option to setup.py again, and simply returning a default set of values if that option is set.

So in bin/weecfg/__init.py I'd add this to prompt_for_info() at the top....and something similar in prompt_for_driver() as well.

+    if defaultConfig:
+        default_stn_info = {}
+        default_stn_info['location'] = "My Little Town, Oregon"
+        default_stn_info['altitude'] = [700, 'foot']
+        default_stn_info['latitude'] = 45
+        default_stn_info['longitude'] = -121
+        default_stn_info['register_this_station'] = "false"
+        default_stn_info['units'] = "us"
+        return default_stn_info

If I hard define defaultConfig at the top of the file right under your DEFAULT_URL variable, the code works as expected.   If it's set True, it skips prompts nicely.  If not, it prompts.  Exactly what I'm looking for.  But it's hard-wired and of course needs to be more flexible.

Question I have is how would I get a setup.py commandline option to this routine in __init.py__ for weecfg ?

I guess I'm a bit lost in the internals of how all this stuff is put together under the hood.  Pointers appreciated.

Tom Keffer

unread,
May 2, 2020, 8:59:25 PM5/2/20
to Vince Skahan, weewx-development
This worked for me:

echo -e "hood river\n700, foot\n45\n-125\nn\nmetric\n3\n" | python3 ./setup.py install

Adding new options to setup.py adds a LOT of complexity. Hence, the decision to get rid of it.

-tk

--
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 weewx-developm...@googlegroups.com.

Vince Skahan

unread,
May 2, 2020, 9:14:18 PM5/2/20
to weewx-development

sigh - I missed the "-e" option there.   I see from the man page what it does.
Thanks.

I would like to keep trying on setup.py, just for the education at a minimum.   Adding the code to __init.py__ for weecfg was trivial, I just can't figure out how to get setup.py commandline options through to weecfg under that hood when setup's install runs.  If there are pointers etc. for that or other similar utilities to use as examples, it would be great to know (and learn).


Tom Keffer

unread,
May 3, 2020, 6:58:04 AM5/3/20
to Vince Skahan, weewx-development
There is no useful documentation on setup.py. I usually end up going through it with a debugger, step-by-step, trying to figure out how it works.

Best example is the old, V3.9.2 setup.py.

--
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 weewx-developm...@googlegroups.com.

Tom Mitchell

unread,
May 3, 2020, 7:08:34 AM5/3/20
to Tom Keffer, Vince Skahan, weewx-development
This worked for me too, but I removed the -e switch because it was winding up in the stattion name. Man echo didn't show me a -e option.

So this is good enough for me now, but I am interested to see what Vince uncevers too.

This worked for me:

echo -e "hood river\n700, foot\n45\n-125\nn\nmetric\n3\n" | python3 ./setup.py install

Adding new options to setup.py adds a LOT of complexity. Hence, the decision to get rid of it.

-tk

--
Tom Mitchell
t...@tom.org
Real Time Beverly, MA Weather
http://weather.tom.org

"The whole problem with the world
  is that fools and fanatics are
  always so certain of themselves,
  and wiser people so full of doubts."
  - Bertrand Russell


You received this message because you are subscribed to a topic in the Google Groups "weewx-development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-development/hT3m5qKheeU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/CAPq0zEDezPQDrhoUSCjCe5rcPyRCLYkM0Cgaicu3D7Y-LCVpjA%40mail.gmail.com.

Vince Skahan

unread,
May 3, 2020, 5:03:33 PM5/3/20
to weewx-development
Here is a short patch to (re)add this option into setup.py, as well as the full modified version of setup.py with the patch applied.

It turns out that wee_config already has the --no-prompt option, and if you call it with that switch for a 'setup.py install' then it simply copies the (valid) default weewx.conf that comes with the distro into place, picking simulator as the builtin default driver.  Cool.   Nothing other than setup.py needed tweaking.

This gets us back the v3.9.x behavior.  Any chance of this making it into the real distro in a future update ?


setup.py.add_no_prompt.patch
setup.py.gz

Tom Keffer

unread,
May 3, 2020, 6:23:57 PM5/3/20
to Vince Skahan, weewx-development
That's not so bad. Added in commit e83fcdf

I simplified a bit, and tweaked here and there.

Can you test?

-tk

--
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 weewx-developm...@googlegroups.com.

Vince Skahan

unread,
May 3, 2020, 7:08:56 PM5/3/20
to weewx-development
On Sunday, May 3, 2020 at 3:23:57 PM UTC-7, Tom Keffer wrote:
That's not so bad. Added in commit e83fcdf

I simplified a bit, and tweaked here and there.

Can you test?


Looks good to me.....

Tom (Mitchell) - do a git pull on development if you want to test as well.... 
Reply all
Reply to author
Forward
0 new messages