From 1cc173081f724e806e3c7a334eadfe4fabe5f7ef Mon Sep 17 00:00:00 2001 From: gongzt Date: Thu, 10 Sep 2020 14:34:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E5=99=A8=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=92=8C=E5=8C=85=E7=9A=84=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E4=BA=BA=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packageship/packageship/application/__init__.py | 15 ++++++++++----- .../apps/lifecycle/function/download_yaml.py | 13 +++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packageship/packageship/application/__init__.py b/packageship/packageship/application/__init__.py index 0ca16e9d..7356b541 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 e231ef9f..500e23b9 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: -- GitLab