コード例 #1
0
                        help="run dashboard server")
    parser.add_argument("--debug",
                        action="store_true",
                        help="enable debug output")
    args = parser.parse_args()

    logLevel = logging.DEBUG if args.debug else logging.INFO
    logging.basicConfig(format="{asctime}|{levelname:7s}|> {message}",
                        style="{",
                        datefmt="%d/%m/%Y %H:%M:%S",
                        level=logLevel)
    if not args.debug:
        logging.getLogger('apscheduler.executors.default').propagate = False

    try:
        piweather.config = load_external(args.config)
        sensors = load_external(piweather.config.SENSORS)
        piweather.config.SENSORS = sensors.SENSORS
        piweather.config.MEASUREMENTS = sensors.MEASUREMENTS
    except FileNotFoundError:
        logging.error("Config file not found at {}".format(args.config))
        sys.exit(1)

    piweather.scheduler.start()

    if args.dash:
        piweather.app = create_app()

        try:
            dash_layout = load_external(piweather.config.DASH).layout
        except AttributeError:
コード例 #2
0
ファイル: test_database.py プロジェクト: weinshec/piweather
 def test_uses_config_if_url_arg_is_none(self):
     piweather.config = load_external("test/static/config.py")
     db.get_engine()
     self.assertEqual(str(piweather.db.url), piweather.config.DB_ENGINE)
コード例 #3
0
 def test_gets_viewport_from_config_file(self):
     piweather.config = load_external("test/static/config.py")
     self.assertIsNotNone(get_viewport())
     piweather.config = None
コード例 #4
0
 def test_load_config_given_file(self):
     config = load_external("test/static/config.py")
     self.assertIn("piweather", config.TITLE)
コード例 #5
0
 def test_load_config_fails_if_file_not_found(self):
     with self.assertRaises(FileNotFoundError):
         load_external("foobar")