diff --git a/packageship/packageship/application/__init__.py b/packageship/packageship/application/__init__.py index 0ca16e9d7e436693beb4fb48eed60e7289a7ce5c..7356b541ba24cc2a79da61cca6cdcf6aa1760aad 100644 --- a/packageship/packageship/application/__init__.py +++ b/packageship/packageship/application/__init__.py @@ -22,13 +22,18 @@ def _timed_task(app): from .apps.lifecycle.function.download_yaml import update_pkg_info # pylint: disable=import-outside-toplevel _readconfig = ReadConfig(system_config.SYS_CONFIG_PATH) - - _hour = _readconfig.get_config('TIMEDTASK', 'hour') - if not _hour or not isinstance(_hour, int) or _hour < 0 or _hour > 23: + try: + _hour = int(_readconfig.get_config('TIMEDTASK', 'hour')) + _minute = int(_readconfig.get_config('TIMEDTASK', 'minute')) + except ValueError: _hour = 3 - _minute = _readconfig.get_config('TIMEDTASK', 'minute') - if not _hour or not isinstance(_hour, int) or _hour < 0 or _hour > 59: _minute = 0 + else: + if _hour < 0 or _hour > 23: + _hour = 3 + if _minute < 0 or _minute > 59: + _minute = 0 + app.apscheduler.add_job( # pylint: disable=no-member func=update_pkg_info, id="update_package_data", trigger="cron", hour=_hour, minute=_minute) app.apscheduler.add_job( # pylint: disable=no-member diff --git a/packageship/packageship/application/apps/lifecycle/function/download_yaml.py b/packageship/packageship/application/apps/lifecycle/function/download_yaml.py index e231ef9f98db4a5003e0da3fda79e66ddbcc823b..500e23b9b876ef1f078ecd1bfc13e9a0a1168e8a 100644 --- a/packageship/packageship/application/apps/lifecycle/function/download_yaml.py +++ b/packageship/packageship/application/apps/lifecycle/function/download_yaml.py @@ -80,8 +80,8 @@ class ParseYaml(): if self._openeuler_advisor_exists_yaml(): self._save_to_database() else: - msg = "The yaml information of the %s package has not been\ - obtained yet" % self.pkg.name + msg = "The yaml information of the [%s] package has not been" \ + "obtained yet" % self.pkg.name self.base.log.logger.warning(msg) def _get_yaml_content(self, url): @@ -118,15 +118,16 @@ class ParseYaml(): """ self._parse_warehouse_info() tags = self._yaml_content.get('git_tag', None) - self._parse_tags_content(tags) + if tags: + self._parse_tags_content(tags) + self.producer_consumer.put(copy.deepcopy(self.pkg)) if self.timed_task_open: - _maintainer = self._yaml_content.get('maintainer') + _maintainer = self._yaml_content.get('maintainers') if _maintainer and isinstance(_maintainer, list): self.pkg.maintainer = _maintainer[0] self.pkg.maintainlevel = self._yaml_content.get('maintainlevel') try: - self.producer_consumer.put(copy.deepcopy(self.pkg)) - if self.timed_task_open and self.pkg.maintainer: + if self.timed_task_open: @retry(stop_max_attempt_number=3, stop_max_delay=500) def _save_maintainer_info(): with DBHelper(db_name="lifecycle") as database: