|
@@ -26,7 +26,7 @@ class OnWriteHandler(pyinotify.ProcessEvent):
|
|
|
print('==> Modification detected')
|
|
print('==> Modification detected')
|
|
|
d=db()
|
|
d=db()
|
|
|
out_fname=os.path.join(RAW_PATH, os.path.basename(path).replace('flv','mp4'))
|
|
out_fname=os.path.join(RAW_PATH, os.path.basename(path).replace('flv','mp4'))
|
|
|
- in_fname=os.path.join(INCOMING_PATH, path)
|
|
|
|
|
|
|
+ in_fname=os.path.join(self.cwd, path)
|
|
|
if os.path.isfile(out_fname):
|
|
if os.path.isfile(out_fname):
|
|
|
#exists
|
|
#exists
|
|
|
return
|
|
return
|
|
@@ -42,21 +42,24 @@ class OnWriteHandler(pyinotify.ProcessEvent):
|
|
|
print(" ".join(process))
|
|
print(" ".join(process))
|
|
|
proc=Popen(process, universal_newlines=True)
|
|
proc=Popen(process, universal_newlines=True)
|
|
|
proc.wait()
|
|
proc.wait()
|
|
|
|
|
+ rc = proc.returncode
|
|
|
|
|
+ if rc != 0:
|
|
|
|
|
+ print("Error?")
|
|
|
|
|
+ return
|
|
|
d.insert_raw(file_info(out_fname))
|
|
d.insert_raw(file_info(out_fname))
|
|
|
|
|
|
|
|
- def process_IN_MODIFY(self, event):
|
|
|
|
|
|
|
+ def process_IN_CLOSE_WRITE(self, event):
|
|
|
if not event.pathname.endswith(self.extension):
|
|
if not event.pathname.endswith(self.extension):
|
|
|
return
|
|
return
|
|
|
- #print(event)
|
|
|
|
|
print(event.mask, event.maskname, event.pathname)
|
|
print(event.mask, event.maskname, event.pathname)
|
|
|
- #self._run_cmd(event.pathname)
|
|
|
|
|
|
|
+ self._run_cmd(event.pathname)
|
|
|
|
|
|
|
|
def auto_compile(path, extension, cmd):
|
|
def auto_compile(path, extension, cmd):
|
|
|
wm = pyinotify.WatchManager()
|
|
wm = pyinotify.WatchManager()
|
|
|
handler = OnWriteHandler(cwd=path, extension=extension, cmd=cmd)
|
|
handler = OnWriteHandler(cwd=path, extension=extension, cmd=cmd)
|
|
|
notifier = pyinotify.Notifier(wm, default_proc_fun=handler)
|
|
notifier = pyinotify.Notifier(wm, default_proc_fun=handler)
|
|
|
wm.add_watch(path, pyinotify.ALL_EVENTS, rec=True, auto_add=True)
|
|
wm.add_watch(path, pyinotify.ALL_EVENTS, rec=True, auto_add=True)
|
|
|
- print('==> Start monitoring %s (type c^c to exit)' % path)
|
|
|
|
|
|
|
+ print('==> Start monitoring %s' % path)
|
|
|
notifier.loop()
|
|
notifier.loop()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|