diff --git a/phytopi/camera/camera.py b/phytopi/camera/camera.py index 800d801..2abd649 100644 --- a/phytopi/camera/camera.py +++ b/phytopi/camera/camera.py @@ -11,7 +11,7 @@ from phytopi import db, models, app # map commands camera_cmds = { 'start_timelapse': 'tl 1', - 'stop_timelapse': 'tl 0', + 'stop_timelapse': 'tl 0' } class CameraStatus(Enum): @@ -31,13 +31,18 @@ class CameraWorker(object): self.status = CameraStatus.STOPPED def start(self): - # create FIFO - os.mkfifo(self.fifo) - # check if process is already running if os.path.isfile(self.pidfile): with open(self.pidfile, 'r') as fh: self.pid = int(fh.read()) + self.status = CameraStatus.IDLE + return + + # create FIFO, if not existent + try: + os.mkfifo(self.fifo) + except FileExistsError: + pass # if not, spawn new process and create pid file self.proc = subprocess.Popen([self.executable])