From 7c2e4a9634d503532c823fb337d8a3bafcb6a170 Mon Sep 17 00:00:00 2001 From: robertatakenaka Date: Thu, 19 Apr 2018 13:14:34 -0300 Subject: [PATCH 1/5] Atualizacao do version.txt --- src/scielo/bin/cfg/version.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scielo/bin/cfg/version.txt b/src/scielo/bin/cfg/version.txt index 67fa4af08..709ac5537 100644 --- a/src/scielo/bin/cfg/version.txt +++ b/src/scielo/bin/cfg/version.txt @@ -1,5 +1,5 @@ -4.0.095 Teste 29/03/2018 -======================== +4.0.095 29/03/2018 +================== - Installation with proxy - Markup XML From 978ad37fb8bd84cc8d7b84e398bcc99030b6adfc Mon Sep 17 00:00:00 2001 From: robertatakenaka Date: Thu, 19 Apr 2018 17:42:33 -0300 Subject: [PATCH 2/5] 40095_install_requirements - questoes de proxy e de ambiente virtual --- src/scielo/bin/xml/app_modules/__init__.py | 44 ++++------ .../xml/app_modules/app/config/app_caller.py | 86 +++++++++++++++---- .../bin/xml/app_modules/app/config/config.py | 4 + src/scielo/bin/xml/run_app.py | 35 ++++++-- 4 files changed, 118 insertions(+), 51 deletions(-) diff --git a/src/scielo/bin/xml/app_modules/__init__.py b/src/scielo/bin/xml/app_modules/__init__.py index 8899b3b80..2fa0b10b8 100644 --- a/src/scielo/bin/xml/app_modules/__init__.py +++ b/src/scielo/bin/xml/app_modules/__init__.py @@ -1,29 +1,29 @@ # coding=utf-8 import os -try: - from app_modules.app.config import app_texts -except Exception as e: - print(e) - from .app.config import app_texts - -try: - from app_modules.app.config import app_caller -except Exception as e: - print(e) - from .app.config import app_caller try: - from app_modules.generics import logger -except Exception as e: - print(e) - from .generics import logger + from app_modules.app.config import ( + app_texts, + app_caller, + ) + from app_modules.generics import ( + logger, + encoding, + system, + ) -try: - from app_modules.generics import encoding except Exception as e: print(e) - from .generics import encoding + from .app.config import ( + app_texts, + app_caller, + ) + from .generics import ( + logger, + encoding, + system, + ) THIS_FILE_LOCATION = os.path.dirname(os.path.realpath(__file__)).replace('\\', '/') @@ -31,7 +31,7 @@ INVALID_APP_PATH = not str(THIS_LOCATION) == THIS_FILE_LOCATION -BIN_PATH = THIS_LOCATION + '/../..' +BIN_PATH = os.path.dirname(os.path.dirname(THIS_LOCATION)) BIN_XML_PATH = BIN_PATH + '/xml' JAR_PATH = BIN_PATH + '/jar' RELATIVE_JAR_PATH = JAR_PATH.replace(BIN_PATH, './..') @@ -66,9 +66,3 @@ os.unlink(LOG_PATH+'/app_caller.log') except: pass - - -appcaller = app_caller.AppCaller( - logger.get_logger(LOG_PATH+'/app_caller.log', 'Environment'), - VENV_PATH, - REQUIREMENTS_FILE) diff --git a/src/scielo/bin/xml/app_modules/app/config/app_caller.py b/src/scielo/bin/xml/app_modules/app/config/app_caller.py index 1841fe477..69f2ff0b5 100644 --- a/src/scielo/bin/xml/app_modules/app/config/app_caller.py +++ b/src/scielo/bin/xml/app_modules/app/config/app_caller.py @@ -66,11 +66,11 @@ def register_commands(self): class VirtualEnv(object): - def __init__(self, logger, venv_path, requirements_filename): + def __init__(self, logger, venv_path, requirements_filename, proxy_data): self.logger = logger self.path = venv_path self.requirements = Requirements(requirements_filename) - self.proxy = ProxyInfo(None) + self.proxy = ProxyInfo(proxy_data) self.setUp() def setUp(self): @@ -153,6 +153,27 @@ def deactivate(self): system.run_command(self.deactivate_command, True) +class RealEnv(object): + + def __init__(self, logger, requirements_filename, proxy_data): + self.logger = logger + self.requirements = Requirements(requirements_filename) + self.proxy = ProxyInfo(proxy_data) + + def install_requirements(self): + commands = self.requirements.install_commands( + self.proxy, + uninstall=True) + self.execute_commands(commands) + + def execute_commands(self, commands): + for cmd in commands: + display_cmd = self.proxy.hide_password(cmd) + self.logger.info(display_cmd) + encoding.display_message(display_cmd) + system.run_command(cmd, False) + + class Requirements(object): def __init__(self, requirements_file): @@ -179,30 +200,59 @@ def uninstall_commands(self): return commands -class AppCaller(object): +class VEnvAppCaller(object): - def __init__(self, logger, venv_path, req_file): - self.venv = VirtualEnv(logger, venv_path, req_file) - - @property - def proxy(self): - return self.venv.proxy - - @proxy.setter - def proxy(self, value): - self.venv.proxy = ProxyInfo(value) + def __init__(self, logger, venv_path, req_file, proxy_data): + self.environment = VirtualEnv(logger, venv_path, req_file, proxy_data) def install_virtualenv(self, recreate=False): inform('Install virtualenv') - self.venv.install_venv() - if self.venv.installed: + self.environment.install_venv() + if self.environment.installed: inform('Install virtualenv: done!') def install_requirements(self): - if self.venv.installed: + if self.environment.installed: inform('Install Requirements') - self.venv.install_requirements() + self.environment.install_requirements() #inform('Install Requirements: done!') def execute(self, commands): - self.venv.execute_in_virtualenv(commands) + self.environment.execute_in_virtualenv(commands) + + +class RealAppCaller(object): + + def __init__(self, logger, venv_path, req_file, proxy_data): + self.environment = RealEnv(logger, req_file, proxy_data) + + def install_virtualenv(self, recreate=False): + pass + + def install_requirements(self): + self.environment.install_requirements() + + def execute(self, commands): + self.environment.execute_commands(commands) + + +class AppCaller(object): + + def __init__(self, logger, venv_path, req_file, proxy_data): + self.caller = None + if venv_path is not None: + virtual = VEnvAppCaller(logger, venv_path, req_file, proxy_data) + virtual.install_virtualenv(True) + if virtual.environment.installed: + self.caller = virtual + if self.caller is None: + self.caller = RealAppCaller(logger, venv_path, req_file, proxy_data) + + def install_virtualenv(self, recreate=False): + self.caller.install_virtualenv(recreate) + + def install_requirements(self): + self.caller.install_requirements() + + def execute(self, commands): + self.caller.execute(commands) diff --git a/src/scielo/bin/xml/app_modules/app/config/config.py b/src/scielo/bin/xml/app_modules/app/config/config.py index afbe4ed63..dd1306714 100644 --- a/src/scielo/bin/xml/app_modules/app/config/config.py +++ b/src/scielo/bin/xml/app_modules/app/config/config.py @@ -454,5 +454,9 @@ def coded_table_required(self): def BLOCK_DISAGREEMENT_WITH_COLLECTION_CRITERIA(self): return self.is_activated('BLOCK_DISAGREEMENT_WITH_COLLECTION_CRITERIA') + @property + def USE_VIRTUAL_ENV(self): + return self.is_activated('USE_VIRTUAL_ENV') + def is_activated(self, label, default='TRUE'): return self._data.get(label, default).upper() in ['ON', 'TRUE', 'YES'] diff --git a/src/scielo/bin/xml/run_app.py b/src/scielo/bin/xml/run_app.py index e49ba5f83..c9b2098fd 100644 --- a/src/scielo/bin/xml/run_app.py +++ b/src/scielo/bin/xml/run_app.py @@ -1,10 +1,29 @@ import sys -from app_modules.generics import encoding -from app_modules.generics import system -from app_modules.__init__ import appcaller -from app_modules.__init__ import BIN_XML_PATH -from app_modules.app.config import config +from app_modules.generics import ( + encoding, + system, + logger, +) +from app_modules.app.config import ( + app_caller, + config, +) +from app_modules.__init__ import ( + BIN_XML_PATH, + LOG_PATH, + VENV_PATH, + REQUIREMENTS_FILE, +) + +configuration = config.Configuration() + +appcaller = app_caller.AppCaller( + logger.get_logger(LOG_PATH+'/app_caller.log', 'Environment'), + VENV_PATH if configuration.USE_VIRTUAL_ENV is True else None, + REQUIREMENTS_FILE, + configuration.proxy_info +) def execute(parameters): @@ -46,9 +65,9 @@ def main(parameters): from app_modules.app import xc xc.call_converter(argv, '1.1') elif parameters[1] == 'install': - configuration = config.Configuration() - proxy_info = configuration.proxy_info - appcaller.proxy = system.proxy_data(proxy_info) + # configuration = config.Configuration() + # proxy_info = configuration.proxy_info + # appcaller.proxy = system.proxy_data(proxy_info) appcaller.install_virtualenv(True) appcaller.install_requirements() else: From 43522762dee7f0e4271e0653176aee3457270342 Mon Sep 17 00:00:00 2001 From: robertatakenaka Date: Fri, 20 Apr 2018 17:49:56 -0300 Subject: [PATCH 3/5] 40095_install_requirements --- .../xml/app_modules/app/config/app_caller.py | 72 +++++++++++++------ .../bin/xml/app_modules/generics/system.py | 2 +- src/scielo/bin/xml/run_app.py | 8 ++- 3 files changed, 58 insertions(+), 24 deletions(-) diff --git a/src/scielo/bin/xml/app_modules/app/config/app_caller.py b/src/scielo/bin/xml/app_modules/app/config/app_caller.py index 69f2ff0b5..cab6e59f2 100644 --- a/src/scielo/bin/xml/app_modules/app/config/app_caller.py +++ b/src/scielo/bin/xml/app_modules/app/config/app_caller.py @@ -66,11 +66,11 @@ def register_commands(self): class VirtualEnv(object): - def __init__(self, logger, venv_path, requirements_filename, proxy_data): + def __init__(self, logger, venv_path, requirements_filename): self.logger = logger self.path = venv_path self.requirements = Requirements(requirements_filename) - self.proxy = ProxyInfo(proxy_data) + self.proxy_info = ProxyInfo(None) self.setUp() def setUp(self): @@ -99,17 +99,21 @@ def install_venv(self): if self.path is not None: if not self.installed: commands = [] - commands.extend(self.proxy.register_commands) + commands.extend(self.proxy_info.register_commands) + commands.append( + 'python -m pip install {} -U pip'.format( + self.proxy_info.parameter) + ) commands.append( 'python -m pip install {} --upgrade pip'.format( - self.proxy.parameter) + self.proxy_info.parameter) ) commands.append( - 'pip install {} virtualenv'.format(self.proxy.parameter) + 'pip install {} virtualenv'.format(self.proxy_info.parameter) ) commands.append(u'virtualenv "{}"'.format(self.path)) for cmd in commands: - if 'teste' in self.proxy.parameter: + if 'teste' in self.proxy_info.parameter: encoding.display_message('Executaria\n {}'.format(cmd)) else: system.run_command(cmd) @@ -122,7 +126,7 @@ def install_venv(self): def install_requirements(self): commands = self.requirements.install_commands( - self.proxy, + self.proxy_info, uninstall=True) self.execute_in_virtualenv(commands) @@ -136,7 +140,7 @@ def execute_in_virtualenv(self, commands): def _execute_inline(self, commands): _commands = [item for item in commands if len(item) > 0] cmd = self.sep.join(_commands) - display_cmd = self.proxy.hide_password(cmd) + display_cmd = self.proxy_info.hide_password(cmd) self.logger.info(display_cmd) if 'teste' in cmd: encoding.display_message('Executaria\n {}'.format(cmd)) @@ -155,23 +159,23 @@ def deactivate(self): class RealEnv(object): - def __init__(self, logger, requirements_filename, proxy_data): + def __init__(self, logger, requirements_filename): self.logger = logger self.requirements = Requirements(requirements_filename) - self.proxy = ProxyInfo(proxy_data) + self.proxy_info = ProxyInfo(None) def install_requirements(self): commands = self.requirements.install_commands( - self.proxy, + self.proxy_info, uninstall=True) self.execute_commands(commands) def execute_commands(self, commands): for cmd in commands: - display_cmd = self.proxy.hide_password(cmd) + display_cmd = self.proxy_info.hide_password(cmd) self.logger.info(display_cmd) encoding.display_message(display_cmd) - system.run_command(cmd, False) + os.system(cmd) class Requirements(object): @@ -184,6 +188,10 @@ def install_commands(self, proxy, uninstall): if uninstall is True: commands = self.uninstall_commands() commands.extend(proxy.register_commands) + commands.append( + 'python -m pip install {} -U pip'.format( + proxy.parameter) + ) commands.append( 'python -m pip install {} --upgrade pip'.format( proxy.parameter) @@ -202,8 +210,16 @@ def uninstall_commands(self): class VEnvAppCaller(object): - def __init__(self, logger, venv_path, req_file, proxy_data): - self.environment = VirtualEnv(logger, venv_path, req_file, proxy_data) + def __init__(self, logger, venv_path, req_file): + self.environment = VirtualEnv(logger, venv_path, req_file) + + @property + def proxy_info(self): + return self.environment.proxy_info + + @proxy_info.setter + def proxy_info(self, _proxy_info): + self.environment.proxy_info = _proxy_info def install_virtualenv(self, recreate=False): inform('Install virtualenv') @@ -223,8 +239,16 @@ def execute(self, commands): class RealAppCaller(object): - def __init__(self, logger, venv_path, req_file, proxy_data): - self.environment = RealEnv(logger, req_file, proxy_data) + def __init__(self, logger, venv_path, req_file): + self.environment = RealEnv(logger, req_file) + + @property + def proxy_info(self): + return self.environment.proxy_info + + @proxy_info.setter + def proxy_info(self, _proxy_info): + self.environment.proxy_info = _proxy_info def install_virtualenv(self, recreate=False): pass @@ -238,15 +262,23 @@ def execute(self, commands): class AppCaller(object): - def __init__(self, logger, venv_path, req_file, proxy_data): + def __init__(self, logger, venv_path, req_file): self.caller = None if venv_path is not None: - virtual = VEnvAppCaller(logger, venv_path, req_file, proxy_data) + virtual = VEnvAppCaller(logger, venv_path, req_file) virtual.install_virtualenv(True) if virtual.environment.installed: self.caller = virtual if self.caller is None: - self.caller = RealAppCaller(logger, venv_path, req_file, proxy_data) + self.caller = RealAppCaller(logger, venv_path, req_file) + + @property + def proxy_data(self): + return self.caller.proxy_info + + @proxy_data.setter + def proxy_data(self, _proxy_data): + self.caller.proxy_info = ProxyInfo(_proxy_data) def install_virtualenv(self, recreate=False): self.caller.install_virtualenv(recreate) diff --git a/src/scielo/bin/xml/app_modules/generics/system.py b/src/scielo/bin/xml/app_modules/generics/system.py index 25e2d87b9..055851266 100644 --- a/src/scielo/bin/xml/app_modules/generics/system.py +++ b/src/scielo/bin/xml/app_modules/generics/system.py @@ -90,5 +90,5 @@ def command_proxy_parameter(command): def proxy_password(param): if ':' in param and '@' in param: p = param[param.find(':'):] - p = p[:p.find('@')+1] + p = p[:p.rfind('@')+1] return p diff --git a/src/scielo/bin/xml/run_app.py b/src/scielo/bin/xml/run_app.py index c9b2098fd..83f21f8e1 100644 --- a/src/scielo/bin/xml/run_app.py +++ b/src/scielo/bin/xml/run_app.py @@ -16,13 +16,15 @@ REQUIREMENTS_FILE, ) + configuration = config.Configuration() +# proxy_data = system.proxy_data(configuration.proxy_info) + appcaller = app_caller.AppCaller( logger.get_logger(LOG_PATH+'/app_caller.log', 'Environment'), VENV_PATH if configuration.USE_VIRTUAL_ENV is True else None, - REQUIREMENTS_FILE, - configuration.proxy_info + REQUIREMENTS_FILE ) @@ -67,7 +69,7 @@ def main(parameters): elif parameters[1] == 'install': # configuration = config.Configuration() # proxy_info = configuration.proxy_info - # appcaller.proxy = system.proxy_data(proxy_info) + appcaller.proxy_data = system.proxy_data(configuration.proxy_info) appcaller.install_virtualenv(True) appcaller.install_requirements() else: From bd88b2727e8e950cfe71e8aa5239e201947dd761 Mon Sep 17 00:00:00 2001 From: robertatakenaka Date: Wed, 25 Apr 2018 09:33:55 -0300 Subject: [PATCH 4/5] 40095_install_requirements_v2 --- .../xml/app_modules/app/config/app_caller.py | 172 ++++++++++-------- .../app/pkg_processors/pkg_processors.py | 17 ++ .../article_content_validations.py | 6 +- src/scielo/bin/xml/app_modules/app/xpm.py | 11 +- .../bin/xml/app_modules/generics/encoding.py | 2 +- .../bin/xml/app_modules/generics/system.py | 6 +- .../bin/xml/app_modules/generics/utils.py | 9 + .../xml/app_modules/generics/ws/ws_proxy.py | 1 + .../app_modules/generics/ws/ws_proxy_gui.py | 38 +++- .../app_modules/generics/ws/ws_requester.py | 3 + src/scielo/bin/xml/run_app.py | 15 +- 11 files changed, 177 insertions(+), 103 deletions(-) diff --git a/src/scielo/bin/xml/app_modules/app/config/app_caller.py b/src/scielo/bin/xml/app_modules/app/config/app_caller.py index cab6e59f2..8b48aff08 100644 --- a/src/scielo/bin/xml/app_modules/app/config/app_caller.py +++ b/src/scielo/bin/xml/app_modules/app/config/app_caller.py @@ -6,6 +6,9 @@ from ...generics import encoding +# proxy_data = system.proxy_data(configuration.proxy_info) + + so, node, release, version, machine, processor = platform.uname() python_version = platform.python_version() so = so.lower() @@ -64,16 +67,30 @@ def register_commands(self): return commands +def gen_proxy_info(proxy_server_port): + return ProxyInfo(system.proxy_data(proxy_server_port)) + + class VirtualEnv(object): - def __init__(self, logger, venv_path, requirements_filename): + def __init__(self, logger, venv_path, requirements_filename, proxy_server_port): + print('VirtualEnv()') self.logger = logger self.path = venv_path self.requirements = Requirements(requirements_filename) - self.proxy_info = ProxyInfo(None) + self.proxy_server_port = proxy_server_port + self._proxy_info = None self.setUp() + @property + def proxy_info(self): + print('proxy_info') + if self._proxy_info is None: + self._proxy_info = gen_proxy_info(self.proxy_server_port) + return self._proxy_info + def setUp(self): + print('setUp') if 'windows' in so: self.activate_filename = u'{}/Scripts/activate.bat'.format(self.path) self.activate_command = u'call "{}"'.format(self.activate_filename) @@ -88,16 +105,20 @@ def setUp(self): self.activate_command = '' self.deactivate_command = '' + def inform_status(self): + print('inform_status') + if self.installed is False: + inform(u'Not found: "{}"'.format(self.activate_filename)) + @property def installed(self): - status = os.path.isfile(self.activate_filename) - if status is False: - inform(u'Missing virtualenv: "{}"'.format(self.activate_filename)) - return status + print('installed') + return os.path.isfile(self.activate_filename) - def install_venv(self): + def install_venv(self, recreate=False): + print('install_venv') if self.path is not None: - if not self.installed: + if not self.installed or recreate: commands = [] commands.extend(self.proxy_info.register_commands) commands.append( @@ -124,29 +145,35 @@ def install_venv(self): inform(u'Unable to create the virtualenv: "{}"'.format(self.path)) inform('Install the programs in a path which does not have diacritics') - def install_requirements(self): + def install_requirements(self, requirements_checker=None): + print('install_requirements') commands = self.requirements.install_commands( - self.proxy_info, - uninstall=True) + self.proxy_info, + uninstall=True) self.execute_in_virtualenv(commands) def execute_in_virtualenv(self, commands): - self.install_venv() + print('execute_in_virtualenv') if self.installed: _commands = [self.activate_command] - _commands.extend(commands) - self._execute_inline(_commands) + _commands.extend(commands) + self._execute_inline(_commands) def _execute_inline(self, commands): + print('_execute_inline') _commands = [item for item in commands if len(item) > 0] - cmd = self.sep.join(_commands) + start = '' + end = '' + sep = self.sep + if '&' in self.sep: + sep = '\n' + start = '(' + end = ')' + cmd = '{}{}{}'.format(start, sep.join(_commands), end) display_cmd = self.proxy_info.hide_password(cmd) self.logger.info(display_cmd) - if 'teste' in cmd: - encoding.display_message('Executaria\n {}'.format(cmd)) - else: - encoding.display_message(display_cmd) - system.run_command(cmd, False) + encoding.display_message(display_cmd) + system.run_command(cmd, False) def activate(self): if self.installed: @@ -159,20 +186,32 @@ def deactivate(self): class RealEnv(object): - def __init__(self, logger, requirements_filename): + def __init__(self, logger, requirements_filename, proxy_server_port): + print('RealEnv()') self.logger = logger self.requirements = Requirements(requirements_filename) - self.proxy_info = ProxyInfo(None) + self.proxy_server_port = proxy_server_port + self._proxy_info = None - def install_requirements(self): - commands = self.requirements.install_commands( + @property + def proxy_info(self): + if self._proxy_info is None: + self._proxy_info = gen_proxy_info(self.proxy_server_port) + return self._proxy_info + + def install_requirements(self, requirements_checker=None): + reqs = 0 + if requirements_checker is not None: + reqs = requirements_checker() + if reqs > 0: + commands = self.requirements.install_commands( self.proxy_info, uninstall=True) - self.execute_commands(commands) + self.execute_commands(commands) def execute_commands(self, commands): for cmd in commands: - display_cmd = self.proxy_info.hide_password(cmd) + display_cmd = self.proxy_server_port.hide_password(cmd) self.logger.info(display_cmd) encoding.display_message(display_cmd) os.system(cmd) @@ -183,21 +222,21 @@ class Requirements(object): def __init__(self, requirements_file): self.requirements_file = requirements_file - def install_commands(self, proxy, uninstall): + def install_commands(self, proxy_info, uninstall): commands = [] if uninstall is True: commands = self.uninstall_commands() - commands.extend(proxy.register_commands) + commands.extend(proxy_info.register_commands) commands.append( 'python -m pip install {} -U pip'.format( - proxy.parameter) + proxy_info.parameter) ) commands.append( 'python -m pip install {} --upgrade pip'.format( - proxy.parameter) + proxy_info.parameter) ) commands.append(u'pip install {} -r "{}"'.format( - proxy.parameter, self.requirements_file)) + proxy_info.parameter, self.requirements_file)) commands.append('pip freeze > python_libraries_installed.txt') return commands @@ -210,81 +249,56 @@ def uninstall_commands(self): class VEnvAppCaller(object): - def __init__(self, logger, venv_path, req_file): - self.environment = VirtualEnv(logger, venv_path, req_file) - - @property - def proxy_info(self): - return self.environment.proxy_info - - @proxy_info.setter - def proxy_info(self, _proxy_info): - self.environment.proxy_info = _proxy_info + def __init__(self, logger, venv_path, req_file, proxy_server_port): + self.env = VirtualEnv(logger, venv_path, req_file, proxy_server_port) def install_virtualenv(self, recreate=False): - inform('Install virtualenv') - self.environment.install_venv() - if self.environment.installed: - inform('Install virtualenv: done!') + self.env.install_venv(recreate) + self.env.inform_status() - def install_requirements(self): - if self.environment.installed: - inform('Install Requirements') - self.environment.install_requirements() - #inform('Install Requirements: done!') + def install_requirements(self, requirements_checker=None): + if self.env.installed: + self.env.install_requirements(requirements_checker) def execute(self, commands): - self.environment.execute_in_virtualenv(commands) + self.env.execute_in_virtualenv(commands) class RealAppCaller(object): - def __init__(self, logger, venv_path, req_file): - self.environment = RealEnv(logger, req_file) - - @property - def proxy_info(self): - return self.environment.proxy_info - - @proxy_info.setter - def proxy_info(self, _proxy_info): - self.environment.proxy_info = _proxy_info + def __init__(self, logger, venv_path, req_file, proxy_server_port): + self.env = RealEnv(logger, req_file, proxy_server_port) def install_virtualenv(self, recreate=False): pass - def install_requirements(self): - self.environment.install_requirements() + def install_requirements(self, requirements_checker=None): + self.env.install_requirements(requirements_checker) def execute(self, commands): - self.environment.execute_commands(commands) + self.env.execute_commands(commands) class AppCaller(object): - def __init__(self, logger, venv_path, req_file): + def __init__(self, logger, venv_path, req_file, proxy_server_port): + print('AppCaller()') self.caller = None if venv_path is not None: - virtual = VEnvAppCaller(logger, venv_path, req_file) - virtual.install_virtualenv(True) - if virtual.environment.installed: + virtual = VEnvAppCaller( + logger, venv_path, req_file, proxy_server_port) + virtual.install_virtualenv() + if virtual.env.installed: self.caller = virtual if self.caller is None: - self.caller = RealAppCaller(logger, venv_path, req_file) - - @property - def proxy_data(self): - return self.caller.proxy_info - - @proxy_data.setter - def proxy_data(self, _proxy_data): - self.caller.proxy_info = ProxyInfo(_proxy_data) + self.caller = RealAppCaller( + logger, venv_path, req_file, proxy_server_port) def install_virtualenv(self, recreate=False): self.caller.install_virtualenv(recreate) - def install_requirements(self): - self.caller.install_requirements() + def install_requirements(self, requirements_checker=None): + self.caller.install_requirements(requirements_checker) def execute(self, commands): self.caller.execute(commands) diff --git a/src/scielo/bin/xml/app_modules/app/pkg_processors/pkg_processors.py b/src/scielo/bin/xml/app_modules/app/pkg_processors/pkg_processors.py index 983ab253a..d849bbbe6 100644 --- a/src/scielo/bin/xml/app_modules/app/pkg_processors/pkg_processors.py +++ b/src/scielo/bin/xml/app_modules/app/pkg_processors/pkg_processors.py @@ -386,8 +386,13 @@ def normalized_package(self, xml_list): return package.Package(pkgfiles, outputs, workarea_path) def evaluate_package(self, pkg): + encoding.debugging('pkg_processors.make_package.evaluate_package - begin') registered_issue_data = registered.RegisteredIssue() + + encoding.debugging('pkg_processors.make_package.evaluate_package - get_registered_issue_data') self.registered_issues_manager.get_registered_issue_data(pkg.issue_data, registered_issue_data) + + encoding.debugging('pkg_processors.make_package.evaluate_package - affiliations') for xml_name in sorted(pkg.articles.keys()): a = pkg.articles[xml_name] if a is not None: @@ -397,12 +402,22 @@ def evaluate_package(self, pkg): institutions_results[aff_xml.id] = self.aff_normalizer.query_institutions(aff_xml) pkg.articles[xml_name].institutions_query_results = institutions_results pkg.articles[xml_name].normalized_affiliations = {aff_id: info[0] for aff_id, info in institutions_results.items()} + + encoding.debugging('pkg_processors.make_package.evaluate_package - validate_pkg_articles') pkg_validations = self.validate_pkg_articles(pkg, registered_issue_data) + encoding.debugging('pkg_processors.make_package.evaluate_package - validate_merged_articles') articles_mergence = self.validate_merged_articles(pkg, registered_issue_data) + + encoding.debugging('pkg_processors.make_package.evaluate_package - PkgArticlesValidationsReports') pkg_reports = pkg_articles_validations.PkgArticlesValidationsReports(pkg_validations, registered_issue_data.articles_db_manager is not None) + + encoding.debugging('pkg_processors.make_package.evaluate_package - MergedArticlesReports') mergence_reports = merged_articles_validations.MergedArticlesReports(articles_mergence, registered_issue_data) + + encoding.debugging('pkg_processors.make_package.evaluate_package - IssueArticlesValidationsReports') validations_reports = merged_articles_validations.IssueArticlesValidationsReports(pkg_reports, mergence_reports, self.is_xml_generation) + encoding.debugging('pkg_processors.make_package.evaluate_package - end') return registered_issue_data, validations_reports def make_package(self, pkg, GENERATE_PMC=False): @@ -447,6 +462,7 @@ def validate_merged_articles(self, pkg, registered_issue_data): pkg.articles, self.is_db_generation) def report_result(self, pkg, validations_reports, conversion=None): + encoding.debugging('pkg_processors.make_package.report_result - begin') files_location = workarea.AssetsDestinations(pkg.wk.scielo_package_path, pkg.issue_data.acron, pkg.issue_data.issue_label) if conversion is not None: files_location = workarea.AssetsDestinations(pkg.wk.scielo_package_path, pkg.issue_data.acron, pkg.issue_data.issue_label, self.config.serial_path, self.config.local_web_app_path, self.config.web_app_site) @@ -460,6 +476,7 @@ def report_result(self, pkg, validations_reports, conversion=None): for article_files in pkg.package_folder.pkgfiles_items.values(): # copia os xml para report path article_files.copy_xml(reports.files_location.report_path) + encoding.debugging('pkg_processors.make_package.report_result - end') return reports def make_pmc_package(self, pkg, GENERATE_PMC): diff --git a/src/scielo/bin/xml/app_modules/app/validations/article_content_validations.py b/src/scielo/bin/xml/app_modules/app/validations/article_content_validations.py index 2d8ad9134..6f69ddf1c 100644 --- a/src/scielo/bin/xml/app_modules/app/validations/article_content_validations.py +++ b/src/scielo/bin/xml/app_modules/app/validations/article_content_validations.py @@ -293,9 +293,11 @@ def article_type(self): ' ; '.join(invalid))) titles = [t.title for t in self.article.titles] _titles = ' / '.join([u'"{}"'.format(t) for t in titles]) - if utils.is_similar(self.article.toc_section, titles): + similar = utils.is_similar(self.article.toc_section, titles) + similar_alt = utils.is_similar_alternative(self.article.toc_section, titles) + if similar and similar_alt: errors.append( - _(u'{} must not be similar to the table of contents section "{}" '.format( + _(u'"{}" must not be similar to the table of contents section "{}" '.format( _titles, self.article.toc_section))) else: errors.append( diff --git a/src/scielo/bin/xml/app_modules/app/xpm.py b/src/scielo/bin/xml/app_modules/app/xpm.py index 123009322..164863dea 100644 --- a/src/scielo/bin/xml/app_modules/app/xpm.py +++ b/src/scielo/bin/xml/app_modules/app/xpm.py @@ -124,17 +124,20 @@ def display_form(self): interface.display_form(self.proc.stage == 'xc', None, self.call_make_package) def call_make_package(self, xml_path, GENERATE_PMC=False): - encoding.display_message(_('Making package') + '...') + encoding.display_message(_('Execute Make package') + ':') xml_list = [xml_path + '/' + item for item in os.listdir(xml_path) if item.endswith('.xml')] - encoding.display_message('...'*2) + encoding.display_message('Step 1/2 ...') normalized_pkgfiles, outputs = pkg_processors.normalize_xml_packages(xml_list, 'remote', self.proc.stage) - encoding.display_message('...'*3) + encoding.display_message('Step 2/2 ...') self.make_package(normalized_pkgfiles, outputs, GENERATE_PMC) - encoding.display_message('...'*4) + encoding.display_message('The End') return 'done', 'blue' def make_package(self, normalized_pkgfiles, outputs, GENERATE_PMC=False): if len(normalized_pkgfiles) > 0: workarea_path = os.path.dirname(normalized_pkgfiles[0].path) + encoding.debugging('xpm.XPM_Reception.make_package - package.Package') pkg = package.Package(normalized_pkgfiles, outputs, workarea_path) + encoding.debugging('xpm.XPM_Reception.make_package - proc.make_package') + encoding.display_message(_('Making package') + ' ...') self.proc.make_package(pkg, GENERATE_PMC) diff --git a/src/scielo/bin/xml/app_modules/generics/encoding.py b/src/scielo/bin/xml/app_modules/generics/encoding.py index 8025eab5a..96792b85a 100644 --- a/src/scielo/bin/xml/app_modules/generics/encoding.py +++ b/src/scielo/bin/xml/app_modules/generics/encoding.py @@ -100,7 +100,7 @@ def report_exception(function_name, e, data): app_logger.info(e) -def debugging(function_name, data): +def debugging(function_name, data=None): try: app_logger.info('DEBUG: {}'.format(function_name)) app_logger.info(data) diff --git a/src/scielo/bin/xml/app_modules/generics/system.py b/src/scielo/bin/xml/app_modules/generics/system.py index 055851266..1eeb41a2f 100644 --- a/src/scielo/bin/xml/app_modules/generics/system.py +++ b/src/scielo/bin/xml/app_modules/generics/system.py @@ -61,9 +61,9 @@ def proxy_parameter(proxy_info): def proxy_data(proxy_info): proxy = None if proxy_info is not None: - resp = read_input('Do you use proxy for Internet access ({})? Y/N '.format(proxy_info)) - if resp in 'Yy': - username = read_input('Inform proxy Username: ') + print('Proxy {}'.format(proxy_info)) + username = read_input('Username: ') + if username.strip() != '': password = input_password() proxy = [ username, diff --git a/src/scielo/bin/xml/app_modules/generics/utils.py b/src/scielo/bin/xml/app_modules/generics/utils.py index 1cb98fb7c..afd01e165 100644 --- a/src/scielo/bin/xml/app_modules/generics/utils.py +++ b/src/scielo/bin/xml/app_modules/generics/utils.py @@ -35,6 +35,15 @@ def is_similar(text, items, min_rate=0.8): return (highiest_rate > min_rate) +def is_similar_alternative(text, items, min_rate=0.8): + if not isinstance(items, list): + items = [items] + lens = [len(item) for item in items] + lens.append(len(text)) + min_len = min(lens) + return is_similar(text, [item[:min_len-2] for item in items], 0.95) + + def how_similar(this, that): if this is None: this = 'None' diff --git a/src/scielo/bin/xml/app_modules/generics/ws/ws_proxy.py b/src/scielo/bin/xml/app_modules/generics/ws/ws_proxy.py index 063b343ad..27b27e118 100644 --- a/src/scielo/bin/xml/app_modules/generics/ws/ws_proxy.py +++ b/src/scielo/bin/xml/app_modules/generics/ws/ws_proxy.py @@ -35,6 +35,7 @@ def __init__(self, server=None, port=None, user=None, password=None): self.port = port self.user = user self.password = password + encoding.debugging('ProxyInfo({}, {}, {}, {})'.format(server, port, user, '*')) @property def handler_data(self): diff --git a/src/scielo/bin/xml/app_modules/generics/ws/ws_proxy_gui.py b/src/scielo/bin/xml/app_modules/generics/ws/ws_proxy_gui.py index 2349b377f..1282309a3 100644 --- a/src/scielo/bin/xml/app_modules/generics/ws/ws_proxy_gui.py +++ b/src/scielo/bin/xml/app_modules/generics/ws/ws_proxy_gui.py @@ -7,9 +7,16 @@ print('no Tkinter') +def gettext(text): + return text + + +_ = gettext + + class ProxyGUI(tk.Frame): - def __init__(self, tk_root, registered_ip, registered_port): + def __init__(self, tk_root, registered_ip, registered_port, debug): self.info = None if registered_ip is None: registered_ip = '' @@ -22,15 +29,26 @@ def __init__(self, tk_root, registered_ip, registered_port): message_frame = tk.Frame(self) message_frame.pack(fill="both", expand="yes") - message = tk.Message(message_frame, - font='System 14 bold', - text=_("""This tool requires Internet access for some services, - such as DOI, affiliations, and other data validations, - and also to get journals data from SciELO.\n - If you do not use a proxy to access the Internet, - and click on Cancel button."""), - wraplength=450 - ) + try: + message = tk.Message(message_frame, + font='System 14 bold', + text=_("""This tool requires Internet access for some services, + such as DOI, affiliations, and other data validations, + and also to get journals data from SciELO.\n + If you do not use a proxy to access the Internet, + and click on Cancel button."""), + wraplength=450 + ) + except: + message = tk.Message(message_frame, + font='System 14 bold', + text=_("""This tool requires Internet access for some services, + such as DOI, affiliations, and other data validations, + and also to get journals data from SciELO.\n + If you do not use a proxy to access the Internet, + and click on Cancel button.""") + ) + message.pack() proxy_ip_frame = tk.Frame(self) diff --git a/src/scielo/bin/xml/app_modules/generics/ws/ws_requester.py b/src/scielo/bin/xml/app_modules/generics/ws/ws_requester.py index a56cec741..5b96b4e57 100644 --- a/src/scielo/bin/xml/app_modules/generics/ws/ws_requester.py +++ b/src/scielo/bin/xml/app_modules/generics/ws/ws_requester.py @@ -86,6 +86,7 @@ def try_request(url, timeout=30, debug=False, force_error=False): class WebServicesRequester(object): def __init__(self, active=True, proxy_data=None): + encoding.debugging('WebServicesRequester({}, {})'.format(active, proxy_data)) self.requests = {} self.skip = [] self.proxy_data = proxy_data @@ -109,6 +110,8 @@ def format_url(self, url, parameters=None): return url + query def request(self, url, timeout=30, debug=False, force_error=False): + encoding.debugging('WebServicesRequester.request({})'.format(url)) + if self.active is False: return None response = self.requests.get(url) diff --git a/src/scielo/bin/xml/run_app.py b/src/scielo/bin/xml/run_app.py index 83f21f8e1..eb15c81a3 100644 --- a/src/scielo/bin/xml/run_app.py +++ b/src/scielo/bin/xml/run_app.py @@ -19,12 +19,11 @@ configuration = config.Configuration() -# proxy_data = system.proxy_data(configuration.proxy_info) - appcaller = app_caller.AppCaller( logger.get_logger(LOG_PATH+'/app_caller.log', 'Environment'), VENV_PATH if configuration.USE_VIRTUAL_ENV is True else None, - REQUIREMENTS_FILE + REQUIREMENTS_FILE, + configuration.proxy_info ) @@ -50,6 +49,12 @@ def requirements_checker(): def check_requirements(): reqs = requirements_checker() if len(reqs) > 0: + encoding.display_message( + '#########\nChecking requirements:\n{}\n########'.format( + '\n'.join(reqs) + ) + ) + print('check_requirements()') appcaller.install_virtualenv() appcaller.install_requirements() @@ -59,6 +64,7 @@ def main(parameters): argv = parameters[1:] if parameters[1].endswith('xml_package_maker.py'): + print('xpm') check_requirements() from app_modules.app import xpm xpm.call_make_packages(argv, '1.1') @@ -69,7 +75,8 @@ def main(parameters): elif parameters[1] == 'install': # configuration = config.Configuration() # proxy_info = configuration.proxy_info - appcaller.proxy_data = system.proxy_data(configuration.proxy_info) + # appcaller.proxy_data = system.proxy_data(configuration.proxy_info) + print('main_install()') appcaller.install_virtualenv(True) appcaller.install_requirements() else: From c39f157ad16851b009a6ad7695d2c38f7466f78c Mon Sep 17 00:00:00 2001 From: robertatakenaka Date: Wed, 25 Apr 2018 15:50:28 -0300 Subject: [PATCH 5/5] 40095_install_requirements_v3 --- .../xml/app_modules/app/config/app_caller.py | 216 ++++++------------ .../app/pkg_processors/pkg_processors.py | 9 + src/scielo/bin/xml/run_app.py | 18 +- 3 files changed, 91 insertions(+), 152 deletions(-) diff --git a/src/scielo/bin/xml/app_modules/app/config/app_caller.py b/src/scielo/bin/xml/app_modules/app/config/app_caller.py index 8b48aff08..89a7ceac8 100644 --- a/src/scielo/bin/xml/app_modules/app/config/app_caller.py +++ b/src/scielo/bin/xml/app_modules/app/config/app_caller.py @@ -73,24 +73,14 @@ def gen_proxy_info(proxy_server_port): class VirtualEnv(object): - def __init__(self, logger, venv_path, requirements_filename, proxy_server_port): - print('VirtualEnv()') + def __init__(self, logger, venv_path): + encoding.debugging('VirtualEnv.VirtualEnv()') self.logger = logger self.path = venv_path - self.requirements = Requirements(requirements_filename) - self.proxy_server_port = proxy_server_port - self._proxy_info = None self.setUp() - @property - def proxy_info(self): - print('proxy_info') - if self._proxy_info is None: - self._proxy_info = gen_proxy_info(self.proxy_server_port) - return self._proxy_info - def setUp(self): - print('setUp') + encoding.debugging('VirtualEnv.setUp') if 'windows' in so: self.activate_filename = u'{}/Scripts/activate.bat'.format(self.path) self.activate_command = u'call "{}"'.format(self.activate_filename) @@ -106,35 +96,35 @@ def setUp(self): self.deactivate_command = '' def inform_status(self): - print('inform_status') + encoding.debugging('VirtualEnv.inform_status') if self.installed is False: inform(u'Not found: "{}"'.format(self.activate_filename)) @property def installed(self): - print('installed') + encoding.debugging('VirtualEnv.installed') return os.path.isfile(self.activate_filename) - def install_venv(self, recreate=False): - print('install_venv') + def install_venv(self, recreate, proxy_info): + encoding.debugging('VirtualEnv.install_venv') if self.path is not None: if not self.installed or recreate: commands = [] - commands.extend(self.proxy_info.register_commands) + commands.extend(proxy_info.register_commands) commands.append( 'python -m pip install {} -U pip'.format( - self.proxy_info.parameter) + proxy_info.parameter) ) commands.append( 'python -m pip install {} --upgrade pip'.format( - self.proxy_info.parameter) + proxy_info.parameter) ) commands.append( - 'pip install {} virtualenv'.format(self.proxy_info.parameter) + 'pip install {} virtualenv'.format(proxy_info.parameter) ) commands.append(u'virtualenv "{}"'.format(self.path)) for cmd in commands: - if 'teste' in self.proxy_info.parameter: + if 'teste' in proxy_info.parameter: encoding.display_message('Executaria\n {}'.format(cmd)) else: system.run_command(cmd) @@ -145,77 +135,6 @@ def install_venv(self, recreate=False): inform(u'Unable to create the virtualenv: "{}"'.format(self.path)) inform('Install the programs in a path which does not have diacritics') - def install_requirements(self, requirements_checker=None): - print('install_requirements') - commands = self.requirements.install_commands( - self.proxy_info, - uninstall=True) - self.execute_in_virtualenv(commands) - - def execute_in_virtualenv(self, commands): - print('execute_in_virtualenv') - if self.installed: - _commands = [self.activate_command] - _commands.extend(commands) - self._execute_inline(_commands) - - def _execute_inline(self, commands): - print('_execute_inline') - _commands = [item for item in commands if len(item) > 0] - start = '' - end = '' - sep = self.sep - if '&' in self.sep: - sep = '\n' - start = '(' - end = ')' - cmd = '{}{}{}'.format(start, sep.join(_commands), end) - display_cmd = self.proxy_info.hide_password(cmd) - self.logger.info(display_cmd) - encoding.display_message(display_cmd) - system.run_command(cmd, False) - - def activate(self): - if self.installed: - system.run_command(self.activate_command, True) - - def deactivate(self): - if self.installed: - system.run_command(self.deactivate_command, True) - - -class RealEnv(object): - - def __init__(self, logger, requirements_filename, proxy_server_port): - print('RealEnv()') - self.logger = logger - self.requirements = Requirements(requirements_filename) - self.proxy_server_port = proxy_server_port - self._proxy_info = None - - @property - def proxy_info(self): - if self._proxy_info is None: - self._proxy_info = gen_proxy_info(self.proxy_server_port) - return self._proxy_info - - def install_requirements(self, requirements_checker=None): - reqs = 0 - if requirements_checker is not None: - reqs = requirements_checker() - if reqs > 0: - commands = self.requirements.install_commands( - self.proxy_info, - uninstall=True) - self.execute_commands(commands) - - def execute_commands(self, commands): - for cmd in commands: - display_cmd = self.proxy_server_port.hide_password(cmd) - self.logger.info(display_cmd) - encoding.display_message(display_cmd) - os.system(cmd) - class Requirements(object): @@ -226,7 +145,6 @@ def install_commands(self, proxy_info, uninstall): commands = [] if uninstall is True: commands = self.uninstall_commands() - commands.extend(proxy_info.register_commands) commands.append( 'python -m pip install {} -U pip'.format( proxy_info.parameter) @@ -247,58 +165,72 @@ def uninstall_commands(self): return commands -class VEnvAppCaller(object): - - def __init__(self, logger, venv_path, req_file, proxy_server_port): - self.env = VirtualEnv(logger, venv_path, req_file, proxy_server_port) - - def install_virtualenv(self, recreate=False): - self.env.install_venv(recreate) - self.env.inform_status() - - def install_requirements(self, requirements_checker=None): - if self.env.installed: - self.env.install_requirements(requirements_checker) - - def execute(self, commands): - self.env.execute_in_virtualenv(commands) - - -class RealAppCaller(object): +class AppCaller(object): def __init__(self, logger, venv_path, req_file, proxy_server_port): - self.env = RealEnv(logger, req_file, proxy_server_port) - - def install_virtualenv(self, recreate=False): - pass - - def install_requirements(self, requirements_checker=None): - self.env.install_requirements(requirements_checker) - - def execute(self, commands): - self.env.execute_commands(commands) + encoding.debugging('AppCaller.AppCaller()') + self.logger = logger + self.venv = VirtualEnv(logger, venv_path) + self.requirements = Requirements(req_file) + self.proxy_server_port = proxy_server_port + self.proxy_info = ProxyInfo(None) + def install_requirements(self, restart, requirements_checker): + encoding.debugging( + 'AppCaller.install_requirements', + (restart, requirements_checker)) + reqs = 0 + if requirements_checker is not None: + reqs = requirements_checker() + encoding.debugging( + 'AppCaller.install_requirements', + (reqs, restart)) + if restart or reqs > 0: + self.proxy_info = gen_proxy_info(self.proxy_server_port) + if restart or not self.venv.installed: + encoding.debugging( + 'AppCaller.install_requirements: self.venv.install_venv') + self.venv.install_venv(restart, self.proxy_info) + encoding.debugging( + 'AppCaller.install_requirements: self.requirements.install_commands') + commands = self.requirements.install_commands( + self.proxy_info, + uninstall=restart) -class AppCaller(object): + self.execute(commands) - def __init__(self, logger, venv_path, req_file, proxy_server_port): - print('AppCaller()') - self.caller = None - if venv_path is not None: - virtual = VEnvAppCaller( - logger, venv_path, req_file, proxy_server_port) - virtual.install_virtualenv() - if virtual.env.installed: - self.caller = virtual - if self.caller is None: - self.caller = RealAppCaller( - logger, venv_path, req_file, proxy_server_port) - - def install_virtualenv(self, recreate=False): - self.caller.install_virtualenv(recreate) - - def install_requirements(self, requirements_checker=None): - self.caller.install_requirements(requirements_checker) + def format_commands(self, commands): + encoding.debugging('AppCaller.format_commands', commands) + _commands = [] + for cmd in commands: + _cmd = [] + if self.venv.installed: + _cmd = [self.venv.activate_command] + if self.proxy_info.parameter in cmd: + _cmd.extend(self.proxy_info.register_commands) + _cmd.append(cmd) + if self.venv.installed: + # _cmd.append(self.venv.deactivate_command) + _cmd = [self.commands_inline(_cmd)] + _commands.extend(_cmd) + encoding.debugging('AppCaller.format_commands: formatted', _commands) + return _commands + + def commands_inline(self, commands): + encoding.debugging('AppCaller.commands_inline', commands) + _commands = [item for item in commands if len(item) > 0] + _cmd = self.venv.sep.join(_commands) + return _cmd def execute(self, commands): - self.caller.execute(commands) + encoding.debugging( + 'AppCaller.execute', + commands) + for cmd in self.format_commands(commands): + encoding.debugging( + 'AppCaller.execute', + cmd) + display_cmd = self.proxy_info.hide_password(cmd) + self.logger.info(display_cmd) + encoding.display_message(display_cmd) + os.system(cmd) diff --git a/src/scielo/bin/xml/app_modules/app/pkg_processors/pkg_processors.py b/src/scielo/bin/xml/app_modules/app/pkg_processors/pkg_processors.py index d849bbbe6..3dc6673e0 100644 --- a/src/scielo/bin/xml/app_modules/app/pkg_processors/pkg_processors.py +++ b/src/scielo/bin/xml/app_modules/app/pkg_processors/pkg_processors.py @@ -386,12 +386,15 @@ def normalized_package(self, xml_list): return package.Package(pkgfiles, outputs, workarea_path) def evaluate_package(self, pkg): + encoding.display_message(_('Evaluating package... Wait. ')) encoding.debugging('pkg_processors.make_package.evaluate_package - begin') registered_issue_data = registered.RegisteredIssue() + encoding.display_message(_('Evaluating package... Wait. ')) encoding.debugging('pkg_processors.make_package.evaluate_package - get_registered_issue_data') self.registered_issues_manager.get_registered_issue_data(pkg.issue_data, registered_issue_data) + encoding.display_message(_('Evaluating package... Wait. ')) encoding.debugging('pkg_processors.make_package.evaluate_package - affiliations') for xml_name in sorted(pkg.articles.keys()): a = pkg.articles[xml_name] @@ -403,20 +406,26 @@ def evaluate_package(self, pkg): pkg.articles[xml_name].institutions_query_results = institutions_results pkg.articles[xml_name].normalized_affiliations = {aff_id: info[0] for aff_id, info in institutions_results.items()} + encoding.display_message(_('Evaluating package... Wait. ')) encoding.debugging('pkg_processors.make_package.evaluate_package - validate_pkg_articles') pkg_validations = self.validate_pkg_articles(pkg, registered_issue_data) + encoding.display_message(_('Evaluating package... Wait. ')) encoding.debugging('pkg_processors.make_package.evaluate_package - validate_merged_articles') articles_mergence = self.validate_merged_articles(pkg, registered_issue_data) + encoding.display_message(_('Evaluating package... Wait. ')) encoding.debugging('pkg_processors.make_package.evaluate_package - PkgArticlesValidationsReports') pkg_reports = pkg_articles_validations.PkgArticlesValidationsReports(pkg_validations, registered_issue_data.articles_db_manager is not None) + encoding.display_message(_('Evaluating package... Wait. ')) encoding.debugging('pkg_processors.make_package.evaluate_package - MergedArticlesReports') mergence_reports = merged_articles_validations.MergedArticlesReports(articles_mergence, registered_issue_data) + encoding.display_message(_('Evaluating package... Wait. ')) encoding.debugging('pkg_processors.make_package.evaluate_package - IssueArticlesValidationsReports') validations_reports = merged_articles_validations.IssueArticlesValidationsReports(pkg_reports, mergence_reports, self.is_xml_generation) + encoding.display_message(_('Evaluating package... Wait. ')) encoding.debugging('pkg_processors.make_package.evaluate_package - end') return registered_issue_data, validations_reports diff --git a/src/scielo/bin/xml/run_app.py b/src/scielo/bin/xml/run_app.py index eb15c81a3..115f40dfb 100644 --- a/src/scielo/bin/xml/run_app.py +++ b/src/scielo/bin/xml/run_app.py @@ -54,9 +54,8 @@ def check_requirements(): '\n'.join(reqs) ) ) - print('check_requirements()') - appcaller.install_virtualenv() - appcaller.install_requirements() + encoding.debugging('run_app.py: check_requirements()') + appcaller.install_requirements(False, requirements_checker) def main(parameters): @@ -64,7 +63,7 @@ def main(parameters): argv = parameters[1:] if parameters[1].endswith('xml_package_maker.py'): - print('xpm') + encoding.debugging('run_app.py: xpm') check_requirements() from app_modules.app import xpm xpm.call_make_packages(argv, '1.1') @@ -76,13 +75,12 @@ def main(parameters): # configuration = config.Configuration() # proxy_info = configuration.proxy_info # appcaller.proxy_data = system.proxy_data(configuration.proxy_info) - print('main_install()') - appcaller.install_virtualenv(True) - appcaller.install_requirements() + encoding.debugging('run_app.py: main_install()') + appcaller.install_requirements(True, requirements_checker) else: - print('unknown command') - print(parameters) - print('do nothing') + encoding.debugging('run_app.py: unknown command') + encoding.debugging(parameters) + encoding.debugging('run_app.py: do nothing') if __name__ == '__main__':