Beispiel #1
0
def start():
    logger.info("starting manager[pid=%s]" % common.PID)
    storage.setup()
    config = common.load_config()
    output = config["output"]
    for camera in config["cameras"].keys():
        logger.info("found camera %s" % camera)
        PROCESSES.append(camera)
        MODULES[camera] = "runtime.recorder"
        segment_dir = "%s/%s" % (output, camera)
        if not exists(segment_dir):
            makedirs(segment_dir)
            logger.info("directory %s created" % segment_dir)

    del config, output

    with storage.get_connection() as conn:
        for name in PROCESSES:
            metric = "%sStatus" % name
            storage.put(conn, metric, "Launching")
            running[name] = start_process(name)
            storage.put(conn, metric, "Launched")

        try:
            loop(conn)
        finally:
            logger.info("manager[pid=%s] is stopping" % common.PID)
Beispiel #2
0
 def test_send(self):
     config = common.load_config()
     with storage.get_connection() as conn:
         storage.put(conn, "reporterStatus", "Running")
         reporter.running = True
         client = reporter.connect(config["mqtt.broker"],
                                   config["mqtt.port"], config["mqtt.user"],
                                   config["mqtt.pass"])
         reporter.send_report(client, conn)
Beispiel #3
0
    def test_update(self):
        with storage.get_connection() as conn:
            storage.put(conn, "a", "a")
            self.assertEqual(storage.get(conn, "a"), "a")

        with storage.get_connection() as conn:
            storage.put(conn, "a", "b")

        with storage.get_connection() as conn:
            self.assertEqual(storage.get(conn, "a"), "b")
Beispiel #4
0
    def test_put_float(self):
        with storage.get_connection() as conn:
            storage.put(conn, "a", 1.1)
            self.assertEqual(storage.get_float(conn, "a"), 1.1)

        with storage.get_connection() as conn:
            storage.put(conn, "b", 1.1)

        with storage.get_connection() as conn:
            self.assertEqual(storage.get_float(conn, "b"), 1.1)
Beispiel #5
0
def start():
    logger.info("starting reported[pid=%s]" % common.PID)
    config = common.load_config()
    broker = config["mqtt.broker"]
    port = config["mqtt.port"]
    user = config.get("mqtt.user")
    pwd = config.get("mqtt.pass")
    del config
    with storage.get_connection() as conn:
        storage.put(conn, REPORTER_STATUS, "Running")
        try:
            loop(conn, broker, port, user, pwd)
        finally:
            storage.put(conn, REPORTER_STATUS, "Not Running")
            logger.info("stopping watcher[pid=%s]" % common.PID)
Beispiel #6
0
def start():
    logger.info("starting cleaner[pid=%s]" % common.PID)
    config = common.load_config()
    output = config["output"]
    cameras = config["cameras"]
    loop_interval = 3600
    for camera, config in cameras.items():
        config["segment_dir"] = join(output, camera)
        loop_interval = min(loop_interval, int(config["keep"]))

    del config, output
    with storage.get_connection() as conn:
        storage.put(conn, CLEANER_STATUS, "Running")
        try:
            loop(conn, cameras, loop_interval)
        finally:
            storage.put(conn, CLEANER_STATUS, "Not Running")
            logger.info("stopping cleaner[pid=%s]" % common.PID)
Beispiel #7
0
def start():
    logger.info("starting watcher[pid=%s]" % common.PID)
    config = common.load_config()
    output = config["output"]
    threshold = config["filesystem.threshold"]
    loop_interval = 10
    segment_dirs = []
    for camera, config in config["cameras"].items():
        segment_dirs.append(join(output, camera))
        loop_interval = min(loop_interval, int(config["duration"]))

    del config
    with storage.get_connection() as conn:
        storage.put(conn, WATCHER_STATUS, "Running")
        try:
            loop(conn, segment_dirs, loop_interval, output, threshold)
        finally:
            storage.put(conn, WATCHER_STATUS, "Not Running")
            logger.info("stopping watcher[pid=%s]" % common.PID)
Beispiel #8
0
 def test_get_all(self):
     with storage.get_connection() as conn:
         storage.put(conn, "a", "a")
         storage.put(conn, "b", "b")
         self.assertEqual(storage.get_all(conn), [("a", "a"), ("b", "b")])
Beispiel #9
0
 def test_get_keys(self):
     with storage.get_connection() as conn:
         storage.put(conn, "a", "a")
         storage.put(conn, "b", "b")
         self.assertEqual(list(storage.get_keys(conn)), ["a", "b"])