mirror of
https://github.com/weewx/weewx.git
synced 2026-04-18 08:36:54 -04:00
65 lines
2.3 KiB
Python
Executable File
65 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
#
|
|
# Copyright (c) 2009-2019 Tom Keffer <tkeffer@gmail.com>
|
|
#
|
|
# See the file LICENSE.txt for your rights.
|
|
#
|
|
"""Entry point to the weewx weather system."""
|
|
import sys
|
|
from optparse import OptionParser
|
|
|
|
import weeutil.logger
|
|
|
|
# First import any user extensions:
|
|
import user.extensions # @UnusedImport
|
|
# Now the engine
|
|
import weewx.engine
|
|
|
|
usagestr = """Usage: weewxd --help
|
|
weewxd --version
|
|
weewxd config_file [--daemon] [--pidfile=PIDFILE]
|
|
[--exit] [--loop-on-init]
|
|
[--log-label=LABEL]
|
|
|
|
Entry point to the weewx weather program. Can be run directly, or as a daemon
|
|
by specifying the '--daemon' option.
|
|
|
|
Arguments:
|
|
config_file: The weewx configuration file to be used.
|
|
"""
|
|
|
|
# ===============================================================================
|
|
# Main entry point
|
|
# ===============================================================================
|
|
|
|
|
|
parser = OptionParser(usage=usagestr)
|
|
parser.add_option("-d", "--daemon", action="store_true", dest="daemon", help="Run as a daemon")
|
|
parser.add_option("-p", "--pidfile", type="string", dest="pidfile", help="Store the process ID in PIDFILE",
|
|
default="/var/run/weewx.pid", metavar="PIDFILE")
|
|
parser.add_option("-v", "--version", action="store_true", dest="version", help="Display version number then exit")
|
|
parser.add_option("-x", "--exit", action="store_true", dest="exit",
|
|
help="Exit on I/O and database errors instead of restarting")
|
|
parser.add_option("-r", "--loop-on-init", action="store_true", dest="loop_on_init",
|
|
help="Retry forever if device is not ready on startup")
|
|
parser.add_option("-n", "--log-label", type="string", dest="log_label", help="Label to use in syslog entries",
|
|
default="weewx", metavar="LABEL")
|
|
|
|
# Get the command line options and arguments:
|
|
(options, args) = parser.parse_args()
|
|
|
|
# Set up a minimal logging facility to be used during initial start up.
|
|
weeutil.logger.setup(options.log_label, {})
|
|
|
|
if options.version:
|
|
print(weewx.__version__)
|
|
sys.exit(0)
|
|
|
|
if len(args) < 1:
|
|
sys.stderr.write("Missing argument(s).\n")
|
|
sys.stderr.write(parser.parse_args(["--help"]))
|
|
sys.exit(weewx.CMD_ERROR)
|
|
|
|
# Fire up the engine.
|
|
weewx.engine.main(options, args)
|