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 ?


-- 
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-development+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/3fec267f-89a8-48ea-8dde-b7df25e4c463%40googlegroups.com.
diff --git a/setup.py b/setup.py
index e642f845..56c515ed 100755
--- a/setup.py
+++ b/setup.py
@@ -47,6 +47,14 @@ this_dir = os.path.abspath(os.path.dirname(this_file))
 class weewx_install(install):
     """Specialized version of install, which runs a post-install script"""
 
+    # Add an option for --no-prompt. This will result in a scripted installation
+    # of a weewx.conf that uses the distribution's default values
+    user_options = install.user_options + [('no-prompt', None, 'Do not prompt for station info')]
+
+    def initialize_options(self, *args, **kwargs):
+         install.initialize_options(self, *args, **kwargs)
+         self.no_prompt = None
+
     def finalize_options(self):
         # Call my superclass's version
         install.finalize_options(self)
@@ -54,6 +62,9 @@ class weewx_install(install):
         # cause files to be installed even if they are older than their target."""
         if self.force is None:
             self.force = 1
+        # Keep track of whether the user specified --no-prompt in the command line options
+        if self.no_prompt:
+            self.no_prompt = True
 
     def run(self):
         """Specialized version of run, which runs post-install commands"""
@@ -62,7 +73,7 @@ class weewx_install(install):
         rv = install.run(self)
 
         # Now the post-install
-        update_and_install_config(self.install_data, self.install_scripts, self.install_lib)
+        update_and_install_config(self.install_data, self.install_scripts, self.no_prompt, self.install_lib)
 
         return rv
 
@@ -179,7 +190,7 @@ def find_files(directory, file_excludes=['*.pyc', "junk*"], dir_excludes=['*/__p
     return data_files
 
 
-def update_and_install_config(install_dir, install_scripts, install_lib, config_name='weewx.conf'):
+def update_and_install_config(install_dir, install_scripts, no_prompt, install_lib, config_name='weewx.conf'):
     """Install the configuration file, weewx.conf, updating it if necessary.
 
     install_dir: the directory containing the configuration file.
@@ -204,8 +215,17 @@ def update_and_install_config(install_dir, install_scripts, install_lib, config_
                 '--dist-config=%s' % config_path + '.' + VERSION,
                 '--output=%s' % config_path,
                 ]
+    elif no_prompt:
+        # No existing config file. This is an unprompted install with default settings
+        args = [sys.executable,
+                os.path.join(install_scripts, 'wee_config'),
+                '--install',
+                '--dist-config=%s' % config_path + '.' + VERSION,
+                '--output=%s' % config_path,
+                '--no-prompt',
+                ]
     else:
-        # No existing config file. This is an install
+        # No existing config file. This is an install with prompts
         args = [sys.executable,
                 os.path.join(install_scripts, 'wee_config'),
                 '--install',

Attachment: setup.py.gz
Description: Binary data

Reply via email to