Пример #1
0
def main():
  parser = utils.create_arg_parser('Meact Manage CLI')
  subparsers = parser.add_subparsers()

  p_create_db = subparsers.add_parser('create-db', help='Create meact database. CAUTION: IT WILL REMOVE OLD DATA')
  p_create_db.set_defaults(func=create_db)

  p_sync_db_desc = subparsers.add_parser('sync-db-desc', help='Sync boards description')
  p_sync_db_desc.set_defaults(func=sync_db_desc)

  p_aggregate_metric = subparsers.add_parser('aggregate-metric', help='Aggregate metrics in DB')
  p_aggregate_metric.add_argument('--start', required=True, help='Start time for aggregate (seconds since epoch)')
  p_aggregate_metric.add_argument('--end', required=True, help='End time for aggregate (seconds since epoch)')
  p_aggregate_metric.add_argument('--policy', required=True, help='Aggregate policy, aggregate per 10m/30m/hour/day/week/month')
  p_aggregate_metric.add_argument('--sensor-type', required=False, help='sensor_type for aggregate, if missing we will aggregate all sensor_type')
  p_aggregate_metric.add_argument('--execute', required=False, help='Execute data aggregation, without this DB will not be changed', action="store_true")
  p_aggregate_metric.set_defaults(func=aggregate_metric)

  p_clean_action = subparsers.add_parser('clean-action', help='Clean (remove) old records from action table')
  p_clean_action.add_argument('--start', required=True, help='Start time for cleaning (seconds since epoch)')
  p_clean_action.add_argument('--end', required=True, help='End time for cleaning (seconds since epoch)')
  p_clean_action.add_argument('--execute', required=False, help='Execute data cleaning, without this DB will not be changed', action="store_true")
  p_clean_action.set_defaults(func=clean_action)

  p_clean_feed = subparsers.add_parser('clean-feed', help='Clean (remove) old records from feed table')
  p_clean_feed.add_argument('--start', required=True, help='Start time for cleaning (seconds since epoch)')
  p_clean_feed.add_argument('--end', required=True, help='End time for cleaning (seconds since epoch)')
  p_clean_feed.add_argument('--execute', required=False, help='Execute data cleaning, without this DB will not be changed', action="store_true")
  p_clean_feed.set_defaults(func=clean_feed)

  args = parser.parse_args()

  utils.create_logger()

  args.func(args)
Пример #2
0
def main():
  parser = utils.create_arg_parser('Meact DBSM service')
  args = parser.parse_args()

  conf = utils.load_config(args.dir + '/global.yaml')
  conf = conf.get('dbsm', {})

  logging_conf = conf.get('logging', {})
  utils.create_logger(logging_conf)

  dbsm = Dbsm(
    db_string=conf['db_string'],
    mqtt_config=conf['mqtt'])

  dbsm.run()
Пример #3
0
def main():
  parser = utils.create_arg_parser('Meact Feeder service')
  args = parser.parse_args()

  conf = utils.load_config(args.dir + '/global.yaml')
  conf = conf.get('feeder', {})
  feeds_map_file = args.dir + '/feeds.yaml'

  logging_conf = conf.get('logging', {})
  utils.create_logger(logging_conf)

  feeder = Feeder(db_string=conf['db_string'],
          mqtt_config=conf['mqtt'],
          feeds_map_file=feeds_map_file)
  feeder.run()
Пример #4
0
def main():
  parser = utils.create_arg_parser('Meact executor service')
  args = parser.parse_args()

  conf = utils.load_config(args.dir + '/global.yaml')
  conf = conf.get('executor', {})
  sensors_map_file = args.dir + '/sensors.yaml'

  logging_conf = conf.get('logging', {})
  utils.create_logger(logging_conf)

  executor = Executor(
    db_string=conf['db_string'],
    sensors_map_file=sensors_map_file,
    action_config=conf['action_config'],
    mqtt_config=conf['mqtt'])

  executor.run()
Пример #5
0
def main():
  parser = utils.create_arg_parser('Meact SRL service')
  args = parser.parse_args()

  conf = utils.load_config(args.dir + '/global.yaml')
  conf = conf.get('srl', {})

  logging_conf = conf.get('logging', {})
  utils.create_logger(logging_conf)

  ser = serial.Serial(
    conf['serial']['device'],
    conf['serial']['speed'],
    timeout=conf['serial']['timeout']
  )
  srl = Srl(
    serial=ser,
    mqtt_config=conf['mqtt'],
    re_sensor_data=conf['re_sensor_data'])
  srl.run()
Пример #6
0
def main():
    parser = utils.create_arg_parser("Meact API service")
    args = parser.parse_args()

    conf = utils.load_config(args.dir + "/global.yaml")
    conf = conf.get("api", {})

    # static_dir in config file should be specified only if
    # static files are located somewhere else than app package
    if not conf.get("static_dir"):
        conf["static_dir"] = os.path.join(os.path.dirname(__file__), "static")

    app.config["appconfig"] = conf
    logging_conf = conf.get("logging", {})

    app.config["mqtt"] = Api(conf["mqtt"])
    app.config["mqtt"].loop_start()

    utils.create_logger(logging_conf)

    app.config["db"] = database.connect(conf["db_string"])

    app.run(host="0.0.0.0", port=8080, server="tornado")