From bdc7c126831275b4a364e3603d8abf7d834e1e0b Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Sat, 3 Aug 2024 20:24:27 +0200 Subject: [PATCH 1/7] task/kernel: fix invalid escape sequence Signed-off-by: Kyr Shatskyy --- teuthology/task/kernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teuthology/task/kernel.py b/teuthology/task/kernel.py index ca4718784..59242d31b 100644 --- a/teuthology/task/kernel.py +++ b/teuthology/task/kernel.py @@ -1033,7 +1033,7 @@ def get_image_version(remote, path): raise UnsupportedPackageTypeError(remote) for file in files.split('\n'): - match = re.search('/lib/modules/(.*)/modules\.order$', file) + match = re.search(r'/lib/modules/(.*)/modules\.order$', file) if match: version = match.group(1) break From b3805eaf96f7fcc7f3bc2a66c3374c4835e22142 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Thu, 1 Aug 2024 00:02:20 +0200 Subject: [PATCH 2/7] lock/cli: fix invalid escape sequence Address warning message which is going to be an error in future python versions: SyntaxWarning: invalid escape sequence '\w' Signed-off-by: Kyr Shatskyy --- teuthology/lock/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teuthology/lock/cli.py b/teuthology/lock/cli.py index c562a3d51..e5f97fb63 100644 --- a/teuthology/lock/cli.py +++ b/teuthology/lock/cli.py @@ -133,7 +133,7 @@ def main(ctx): for s in sorted(statuses, key=lambda s: s.get('name')): locked = 'unlocked' if s['locked'] == 0 else 'locked' up = 'up' if s['up'] else 'down' - mo = re.match('\w+@(\w+?)\..*', s['name']) + mo = re.match(r'\w+@(\w+?)\..*', s['name']) host = mo.group(1) if mo else s['name'] print(node_status_template.format( up=up, locked=locked, host=host, From edbcc1d70d85df181917798837836c3422286cf1 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Sat, 3 Aug 2024 20:25:41 +0200 Subject: [PATCH 3/7] timer: fix deprecation warning for utcfromtimestamp Signed-off-by: Kyr Shatskyy --- teuthology/timer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/teuthology/timer.py b/teuthology/timer.py index 0119b8b3a..3d8eb7733 100644 --- a/teuthology/timer.py +++ b/teuthology/timer.py @@ -2,7 +2,7 @@ import time import yaml -from datetime import datetime +import datetime log = logging.getLogger(__name__) @@ -68,8 +68,8 @@ def get_datetime_string(self, time): :param time: Time in seconds; like from time.time() """ - _datetime = datetime.utcfromtimestamp(time) - return datetime.strftime( + _datetime = datetime.datetime.fromtimestamp(time, datetime.UTC) + return datetime.datetime.strftime( _datetime, self.datetime_format, ) From b5d14a9d2d8632feac6d81121fd0a6d6d2214185 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Mon, 5 Aug 2024 00:06:33 +0200 Subject: [PATCH 4/7] util/scanner: get rid of FutureWarning message Get rid of the warning: teuthology/util/test/test_scanner.py::TestValgrindScanner::test_scan_all_files /Users/kyr/kshtsk/teuthology/teuthology/util/scanner.py:133: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. if not xml_tree: Signed-off-by: Kyr Shatskyy --- teuthology/util/scanner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teuthology/util/scanner.py b/teuthology/util/scanner.py index b67d88c92..421d5a028 100644 --- a/teuthology/util/scanner.py +++ b/teuthology/util/scanner.py @@ -130,7 +130,7 @@ def __init__(self, remote=None) -> None: def _parse(self, file_content: str) -> Tuple[Optional[str], Optional[dict]]: xml_tree = etree.fromstring(file_content) - if not xml_tree: + if xml_tree is None: return None, None error_tree = xml_tree.find('error') From ea0043ea18ae74e105ff02419eeeaabca7dc0806 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Mon, 5 Aug 2024 00:17:36 +0200 Subject: [PATCH 5/7] task/mpi: fix invalid escape sequence teuthology/task/mpi.py:21: SyntaxWarning: invalid escape sequence '\s' version = re.search("^\s+Version:\s+(.+)$", version_str, re.MULTILINE).group(1) Signed-off-by: Kyr Shatskyy --- teuthology/task/mpi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teuthology/task/mpi.py b/teuthology/task/mpi.py index 6c709fd17..0e1b504dd 100644 --- a/teuthology/task/mpi.py +++ b/teuthology/task/mpi.py @@ -18,7 +18,7 @@ def _check_mpi_version(remotes): for remote in remotes: version_str = remote.sh("mpiexec --version") try: - version = re.search("^\s+Version:\s+(.+)$", version_str, re.MULTILINE).group(1) + version = re.search(r"^\s+Version:\s+(.+)$", version_str, re.MULTILINE).group(1) except AttributeError: raise RuntimeError("Malformed MPI version output: {0}".format(version_str)) else: From 70d385ec4145805f429664dadd7ec839361dffe3 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Mon, 5 Aug 2024 00:46:19 +0200 Subject: [PATCH 6/7] task/ssh_keys: fix invalid escape sequence '\w' Fix syntax warning message: :68: SyntaxWarning: invalid escape sequence '\w' teuthology/task/ssh_keys.py:57: SyntaxWarning: invalid escape sequence '\w' match = re.match('[\w-]+ {key} \S+@\S+'.format(key=re.escape(ssh_key)), line_to_test) teuthology/task/ssh_keys.py:68: SyntaxWarning: invalid escape sequence '\w' match = re.match('[\w-]+ \S+ {username}@\S+'.format(username=username), line_to_test) Signed-off-by: Kyr Shatskyy --- teuthology/task/ssh_keys.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/teuthology/task/ssh_keys.py b/teuthology/task/ssh_keys.py index 9c899e8fa..0f497ebe9 100644 --- a/teuthology/task/ssh_keys.py +++ b/teuthology/task/ssh_keys.py @@ -54,7 +54,7 @@ def particular_ssh_key_test(line_to_test, ssh_key): """ Check the validity of the ssh_key """ - match = re.match('[\w-]+ {key} \S+@\S+'.format(key=re.escape(ssh_key)), line_to_test) + match = re.match(r'[\w-]+ {key} \S+@\S+'.format(key=re.escape(ssh_key)), line_to_test) if match: return False @@ -65,7 +65,7 @@ def ssh_keys_user_line_test(line_to_test, username ): """ Check the validity of the username """ - match = re.match('[\w-]+ \S+ {username}@\S+'.format(username=username), line_to_test) + match = re.match(r'[\w-]+ \S+ {username}@\S+'.format(username=username), line_to_test) if match: return False From 5bd83e9c49e9a81c3b49907f309ffc9d267c752f Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Mon, 5 Aug 2024 01:15:24 +0200 Subject: [PATCH 7/7] timer: use datetime.timezone.utc for python 3.10 Python 3.10 doesn't have datetime.UTC yet as Python 3.12 does Signed-off-by: Kyr Shatskyy --- teuthology/timer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teuthology/timer.py b/teuthology/timer.py index 3d8eb7733..9ca5d76a7 100644 --- a/teuthology/timer.py +++ b/teuthology/timer.py @@ -68,7 +68,7 @@ def get_datetime_string(self, time): :param time: Time in seconds; like from time.time() """ - _datetime = datetime.datetime.fromtimestamp(time, datetime.UTC) + _datetime = datetime.datetime.fromtimestamp(time, datetime.timezone.utc) return datetime.datetime.strftime( _datetime, self.datetime_format,