From 99be5a31378fbea578a3697c2360e35221651d88 Mon Sep 17 00:00:00 2001 From: Seena Fallah Date: Sun, 17 Jan 2021 14:21:37 +0330 Subject: [PATCH] config: make backup_name_regex configurable Signed-off-by: Seena Fallah --- config.py.in | 3 +++ paddles/models/runs.py | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/config.py.in b/config.py.in index 31dccd2..e8a88b9 100644 --- a/config.py.in +++ b/config.py.in @@ -25,6 +25,9 @@ address = 'http://paddles.front.sepia.ceph.com' job_log_href_templ = 'http://qa-proxy.ceph.com/teuthology/{run_name}/{job_id}/teuthology.log' # noqa default_latest_runs_count = 25 +backup_name_regex = \ + '(?P.*)-(?P[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2}_[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2})-(?P.*)-(?P.*)-.*?-.*?-(?P.*?)' # noqa + # Pecan Application Configurations app = { 'root': 'paddles.controllers.root.RootController', diff --git a/paddles/models/runs.py b/paddles/models/runs.py index d7250a4..5797822 100644 --- a/paddles/models/runs.py +++ b/paddles/models/runs.py @@ -93,12 +93,11 @@ def get_name_regexes(timestamp_regex, suite_names, distros, machine_types): class Run(Base): + timestamp_format = '%Y-%m-%d_%H:%M:%S' timestamp_regex = \ '[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2}_[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}' - timestamp_format = '%Y-%m-%d_%H:%M:%S' name_regexes = get_name_regexes(timestamp_regex, suite_names, distros, machine_types) - backup_name_regex = '(?P.*)-(?P%s)-(?P.*)-(?P.*)-.*?-.*?-(?P.*?)' % timestamp_regex # noqa __tablename__ = 'runs' id = Column(Integer, primary_key=True) @@ -175,14 +174,15 @@ def _parse_name(cls, name): name_match = re.match(cls.name_regexes[0], name) or \ re.match(cls.name_regexes[1], name) or \ re.match(cls.name_regexes[2], name) or \ - re.match(cls.backup_name_regex, name) + re.match(conf.backup_name_regex, name) if name_match: match_dict = name_match.groupdict() for (key, value) in match_dict.iteritems(): match_dict[key] = value.strip(' -') - match_dict['scheduled'] = datetime.strptime( - match_dict['scheduled'], cls.timestamp_format) + if 'scheduled' in match_dict: + match_dict['scheduled'] = datetime.strptime( + match_dict['scheduled'], cls.timestamp_format) return match_dict return dict()