]> git.treefish.org Git - photosort.git/blobdiff - src/bunch.py
fixing trigger
[photosort.git] / src / bunch.py
index 713a6185106148cd9107b5582d371902faea751c..2ac33ca7547521737b47d2c0bf17944063a2ed0e 100644 (file)
@@ -18,7 +18,7 @@ class Bunch:
         for src_dir_cfg in cfg['src_dirs']:
             self._sources.append(
                 Bunch.TriggeredSource(
         for src_dir_cfg in cfg['src_dirs']:
             self._sources.append(
                 Bunch.TriggeredSource(
-                    DirTrigger(src_dir_cfg['path']),
+                    DirTrigger(src_dir_cfg['path'], src_dir_cfg['cool_time'], src_dir_cfg['max_time']),
                     Migrator(src_dir_cfg['path'], cfg['dst_dir']['path']),
                     src_dir_cfg['cleanup']
                 )
                     Migrator(src_dir_cfg['path'], cfg['dst_dir']['path']),
                     src_dir_cfg['cleanup']
                 )
@@ -37,8 +37,12 @@ class Bunch:
         self._worker_thread.join()
         logging.info("Stopped bunch %s.", self._id)
 
         self._worker_thread.join()
         logging.info("Stopped bunch %s.", self._id)
 
+    def is_running(self):
+        return self._worker_thread.is_alive()
+
     def _worker(self):
     def _worker(self):
-        # start triggers
+        for source in self._sources:
+            source.trigger.start()
 
         while not self._stop:
             for source in self._sources:
 
         while not self._stop:
             for source in self._sources:
@@ -46,7 +50,7 @@ class Bunch:
                     if source.trigger.is_triggering():
                         logging.info("Got source trigger for bunch %s.", self._id)
                         source.trigger.reset()
                     if source.trigger.is_triggering():
                         logging.info("Got source trigger for bunch %s.", self._id)
                         source.trigger.reset()
-                        source.migrator.migrate()
+                        source.migrator.migrate(source.cleanup)
                         if source.cleanup:
                             source.migrator.cleanup()
                 except Exception as e:
                         if source.cleanup:
                             source.migrator.cleanup()
                 except Exception as e:
@@ -54,4 +58,5 @@ class Bunch:
                                   self._id, str(e))
             time.sleep(10.0)
 
                                   self._id, str(e))
             time.sleep(10.0)
 
-        # stop triggers
+        for source in self._sources:
+            source.trigger.stop()