Commit 8d8e851e by Kálmán Viktor

circle: don't run watch.py on import

parent 595735da
...@@ -27,11 +27,12 @@ class LessUtils(object): ...@@ -27,11 +27,12 @@ class LessUtils(object):
less_pathname, css_pathname)) less_pathname, css_pathname))
# for first run compile everything if __name__ == "__main__":
print("Initial LESS compiles") # for first run compile everything
current_dir = os.path.dirname(os.path.realpath(__file__)) print("Initial LESS compiles")
current_dir = os.path.dirname(os.path.realpath(__file__))
for root, dirs, files in os.walk("/home/cloud/circle/circle"): for root, dirs, files in os.walk("/home/cloud/circle/circle"):
for f in files: for f in files:
if not f.endswith(".less"): if not f.endswith(".less"):
continue continue
...@@ -44,15 +45,13 @@ for root, dirs, files in os.walk("/home/cloud/circle/circle"): ...@@ -44,15 +45,13 @@ for root, dirs, files in os.walk("/home/cloud/circle/circle"):
css_pathname = LessUtils.less_path_to_css_path(less_pathname) css_pathname = LessUtils.less_path_to_css_path(less_pathname)
LessUtils.compile_less(less_pathname, css_pathname) LessUtils.compile_less(less_pathname, css_pathname)
print("\n%s\n" % ("=" * 30)) print("\n%s\n" % ("=" * 30))
print("End of initial LESS compiles\n") print("End of initial LESS compiles\n")
# after first run watch less files
wm = pyinotify.WatchManager()
# after first run watch less files class EventHandler(pyinotify.ProcessEvent):
wm = pyinotify.WatchManager()
class EventHandler(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, event): def process_IN_MODIFY(self, event):
if not event.name.endswith(".less"): if not event.name.endswith(".less"):
return return
...@@ -60,8 +59,7 @@ class EventHandler(pyinotify.ProcessEvent): ...@@ -60,8 +59,7 @@ class EventHandler(pyinotify.ProcessEvent):
css_pathname = LessUtils.less_path_to_css_path(event.pathname) css_pathname = LessUtils.less_path_to_css_path(event.pathname)
LessUtils.compile_less(event.pathname, css_pathname) LessUtils.compile_less(event.pathname, css_pathname)
handler = EventHandler()
handler = EventHandler() notifier = pyinotify.Notifier(wm, handler)
notifier = pyinotify.Notifier(wm, handler) wm.add_watch(current_dir, pyinotify.IN_MODIFY, rec=True)
wm.add_watch(current_dir, pyinotify.IN_MODIFY, rec=True) notifier.loop()
notifier.loop()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment