Przeglądaj źródła

check por error, arreglo fname

David 10 lat temu
rodzic
commit
7a8da58133
1 zmienionych plików z 8 dodań i 5 usunięć
  1. 8 5
      back/watch.py

+ 8 - 5
back/watch.py

@@ -26,7 +26,7 @@ class OnWriteHandler(pyinotify.ProcessEvent):
         print('==> Modification detected')
         d=db()
         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):
             #exists
             return
@@ -42,21 +42,24 @@ class OnWriteHandler(pyinotify.ProcessEvent):
         print(" ".join(process))
         proc=Popen(process, universal_newlines=True)
         proc.wait()
+        rc = proc.returncode
+        if rc != 0:
+            print("Error?")
+            return
         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):
             return
-        #print(event)
         print(event.mask, event.maskname, event.pathname)
-        #self._run_cmd(event.pathname)
+        self._run_cmd(event.pathname)
 
 def auto_compile(path, extension, cmd):
     wm = pyinotify.WatchManager()
     handler = OnWriteHandler(cwd=path, extension=extension, cmd=cmd)
     notifier = pyinotify.Notifier(wm, default_proc_fun=handler)
     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()
 
 if __name__ == '__main__':