fix creation of fifo
This commit is contained in:
parent
e65ed89053
commit
a8c7d8e74f
1 changed files with 9 additions and 4 deletions
|
@ -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])
|
||||
|
|
Loading…
Add table
Reference in a new issue