LEFT | RIGHT |
(no file at all) | |
1 #This file is part of Tryton. The COPYRIGHT file at the top level of | 1 #This file is part of Tryton. The COPYRIGHT file at the top level of |
2 #this repository contains the full copyright notices and license terms. | 2 #this repository contains the full copyright notices and license terms. |
3 import sys | 3 import sys |
4 import os | 4 import os |
5 import subprocess | 5 import subprocess |
6 from threading import Lock | 6 from threading import Lock |
7 from trytond.modules import get_module_list | 7 from trytond.modules import get_module_list |
8 | 8 |
9 _LOCK = Lock() | 9 _LOCK = Lock() |
10 _TIMES = {} | 10 _TIMES = {} |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 | 34 |
35 def monitor(): | 35 def monitor(): |
36 ''' | 36 ''' |
37 Monitor module files for change | 37 Monitor module files for change |
38 | 38 |
39 :return: True if at least one file has changed | 39 :return: True if at least one file has changed |
40 ''' | 40 ''' |
41 global _MODULES | 41 global _MODULES |
42 modified = False | 42 modified = False |
| 43 directories = set() |
43 for module in sys.modules.keys(): | 44 for module in sys.modules.keys(): |
44 if not module.startswith('trytond.'): | 45 if not module.startswith('trytond.'): |
45 continue | 46 continue |
46 if not hasattr(sys.modules[module], '__file__'): | 47 if not hasattr(sys.modules[module], '__file__'): |
47 continue | 48 continue |
48 path = getattr(sys.modules[module], '__file__') | 49 path = getattr(sys.modules[module], '__file__') |
49 if not path: | 50 if not path: |
50 continue | 51 continue |
51 if os.path.splitext(path)[1] in ['.pyc', '.pyo', '.pyd']: | 52 if os.path.splitext(path)[1] in ['.pyc', '.pyo', '.pyd']: |
52 path = path[:-1] | 53 path = path[:-1] |
53 if _modified(path): | 54 if _modified(path): |
54 if subprocess.call((sys.executable, '-c', 'import %s' % module), | 55 if subprocess.call((sys.executable, '-c', 'import %s' % module), |
55 cwd=os.path.dirname(os.path.abspath(os.path.normpath( | 56 cwd=os.path.dirname(os.path.abspath(os.path.normpath( |
56 os.path.join(__file__, '..'))))): | 57 os.path.join(__file__, '..'))))): |
57 modified = False | 58 modified = False |
58 break | 59 break |
59 modified = True | 60 modified = True |
| 61 |
| 62 # Check view XML |
| 63 directory = os.path.dirname(path) |
| 64 if directory not in directories: |
| 65 directories.add(directory) |
| 66 view_dir = os.path.join(directory, 'view') |
| 67 if os.path.isdir(view_dir): |
| 68 for view in os.listdir(view_dir): |
| 69 view = os.path.join(view_dir, view) |
| 70 if os.path.splitext(view)[1] == '.xml': |
| 71 if _modified(view): |
| 72 modified = True |
| 73 |
60 modules = set(get_module_list()) | 74 modules = set(get_module_list()) |
61 if _MODULES is None: | 75 if _MODULES is None: |
62 _MODULES = modules | 76 _MODULES = modules |
63 for module in modules.difference(_MODULES): | 77 for module in modules.difference(_MODULES): |
64 if subprocess.call((sys.executable, '-c', | 78 if subprocess.call((sys.executable, '-c', |
65 'import trytond.modules.%s' % module)): | 79 'import trytond.modules.%s' % module)): |
66 modified = False | 80 modified = False |
67 break | 81 break |
68 modified = True | 82 modified = True |
69 _MODULES = modules | 83 _MODULES = modules |
70 return modified | 84 return modified |
LEFT | RIGHT |