Agree. I was going to likely stop at listing the skins, enable/disable,
and setting HTML_ROOT, but it would be nice to be able to edit anything
under the skin's definition. There's really no way to do that with ansible
or the like since keywords are not unique in weewx.conf - man I wish we had
anything other than configobj format, but so it goes....
Anyway, at this point I'm using wunderfixer as a simple example just to get
my feet wet, but this does work for listing (not changing) the skins and
some info therein quickly....
IMPORTANT - the attached script does NOT hide/delete/obfuscate any
usernames/keys/passwords/etc/ in the config_dict for a skin, so don't post
output please. I'm just fiddling with things at this point to see what I
can get at easily before seeing if I can add to it...
Quick example output for a few skins looks like the following. Obviously
any real utility would have very different formatting.
-----------------
SeasonsReport
-----------------
enable = false
HTML_ROOT = public_html/Standard
config_dict = {'skin': 'Seasons', 'enable': 'false', 'HTML_ROOT':
'public_html/Standard', 'Units': {'Groups': {'group_altitude': 'foot',
'group_speed2': 'mile_per_hour2', 'group_pressure': 'mbar', 'group_rain':
'inch', 'group_rainrate': 'inch_per_hour', 'group_temperature': 'degree_F',
'group_degree_day': 'degree_F_day', 'group_speed': 'mile_per_hour'}}}
-----------------
MQTT
-----------------
enable = true
HTML_ROOT not specified
config_dict = {'server_url': 'mqtt://localhost:1883', 'topic': 'weather',
'binding': ['archive', 'loop'], 'aggregation': 'aggregate', 'log_success':
'false', 'log_failure': 'true', 'enable': 'true'}
-----------------
FTP
-----------------
enable not specified
HTML_ROOT not specified
config_dict = {'skin': 'Ftp', 'secure_ftp': 'False', 'port': '21',
'passive': '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/34398431-9a85-408a-831b-67d8772507c4n%40googlegroups.com.
#!/usr/bin/python3
#
# based on wunderfixer as an example to start with
#
from __future__ import print_function
import datetime
import logging
import optparse
import sys
# Python 2/3 compatiblity shims
import six
from six.moves import urllib, input
import weecfg
import weewx.manager
import weeutil.logger
from weeutil.config import search_up
from weeutil.weeutil import timestamp_to_string
log = logging.getLogger(__name__)
usagestr = """%prog CONFIG_FILE|--config=CONFIG_FILE
"""
epilog = """
"""
__version__ = "0.0.1"
def main():
"""main program body for printSkins"""
# Set defaults for logging:
weeutil.logger.setup('printSkins', {})
parser = optparse.OptionParser(usage=usagestr, epilog=epilog)
parser.add_option("-c", "--config", metavar="CONFIG_PATH",
help="Use configuration file CONFIG_PATH. "
"Default is /etc/weewx/weewx.conf or /home/weewx/weewx.conf.")
(options, args) = parser.parse_args()
# get our config file
config_fn, config_dict = weecfg.read_config(options.config, args)
# toplevel items under StdReport that are not skins
toplevel_skin_excludes = ['SKIN_ROOT','HTML_ROOT','data_binding','log_success','log_failure','Defaults']
for item in config_dict['StdReport']:
if item in toplevel_skin_excludes:
pass
else:
# this next line would be the meat of a --list-skins output
print("-----------------");
print(item);
print("-----------------");
# enabled status specifically
try:
print("enable = %s" % config_dict['StdReport'][item]['enable']);
except:
print("enable not specified")
# HTML_ROOT specifically
try:
print("HTML_ROOT = %s" % config_dict['StdReport'][item]['HTML_ROOT']);
except:
print("HTML_ROOT not specified")
# full config_dict therein
print();
print("config_dict = %s" % config_dict['StdReport'][item]);
print();
# don't do anything quite yet...
sys.exit(1)
if __name__ == "__main__":
main()