Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get rid of deprecation warnings #1992

Merged
merged 7 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion teuthology/lock/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion teuthology/task/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion teuthology/task/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions teuthology/task/ssh_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions teuthology/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
import yaml

from datetime import datetime
import datetime

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -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.timezone.utc)
return datetime.datetime.strftime(
_datetime,
self.datetime_format,
)
Expand Down
2 changes: 1 addition & 1 deletion teuthology/util/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down