feat: Add basic struture for tests
This commit is contained in:
52
.dev/dev.py
Executable file
52
.dev/dev.py
Executable file
@@ -0,0 +1,52 @@
|
||||
# script para refrescar cambios de xml del modulo de tryton
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
import time
|
||||
|
||||
import inotify.adapters
|
||||
|
||||
logging.basicConfig(level=logging.INFO, stream=sys.stderr)
|
||||
|
||||
SRC = os.environ['SRC'] + '/modules/'
|
||||
MODULES = os.environ['MODULES'].split(':')
|
||||
DB_NAME = os.environ['DB_NAME']
|
||||
|
||||
|
||||
def _main():
|
||||
i = inotify.adapters.Inotify()
|
||||
logging.info("MONITOREANDO ARCHIVOS EN %s", SRC)
|
||||
|
||||
for module in MODULES:
|
||||
logging.info('NOMBRE DEL MODULO A MONITOREAR%s', module)
|
||||
i.add_watch(
|
||||
SRC + module)
|
||||
|
||||
for event in i.event_gen(yield_nones=False):
|
||||
(_, type_names, path, filename) = event
|
||||
(_, ext) = os.path.splitext(filename)
|
||||
|
||||
if 'IN_CLOSE_WRITE' not in type_names:
|
||||
continue
|
||||
|
||||
module_name = path.split('/')[-1]
|
||||
logging.info('NOMBRE DEL MODULO %s', module_name)
|
||||
|
||||
if ext in ['.py', '.xml', '.cfg']:
|
||||
for _ in range(0, 10):
|
||||
command = "trytond-admin -d {} -u {} --act -vv".format(
|
||||
DB_NAME, module_name)
|
||||
logging.debug("Ejecutando comando: %s", command)
|
||||
update_module = os.system(command)
|
||||
if update_module != 0:
|
||||
time.sleep(2)
|
||||
logging.error("fallo trytond-admin")
|
||||
else:
|
||||
logging.info(
|
||||
"ACTUALIZADO TRYTOND POR CAMBIO DE ARCHIVO %s",
|
||||
filename)
|
||||
break
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_main()
|
||||
Reference in New Issue
Block a user