cleepcli 1.34.2__tar.gz → 1.35.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cleepcli-1.34.2/cleepcli.egg-info → cleepcli-1.35.1}/PKG-INFO +1 -1
- {cleepcli-1.34.2 → cleepcli-1.35.1}/bin/ccli +16 -10
- {cleepcli-1.34.2 → cleepcli-1.35.1}/bin/cleep-cli +16 -10
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/file.py +30 -3
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/version.py +1 -1
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/watch.py +108 -94
- {cleepcli-1.34.2 → cleepcli-1.35.1/cleepcli.egg-info}/PKG-INFO +1 -1
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli.egg-info/requires.txt +2 -2
- {cleepcli-1.34.2 → cleepcli-1.35.1}/LICENSE +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/MANIFEST.in +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/README.md +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/__init__.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/check.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/ci.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/cleepapi.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/config.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/console.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/docs.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/git.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/module.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/package.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/test.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli/tools.py +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli.egg-info/SOURCES.txt +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli.egg-info/dependency_links.txt +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/cleepcli.egg-info/top_level.txt +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/setup.cfg +0 -0
- {cleepcli-1.34.2 → cleepcli-1.35.1}/setup.py +0 -0
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
import logging
|
|
8
8
|
import sys
|
|
9
|
-
logging.basicConfig(level=logging.INFO, format=u'%(message)s', stream=sys.stdout)
|
|
10
9
|
import os
|
|
11
10
|
import platform
|
|
12
11
|
import subprocess
|
|
@@ -23,10 +22,14 @@ from cleepcli.package import Package
|
|
|
23
22
|
from cleepcli.docs import Docs
|
|
24
23
|
from cleepcli.check import Check
|
|
25
24
|
from cleepcli.ci import Ci
|
|
26
|
-
from cleepcli.cleepapi import CleepApi
|
|
27
25
|
import cleepcli.config as config
|
|
28
26
|
from cleepcli.version import VERSION
|
|
29
27
|
|
|
28
|
+
if os.getcwd() == '/root/cleep-cli':
|
|
29
|
+
# in dev env, force debug log level by default
|
|
30
|
+
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s [%(name)s:%(lineno)d]: %(message)s', stream=sys.stdout)
|
|
31
|
+
else:
|
|
32
|
+
logging.basicConfig(level=logging.INFO, format='%(message)s', stream=sys.stdout)
|
|
30
33
|
|
|
31
34
|
# install logging trace level
|
|
32
35
|
level = logging.TRACE = logging.DEBUG - 5
|
|
@@ -255,8 +258,8 @@ def reset(ctx):
|
|
|
255
258
|
def mod():
|
|
256
259
|
pass
|
|
257
260
|
|
|
258
|
-
def get_module_name(param, value):
|
|
259
|
-
module_name = value
|
|
261
|
+
def get_module_name(ctx, param, value):
|
|
262
|
+
module_name = value or None
|
|
260
263
|
try:
|
|
261
264
|
current_path = os.getcwd()
|
|
262
265
|
if current_path.startswith(config.MODULES_SRC) and not module_name:
|
|
@@ -272,7 +275,8 @@ def get_module_name(param, value):
|
|
|
272
275
|
return module_name
|
|
273
276
|
|
|
274
277
|
@mod.command()
|
|
275
|
-
|
|
278
|
+
@click.option('--run-scripts', default=False, is_flag=True, help='Also run preinst.sh and postinst.sh scripts')
|
|
279
|
+
def modssync(run_scripts):
|
|
276
280
|
"""
|
|
277
281
|
Synchronize all mandatory modules (system, network...)
|
|
278
282
|
"""
|
|
@@ -283,6 +287,9 @@ def modssync():
|
|
|
283
287
|
res = f.module_sync(module)
|
|
284
288
|
if not res:
|
|
285
289
|
sys.exit(1)
|
|
290
|
+
res = f.module_run_install_scripts(module)
|
|
291
|
+
if not res:
|
|
292
|
+
sys.exit(1)
|
|
286
293
|
|
|
287
294
|
logging.info('Done')
|
|
288
295
|
|
|
@@ -337,7 +344,7 @@ def watch(quiet, loglevel, rpc_url):
|
|
|
337
344
|
"""
|
|
338
345
|
Start watchdog that monitors filesystem changes on Cleep sources
|
|
339
346
|
"""
|
|
340
|
-
if logging.getLogger().getEffectiveLevel()==logging.DEBUG:
|
|
347
|
+
if logging.getLogger().getEffectiveLevel() == logging.DEBUG:
|
|
341
348
|
# do not overwrite root logger level if configured to DEBUG (dev mode)
|
|
342
349
|
pass
|
|
343
350
|
elif quiet:
|
|
@@ -859,14 +866,14 @@ def print_version(ctx, param, value):
|
|
|
859
866
|
def cli():
|
|
860
867
|
pass
|
|
861
868
|
|
|
862
|
-
if __name__ == '__main__':
|
|
863
869
|
|
|
870
|
+
if __name__ == '__main__':
|
|
864
871
|
def is_raspbian():
|
|
865
872
|
if platform.system()!='Linux':
|
|
866
873
|
return False
|
|
867
874
|
res = subprocess.Popen(u'cat /etc/os-release | grep -i raspbian | wc -l', stdout=subprocess.PIPE, shell=True)
|
|
868
875
|
stdout = res.communicate()[0]
|
|
869
|
-
if stdout.strip()=='0':
|
|
876
|
+
if stdout.strip() == '0':
|
|
870
877
|
return False
|
|
871
878
|
return True
|
|
872
879
|
|
|
@@ -874,5 +881,4 @@ if __name__ == '__main__':
|
|
|
874
881
|
if is_raspbian():
|
|
875
882
|
cli()
|
|
876
883
|
else:
|
|
877
|
-
click.echo('Cleep-cli runs only on
|
|
878
|
-
|
|
884
|
+
click.echo('Cleep-cli runs only on RaspberrypiOS distribution')
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
import logging
|
|
8
8
|
import sys
|
|
9
|
-
logging.basicConfig(level=logging.INFO, format=u'%(message)s', stream=sys.stdout)
|
|
10
9
|
import os
|
|
11
10
|
import platform
|
|
12
11
|
import subprocess
|
|
@@ -23,10 +22,14 @@ from cleepcli.package import Package
|
|
|
23
22
|
from cleepcli.docs import Docs
|
|
24
23
|
from cleepcli.check import Check
|
|
25
24
|
from cleepcli.ci import Ci
|
|
26
|
-
from cleepcli.cleepapi import CleepApi
|
|
27
25
|
import cleepcli.config as config
|
|
28
26
|
from cleepcli.version import VERSION
|
|
29
27
|
|
|
28
|
+
if os.getcwd() == '/root/cleep-cli':
|
|
29
|
+
# in dev env, force debug log level by default
|
|
30
|
+
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s [%(name)s:%(lineno)d]: %(message)s', stream=sys.stdout)
|
|
31
|
+
else:
|
|
32
|
+
logging.basicConfig(level=logging.INFO, format='%(message)s', stream=sys.stdout)
|
|
30
33
|
|
|
31
34
|
# install logging trace level
|
|
32
35
|
level = logging.TRACE = logging.DEBUG - 5
|
|
@@ -255,8 +258,8 @@ def reset(ctx):
|
|
|
255
258
|
def mod():
|
|
256
259
|
pass
|
|
257
260
|
|
|
258
|
-
def get_module_name(param, value):
|
|
259
|
-
module_name = value
|
|
261
|
+
def get_module_name(ctx, param, value):
|
|
262
|
+
module_name = value or None
|
|
260
263
|
try:
|
|
261
264
|
current_path = os.getcwd()
|
|
262
265
|
if current_path.startswith(config.MODULES_SRC) and not module_name:
|
|
@@ -272,7 +275,8 @@ def get_module_name(param, value):
|
|
|
272
275
|
return module_name
|
|
273
276
|
|
|
274
277
|
@mod.command()
|
|
275
|
-
|
|
278
|
+
@click.option('--run-scripts', default=False, is_flag=True, help='Also run preinst.sh and postinst.sh scripts')
|
|
279
|
+
def modssync(run_scripts):
|
|
276
280
|
"""
|
|
277
281
|
Synchronize all mandatory modules (system, network...)
|
|
278
282
|
"""
|
|
@@ -283,6 +287,9 @@ def modssync():
|
|
|
283
287
|
res = f.module_sync(module)
|
|
284
288
|
if not res:
|
|
285
289
|
sys.exit(1)
|
|
290
|
+
res = f.module_run_install_scripts(module)
|
|
291
|
+
if not res:
|
|
292
|
+
sys.exit(1)
|
|
286
293
|
|
|
287
294
|
logging.info('Done')
|
|
288
295
|
|
|
@@ -337,7 +344,7 @@ def watch(quiet, loglevel, rpc_url):
|
|
|
337
344
|
"""
|
|
338
345
|
Start watchdog that monitors filesystem changes on Cleep sources
|
|
339
346
|
"""
|
|
340
|
-
if logging.getLogger().getEffectiveLevel()==logging.DEBUG:
|
|
347
|
+
if logging.getLogger().getEffectiveLevel() == logging.DEBUG:
|
|
341
348
|
# do not overwrite root logger level if configured to DEBUG (dev mode)
|
|
342
349
|
pass
|
|
343
350
|
elif quiet:
|
|
@@ -859,14 +866,14 @@ def print_version(ctx, param, value):
|
|
|
859
866
|
def cli():
|
|
860
867
|
pass
|
|
861
868
|
|
|
862
|
-
if __name__ == '__main__':
|
|
863
869
|
|
|
870
|
+
if __name__ == '__main__':
|
|
864
871
|
def is_raspbian():
|
|
865
872
|
if platform.system()!='Linux':
|
|
866
873
|
return False
|
|
867
874
|
res = subprocess.Popen(u'cat /etc/os-release | grep -i raspbian | wc -l', stdout=subprocess.PIPE, shell=True)
|
|
868
875
|
stdout = res.communicate()[0]
|
|
869
|
-
if stdout.strip()=='0':
|
|
876
|
+
if stdout.strip() == '0':
|
|
870
877
|
return False
|
|
871
878
|
return True
|
|
872
879
|
|
|
@@ -874,5 +881,4 @@ if __name__ == '__main__':
|
|
|
874
881
|
if is_raspbian():
|
|
875
882
|
cli()
|
|
876
883
|
else:
|
|
877
|
-
click.echo('Cleep-cli runs only on
|
|
878
|
-
|
|
884
|
+
click.echo('Cleep-cli runs only on RaspberrypiOS distribution')
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
|
-
import sys
|
|
5
4
|
import os
|
|
6
5
|
from .console import Console
|
|
7
6
|
import logging
|
|
@@ -36,7 +35,7 @@ class File():
|
|
|
36
35
|
mkdir -p "%(HTML_DST)s/"
|
|
37
36
|
mkdir -p "%(CORE_DST)s/modules"
|
|
38
37
|
mkdir -p "%(MEDIA_DST)s/modules"
|
|
39
|
-
|
|
38
|
+
mkdir -p "%(CONFIG_DIR)s"
|
|
40
39
|
rsync -av "%(REPO_DIR)s/cleep/" "%(CORE_DST)s/" --exclude "/tests/" --exclude "modules" --exclude "*__pycache__*" --delete --exclude "*.pyc" --keep-dirlinks
|
|
41
40
|
rsync -av "%(REPO_DIR)s/html/" "%(HTML_DST)s/" --delete --exclude "js/modules/" --exclude "*node_modules*"
|
|
42
41
|
rsync -av "%(REPO_DIR)s/bin/cleep" "%(BIN_DST)s/cleep"
|
|
@@ -58,7 +57,8 @@ rsync -av "%(REPO_DIR)s/medias/sounds" "%(MEDIA_DST)s/sounds/" --delete
|
|
|
58
57
|
Copy specified module content to valid execution location
|
|
59
58
|
"""
|
|
60
59
|
if not os.path.exists(os.path.join(config.MODULES_SRC, module_name)):
|
|
61
|
-
|
|
60
|
+
self.logger.error('Module "%s" doesn\'t exist [%s]' % (module_name, os.path.join(config.MODULES_SRC, module_name)))
|
|
61
|
+
return False
|
|
62
62
|
|
|
63
63
|
if not os.path.exists(os.path.join(config.MODULES_DST, module_name)):
|
|
64
64
|
os.makedirs(os.path.join(config.MODULES_DST, module_name))
|
|
@@ -101,3 +101,30 @@ fi
|
|
|
101
101
|
|
|
102
102
|
return True
|
|
103
103
|
|
|
104
|
+
def module_run_install_scripts(self, module_name):
|
|
105
|
+
"""
|
|
106
|
+
Run module installation scripts
|
|
107
|
+
"""
|
|
108
|
+
if not os.path.exists(os.path.join(config.MODULES_SRC, module_name)):
|
|
109
|
+
self.logger.error('Module "%s" doesn\'t exist [%s]' % (module_name, os.path.join(config.MODULES_SRC, module_name)))
|
|
110
|
+
return False
|
|
111
|
+
|
|
112
|
+
preinst_script = os.path.join(config.MODULES_SCRIPTS_DST, module_name, "preinst.sh")
|
|
113
|
+
postinst_script = os.path.join(config.MODULES_SCRIPTS_DST, module_name, "postinst.sh")
|
|
114
|
+
console = Console()
|
|
115
|
+
|
|
116
|
+
if os.path.exists(preinst_script):
|
|
117
|
+
self.logger.info('Running %s scripts', preinst_script)
|
|
118
|
+
resp = console.command(preinst_script, timeout=300)
|
|
119
|
+
if resp["returncode"] != 0:
|
|
120
|
+
self.logger.error('Error running %s [%s]: %s', preinst_script, resp["returncode"], ''.join(resp["stderr"]))
|
|
121
|
+
return False
|
|
122
|
+
|
|
123
|
+
if os.path.exists(postinst_script):
|
|
124
|
+
self.logger.info('Running %s scripts', postinst_script)
|
|
125
|
+
resp = console.command(postinst_script, timeout=300)
|
|
126
|
+
if resp["returncode"] != 0:
|
|
127
|
+
self.logger.error('Error running %s [%s]: %s', postinst_script, resp["returncode"], ''.join(resp["stderr"]))
|
|
128
|
+
return False
|
|
129
|
+
|
|
130
|
+
return True
|
|
@@ -8,18 +8,20 @@ import time
|
|
|
8
8
|
import logging
|
|
9
9
|
from . import config
|
|
10
10
|
from watchdog.observers import Observer
|
|
11
|
-
from watchdog.events import
|
|
11
|
+
from watchdog.events import PatternMatchingEventHandler, EVENT_TYPE_MODIFIED
|
|
12
12
|
import watchdog.events as events
|
|
13
13
|
from threading import Thread
|
|
14
14
|
from .cleepapi import CleepApi
|
|
15
15
|
from .file import File
|
|
16
16
|
from collections import deque
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
class ActionFileSync:
|
|
19
20
|
def __init__(self, module=None):
|
|
20
21
|
self.module = module
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
|
|
24
|
+
class ActionRestart:
|
|
23
25
|
def __init__(self, frontend=False):
|
|
24
26
|
self.frontend = frontend
|
|
25
27
|
|
|
@@ -29,6 +31,7 @@ class ActionsExecutor(Thread):
|
|
|
29
31
|
Actions executor
|
|
30
32
|
Implements queue to execute sequentially actions
|
|
31
33
|
"""
|
|
34
|
+
|
|
32
35
|
def __init__(self, rpc_url):
|
|
33
36
|
Thread.__init__(self)
|
|
34
37
|
Thread.daemon = True
|
|
@@ -80,51 +83,45 @@ class ActionsExecutor(Thread):
|
|
|
80
83
|
self.__execute_action(action)
|
|
81
84
|
|
|
82
85
|
except IndexError:
|
|
83
|
-
#no action available
|
|
86
|
+
# no action available
|
|
84
87
|
time.sleep(0.25)
|
|
85
88
|
|
|
86
89
|
except:
|
|
87
|
-
#error occured during action execution
|
|
88
|
-
self.logger.exception(
|
|
90
|
+
# error occured during action execution
|
|
91
|
+
self.logger.exception("Error during action execution:")
|
|
89
92
|
|
|
90
93
|
|
|
91
|
-
class CleepHandler(
|
|
94
|
+
class CleepHandler(PatternMatchingEventHandler):
|
|
92
95
|
"""
|
|
93
96
|
Watchdog handler for Cleep
|
|
94
97
|
"""
|
|
98
|
+
|
|
95
99
|
REJECTED_FILENAMES = [
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
"4913", # vim furtive temp file to check user permissions
|
|
101
|
+
".gitignore",
|
|
98
102
|
]
|
|
99
103
|
REJECTED_EXTENSIONS = [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
]
|
|
108
|
-
REJECTED_PREFIXES = [
|
|
109
|
-
'.',
|
|
110
|
-
'~'
|
|
111
|
-
]
|
|
112
|
-
REJECTED_SUFFIXES = [
|
|
113
|
-
'~'
|
|
104
|
+
".swp", # vim
|
|
105
|
+
".swpx", # vim
|
|
106
|
+
".swx", # vim
|
|
107
|
+
".tmp", # generic?
|
|
108
|
+
".offset", # pygtail
|
|
109
|
+
".pyc", # python compiled
|
|
110
|
+
".log", # log file
|
|
114
111
|
]
|
|
112
|
+
REJECTED_PREFIXES = [".", "~"]
|
|
113
|
+
REJECTED_SUFFIXES = ["~"]
|
|
115
114
|
REJECTED_DIRS = [
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
".git",
|
|
116
|
+
".vscode",
|
|
117
|
+
".editor",
|
|
118
|
+
"__pycache__",
|
|
120
119
|
]
|
|
121
|
-
DEBOUNCE = 0.25
|
|
120
|
+
DEBOUNCE = 0.25 # seconds
|
|
122
121
|
|
|
123
122
|
def __init__(self, actions_executor):
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
'frontend': 0
|
|
127
|
-
}
|
|
123
|
+
super().__init__(ignore_patterns=["(\.git|__pycache__|.vscode|.editor)"])
|
|
124
|
+
self.__last_times = {"backend": 0, "frontend": 0}
|
|
128
125
|
self.logger = logging.getLogger(self.__class__.__name__)
|
|
129
126
|
self.actions_executor = actions_executor
|
|
130
127
|
|
|
@@ -134,67 +131,74 @@ class CleepHandler(FileSystemEventHandler):
|
|
|
134
131
|
Return:
|
|
135
132
|
bool: True if event must be dropped
|
|
136
133
|
"""
|
|
137
|
-
#drop dir modified event or created file (that always comes with modified file)
|
|
134
|
+
# drop dir modified event or created file (that always comes with modified file)
|
|
138
135
|
if type(event) in (events.DirModifiedEvent, events.FileCreatedEvent):
|
|
139
|
-
self.logger.debug(
|
|
136
|
+
self.logger.debug(" Filtered: DirModifiedEvent or FileCreatedEvent")
|
|
137
|
+
return True
|
|
138
|
+
|
|
139
|
+
if event.event_type != EVENT_TYPE_MODIFIED:
|
|
140
|
+
self.logger.debug(" Filtered: not modified event type")
|
|
140
141
|
return True
|
|
141
142
|
|
|
142
|
-
#filter invalid event
|
|
143
|
+
# filter invalid event
|
|
143
144
|
if not event:
|
|
144
|
-
self.logger.debug(
|
|
145
|
+
self.logger.debug(" Filtered: invalid event")
|
|
145
146
|
return True
|
|
146
147
|
|
|
147
|
-
#filter
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
# filter on non
|
|
149
|
+
|
|
150
|
+
# filter event on current script
|
|
151
|
+
if event.src_path == ".%s" % __file__:
|
|
152
|
+
self.logger.debug(" Filtered: event on current script")
|
|
150
153
|
return True
|
|
151
154
|
|
|
152
|
-
#filter root event
|
|
153
|
-
if event.src_path ==
|
|
154
|
-
self.logger.debug(
|
|
155
|
+
# filter root event
|
|
156
|
+
if event.src_path == ".":
|
|
157
|
+
self.logger.debug(" Filtered: root event")
|
|
155
158
|
return True
|
|
156
159
|
|
|
157
|
-
#filter invalid extension
|
|
160
|
+
# filter invalid extension
|
|
158
161
|
src_ext = os.path.splitext(event.src_path)[1]
|
|
159
162
|
if src_ext in self.REJECTED_EXTENSIONS:
|
|
160
|
-
self.logger.debug(
|
|
163
|
+
self.logger.debug(" Filtered: invalid extension")
|
|
161
164
|
return True
|
|
162
165
|
|
|
163
|
-
#filter by prefix
|
|
166
|
+
# filter by prefix
|
|
164
167
|
for prefix in self.REJECTED_PREFIXES:
|
|
165
168
|
if event.src_path.startswith(prefix):
|
|
166
|
-
self.logger.debug(
|
|
169
|
+
self.logger.debug(" Filtered: source prefix")
|
|
167
170
|
return True
|
|
168
|
-
if getattr(event,
|
|
169
|
-
self.logger.debug(
|
|
171
|
+
if getattr(event, "dest_path", None) and event.dest_path.startswith(prefix):
|
|
172
|
+
self.logger.debug(" Filtered: destination prefix")
|
|
170
173
|
return True
|
|
171
174
|
|
|
172
|
-
#filter by suffix
|
|
175
|
+
# filter by suffix
|
|
173
176
|
for suffix in self.REJECTED_SUFFIXES:
|
|
174
177
|
if event.src_path.endswith(suffix):
|
|
175
|
-
self.logger.debug(
|
|
178
|
+
self.logger.debug("Filtered: source suffix")
|
|
176
179
|
return True
|
|
177
|
-
if getattr(event,
|
|
178
|
-
self.logger.debug(
|
|
180
|
+
if getattr(event, "dest_path", None) and event.dest_path.endswith(prefix):
|
|
181
|
+
self.logger.debug(" Filtered: destination suffix")
|
|
179
182
|
return True
|
|
180
183
|
|
|
181
|
-
#filter by filename
|
|
184
|
+
# filter by filename
|
|
182
185
|
for filename in self.REJECTED_FILENAMES:
|
|
183
186
|
if event.src_path.endswith(filename):
|
|
184
|
-
self.logger.debug(
|
|
187
|
+
self.logger.debug(" Filtered: filename")
|
|
185
188
|
return True
|
|
186
189
|
|
|
187
|
-
#filter by dir
|
|
190
|
+
# filter by dir
|
|
188
191
|
parts = event.src_path.split(os.path.sep)
|
|
189
192
|
for folder in self.REJECTED_DIRS:
|
|
190
193
|
if folder in parts:
|
|
191
|
-
self.logger.debug(
|
|
194
|
+
self.logger.debug(" Filtered: directory")
|
|
192
195
|
return True
|
|
193
196
|
|
|
197
|
+
self.logger.debug(" NotFiltered")
|
|
194
198
|
return False
|
|
195
199
|
|
|
196
200
|
def __debounce(self, now, last_time):
|
|
197
|
-
if now<(last_time+self.DEBOUNCE):
|
|
201
|
+
if now < (last_time + self.DEBOUNCE):
|
|
198
202
|
return True
|
|
199
203
|
return False
|
|
200
204
|
|
|
@@ -208,19 +212,19 @@ class CleepHandler(FileSystemEventHandler):
|
|
|
208
212
|
Returns:
|
|
209
213
|
module name (string) or None if nothing found
|
|
210
214
|
"""
|
|
211
|
-
pattern =
|
|
212
|
-
#self.logger.debug('Module pattern: %s' % pattern)
|
|
215
|
+
pattern = "^%s/(.*?)/(?:frontend|backend|scripts)/.*$" % (config.MODULES_SRC)
|
|
216
|
+
# self.logger.debug('Module pattern: %s' % pattern)
|
|
213
217
|
|
|
214
|
-
if hasattr(event,
|
|
218
|
+
if hasattr(event, "src_path"):
|
|
215
219
|
res = re.findall(pattern, event.src_path)
|
|
216
|
-
if res and len(res)>0:
|
|
220
|
+
if res and len(res) > 0:
|
|
217
221
|
return res[0]
|
|
218
222
|
|
|
219
|
-
if hasattr(event,
|
|
223
|
+
if hasattr(event, "dest_path"):
|
|
220
224
|
res = re.findall(pattern, event.dest_path)
|
|
221
|
-
if res and len(res)>0:
|
|
225
|
+
if res and len(res) > 0:
|
|
222
226
|
return res[0]
|
|
223
|
-
|
|
227
|
+
|
|
224
228
|
return None
|
|
225
229
|
|
|
226
230
|
def __change_on_core(self, event):
|
|
@@ -233,18 +237,21 @@ class CleepHandler(FileSystemEventHandler):
|
|
|
233
237
|
Returns:
|
|
234
238
|
True if change occurs in core, False otherwise
|
|
235
239
|
"""
|
|
236
|
-
pattern_core =
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
pattern_core = "^(%s/(?!tests|modules)(.*\.py)|%s/.*)$" % (
|
|
241
|
+
config.CORE_SRC,
|
|
242
|
+
config.HTML_SRC,
|
|
243
|
+
)
|
|
244
|
+
pattern_bin = "^%s/cleep" % (config.BIN_SRC)
|
|
245
|
+
# self.logger.debug('Core pattern: %s' % pattern_core)
|
|
246
|
+
# self.logger.debug('Bin pattern: %s' % pattern_bin)
|
|
247
|
+
|
|
248
|
+
if hasattr(event, "src_path"):
|
|
242
249
|
if re.search(pattern_core, event.src_path):
|
|
243
250
|
return True
|
|
244
251
|
if re.search(pattern_bin, event.src_path):
|
|
245
252
|
return True
|
|
246
253
|
|
|
247
|
-
if hasattr(event,
|
|
254
|
+
if hasattr(event, "dest_path"):
|
|
248
255
|
if re.search(pattern_core, event.dest_path):
|
|
249
256
|
return True
|
|
250
257
|
|
|
@@ -260,15 +267,18 @@ class CleepHandler(FileSystemEventHandler):
|
|
|
260
267
|
Returns:
|
|
261
268
|
True if change on frontend, False otherwise
|
|
262
269
|
"""
|
|
263
|
-
pattern =
|
|
264
|
-
|
|
270
|
+
pattern = "^(%s/|%s/(?:.*?)/frontend/).*$" % (
|
|
271
|
+
config.HTML_SRC,
|
|
272
|
+
config.MODULES_SRC,
|
|
273
|
+
)
|
|
274
|
+
# self.logger.debug('Frontend pattern: %s' % pattern)
|
|
265
275
|
|
|
266
|
-
if hasattr(event,
|
|
276
|
+
if hasattr(event, "src_path"):
|
|
267
277
|
res = re.search(pattern, event.src_path)
|
|
268
278
|
if res:
|
|
269
279
|
return True
|
|
270
280
|
|
|
271
|
-
if hasattr(event,
|
|
281
|
+
if hasattr(event, "dest_path"):
|
|
272
282
|
res = re.search(pattern, event.dest_path)
|
|
273
283
|
if res:
|
|
274
284
|
return True
|
|
@@ -278,51 +288,54 @@ class CleepHandler(FileSystemEventHandler):
|
|
|
278
288
|
def on_any_event(self, event):
|
|
279
289
|
try:
|
|
280
290
|
now = time.time()
|
|
281
|
-
self.logger.debug(
|
|
291
|
+
self.logger.debug("Event: %s" % event)
|
|
282
292
|
if not self.__is_event_dropped(event):
|
|
283
293
|
self.__last_action_time = now
|
|
284
294
|
|
|
285
|
-
#is event on backend or frontend ?
|
|
295
|
+
# is event on backend or frontend ?
|
|
286
296
|
frontend = self.__change_on_frontend(event)
|
|
287
297
|
|
|
288
|
-
#debounce ?
|
|
289
|
-
if self.__debounce(
|
|
290
|
-
self.
|
|
291
|
-
|
|
298
|
+
# debounce ?
|
|
299
|
+
if self.__debounce(
|
|
300
|
+
now, self.__last_times[("frontend" if frontend else "backend")]
|
|
301
|
+
):
|
|
302
|
+
self.logger.debug(" Dropped by debounce")
|
|
303
|
+
return
|
|
292
304
|
|
|
293
|
-
#is event on module ?
|
|
305
|
+
# is event on module ?
|
|
294
306
|
change_on_core = False
|
|
295
307
|
change_on_module = self.__change_on_module(event)
|
|
296
308
|
if change_on_module is None:
|
|
297
309
|
change_on_core = self.__change_on_core(event)
|
|
298
310
|
|
|
299
|
-
#push action and update last action time
|
|
311
|
+
# push action and update last action time
|
|
300
312
|
if change_on_module:
|
|
301
313
|
self.logger.debug(' Change on module "%s"' % change_on_module)
|
|
302
314
|
self.actions_executor.add_action(ActionFileSync(change_on_module))
|
|
303
315
|
elif change_on_core:
|
|
304
|
-
self.logger.debug(
|
|
316
|
+
self.logger.debug(" Change on core")
|
|
305
317
|
self.actions_executor.add_action(ActionFileSync())
|
|
306
318
|
else:
|
|
307
|
-
self.logger.debug(
|
|
319
|
+
self.logger.debug(" Dropped due to useless change")
|
|
308
320
|
return
|
|
309
321
|
if frontend:
|
|
310
|
-
self.logger.debug(
|
|
322
|
+
self.logger.debug(" Change on frontend")
|
|
311
323
|
self.actions_executor.add_action(ActionRestart(True))
|
|
312
|
-
self.__last_times[
|
|
324
|
+
self.__last_times["frontend"] = now
|
|
313
325
|
else:
|
|
314
|
-
self.logger.debug(
|
|
326
|
+
self.logger.debug(" Change on backend")
|
|
315
327
|
self.actions_executor.add_action(ActionRestart())
|
|
316
|
-
self.__last_times[
|
|
328
|
+
self.__last_times["backend"] = now
|
|
317
329
|
|
|
318
330
|
except:
|
|
319
|
-
self.logger.exception(
|
|
331
|
+
self.logger.exception("Error occured during watcher event processing:")
|
|
320
332
|
|
|
321
333
|
|
|
322
|
-
class CleepWatchdog
|
|
334
|
+
class CleepWatchdog:
|
|
323
335
|
"""
|
|
324
336
|
Cleep core and module watchdog
|
|
325
337
|
"""
|
|
338
|
+
|
|
326
339
|
def __init__(self, rpc_url):
|
|
327
340
|
"""
|
|
328
341
|
Constructor
|
|
@@ -337,11 +350,13 @@ class CleepWatchdog():
|
|
|
337
350
|
"""
|
|
338
351
|
Start watchdog that monitors filesystem changes on Cleep sources
|
|
339
352
|
"""
|
|
340
|
-
path =
|
|
353
|
+
path = "%s/" % config.REPO_DIR
|
|
341
354
|
self.actions_executor.start()
|
|
342
355
|
|
|
343
356
|
if not os.path.exists(path):
|
|
344
|
-
self.logger.error(
|
|
357
|
+
self.logger.error(
|
|
358
|
+
'Please get Cleep sources using "cleep-cli getcore" command'
|
|
359
|
+
)
|
|
345
360
|
return False
|
|
346
361
|
|
|
347
362
|
event_handler = CleepHandler(self.actions_executor)
|
|
@@ -358,4 +373,3 @@ class CleepWatchdog():
|
|
|
358
373
|
observer.join()
|
|
359
374
|
|
|
360
375
|
return True
|
|
361
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|