# Path: foos/process.py
# def long_running(*args, **kwargs):
#     """Run process redirecting stderr to stdout and write output to log"""
#     p = subprocess.Popen(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, **kwargs)
#     with p.stdout:
#         for line in iter(p.stdout.readline, b''):
#             logger.error(line.decode("utf-8").strip())
# 
#     p.wait()
#     if p.returncode != 0:
#         logger.error("{} returned {}".format(p.args, p.returncode))


from foos.process import long_running
from threading import Thread
import time
import foos.config as config


class Plugin:
    def __init__(self, bus):
        Thread(target=self.runCamera, daemon=True).start()

    # Run camera
    def runCamera(self):
        while True:

# Path: foos/process.py
# def long_running(*args, **kwargs):
#     """Run process redirecting stderr to stdout and write output to log"""
#     p = subprocess.Popen(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, **kwargs)
#     with p.stdout:
#         for line in iter(p.stdout.readline, b''):
#             logger.error(line.decode("utf-8").strip())
# 
#     p.wait()
#     if p.returncode != 0:
#         logger.error("{} returned {}".format(p.args, p.returncode))


# Path: plugins/camera.py
from foos.process import long_running
from threading import Thread
import time
import foos.config as config



class Plugin:
    def __init__(self, bus):
        Thread(target=self.runCamera, daemon=True).start()

    # Run camera
    def runCamera(self):
        while True:

            long_running(["video/run-camera.sh"])