]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Fix 'invalid escape sequence' deprecation warnings
authorZack Cerza <zack@redhat.com>
Fri, 20 Jan 2023 19:25:30 +0000 (12:25 -0700)
committerZack Cerza <zack@redhat.com>
Fri, 20 Jan 2023 23:13:16 +0000 (16:13 -0700)
Signed-off-by: Zack Cerza <zack@redhat.com>
16 files changed:
teuthology/ls.py
teuthology/misc.py
teuthology/nuke/actions.py
teuthology/openstack/__init__.py
teuthology/orchestra/daemon/systemd.py
teuthology/provision/openstack.py
teuthology/provision/test/test_init_provision.py
teuthology/provision/test/test_pelagos.py
teuthology/repo_utils.py
teuthology/report.py
teuthology/scrape.py
teuthology/suite/placeholder.py
teuthology/suite/run.py
teuthology/task/install/deb.py
teuthology/task/kernel.py
teuthology/task/selinux.py

index a50a59d176a92f61848071cabfd4fd6dae5bcae4..de8e6d4bc4e0d181699ef7772db819857e341fba 100644 (file)
@@ -43,7 +43,7 @@ def get_jobs(archive_dir):
     dir_contents = os.listdir(archive_dir)
 
     def is_job_dir(parent, subdir):
-        if (os.path.isdir(os.path.join(parent, subdir)) and re.match('\d+$',
+        if (os.path.isdir(os.path.join(parent, subdir)) and re.match(r'\d+$',
                                                                      subdir)):
             return True
         return False
index 26a9d243818f2f98a85e2fdaf4deda49b3015d3a..140c14993f484f50604a03924ac6091d54bdce17 100644 (file)
@@ -52,7 +52,7 @@ def host_shortname(hostname):
 
 def canonicalize_hostname(hostname, user='ubuntu'):
     hostname_expr = hostname_expr_templ.format(
-        lab_domain=config.lab_domain.replace('.', '\.'))
+        lab_domain=config.lab_domain.replace('.', r'\.'))
     match = re.match(hostname_expr, hostname)
     if _is_ipv4(hostname) or _is_ipv6(hostname):
         return "%s@%s" % (user, hostname)
@@ -82,7 +82,7 @@ def canonicalize_hostname(hostname, user='ubuntu'):
 def decanonicalize_hostname(hostname):
     lab_domain = ''
     if config.lab_domain:
-        lab_domain='\.' + config.lab_domain.replace('.', '\.')
+        lab_domain=r'\.' + config.lab_domain.replace('.', r'\.')
     hostname_expr = hostname_expr_templ.format(lab_domain=lab_domain)
     match = re.match(hostname_expr, hostname)
     if match:
index 854ca27d4858bcc59c61d51c82abbede4da7829d..3e427c6fb8514485a1e8cbb23bd9938352496517 100644 (file)
@@ -118,7 +118,7 @@ def remove_osd_tmpfs(ctx):
     log.info('Unmount any osd tmpfs dirs...')
     ctx.cluster.run(
         args=[
-            'egrep', 'tmpfs\s+/mnt', '/etc/mtab', run.Raw('|'),
+            'egrep', r'tmpfs\s+/mnt', '/etc/mtab', run.Raw('|'),
             'awk', '{print $2}', run.Raw('|'),
             'xargs', '-r',
             'sudo', 'umount', run.Raw(';'),
@@ -229,7 +229,7 @@ def remove_yum_timedhosts(ctx):
         if remote.os.package_type != 'rpm':
             continue
         remote.run(
-            args="sudo find /var/cache/yum -name 'timedhosts' -exec rm {} \;",
+            args=r"sudo find /var/cache/yum -name 'timedhosts' -exec rm {} \;",
             check_status=False, timeout=180
         )
 
index 43f568737d53d8df4ea14041554d9a42bb5cf391..bdfde29566f087896b175e2a25d7f502364edda1 100644 (file)
@@ -123,7 +123,7 @@ class OpenStackInstance(object):
         with safe_while(sleep=2, tries=30,
                         action="get ip " + self['id']) as proceed:
             while proceed():
-                found = re.match('.*\d+', self['addresses'])
+                found = re.match(r'.*\d+', self['addresses'])
                 if found:
                     return self['addresses']
                 self.set_info()
@@ -165,7 +165,7 @@ class OpenStackInstance(object):
                 self.private_ip = self.get_ip_neutron()
             except Exception as e:
                 log.debug("ignoring get_ip_neutron exception " + str(e))
-                self.private_ip = re.findall(network + '=([\d.]+)',
+                self.private_ip = re.findall(network + r'=([\d.]+)',
                                              self.get_addresses())[0]
         return self.private_ip
 
index fd833b84fb822dc9a239040f72b98869c1fc054e..9a4bc437422ff31d859baf87a2d3d5e61e08a40c 100644 (file)
@@ -86,7 +86,7 @@ class SystemDState(DaemonState):
             self.status_cmd + " | grep 'Main.*code=exited'",
         )
         line = out.strip().split('\n')[-1]
-        exit_code = int(re.match('.*status=(\d+).*', line).groups()[0])
+        exit_code = int(re.match(r'.*status=(\d+).*', line).groups()[0])
         if exit_code:
             self.remote.run(
                 args=self.output_cmd
index 23066cda3883131f83d5107fe9970dae86fb1182..f8d3eda85adea78ea7d6c299e46dc32f4194b0e0 100644 (file)
@@ -151,7 +151,7 @@ class ProvisionOpenStack(OpenStack):
         """
         return the instance name suffixed with the IP address.
         """
-        digits = map(int, re.findall('(\d+)\.(\d+)\.(\d+)\.(\d+)', ip)[0])
+        digits = map(int, re.findall(r'(\d+)\.(\d+)\.(\d+)\.(\d+)', ip)[0])
         return prefix + "%03d%03d%03d%03d" % tuple(digits)
 
     def create(self, num, os_type, os_version, arch, resources_hint):
index 390385037a8bc8a35d0717e6bcaa76cd6364b6c5..11c67679b41cb968494262d7ac152485a8a97f82 100644 (file)
@@ -37,10 +37,10 @@ class TestInitProvision(object):
             teuthology.provision.reimage(ctx, 'f.q.d.n.org', 'not-defined-type')
         e_str = str(e_info)
         print("Caught exception: " +  e_str)
-        assert e_str.find("configured\sprovisioners") == -1
+        assert e_str.find(r"configured\sprovisioners") == -1
 
         with raises(Exception) as e_info:
             teuthology.provision.reimage(ctx, 'f.q.d.n.org', 'common_type')
         e_str = str(e_info)
         print("Caught exception: " +  e_str)
-        assert e_str.find("used\swith\sone\sprovisioner\sonly") == -1
+        assert e_str.find(r"used\swith\sone\sprovisioner\sonly") == -1
index a8969d4b4fd3d68e95d81babd0427a2070fff404..3a8a0c4f9681b278dc174855075c8a39016d55cb 100644 (file)
@@ -42,5 +42,5 @@ class TestPelagos(object):
                 teuthology.provision.reimage(ctx, 'f.q.d.n.org', 'ptype1')
             e_str = str(e_info)
             print("Caught exception: " +  e_str)
-            assert e_str.find("Name\sor\sservice\snot\sknown") == -1
+            assert e_str.find(r"Name\sor\sservice\snot\sknown") == -1
 
index ffccc00f3aa697e41cfaab0447cc3993b740ee95..1fe189dfbe9bc7a1e1cbdb07b6f71c43413791d9 100644 (file)
@@ -50,7 +50,7 @@ def build_git_url(project, project_owner='ceph'):
         base = config.get_ceph_git_url()
     else:
         base = 'https://github.com/{project_owner}/{project}'
-    url_templ = re.sub('\.git$', '', base)
+    url_templ = re.sub(r'\.git$', '', base)
     return url_templ.format(project_owner=project_owner, project=project)
 
 
index d7375f36160ea7cb16bc9882b963af0eeb31a6c4..edf01cfdb082632c7b1901c6b847577472e13a6c 100644 (file)
@@ -143,7 +143,7 @@ class ResultsSerializer(object):
             return {}
         jobs = {}
         for item in os.listdir(archive_dir):
-            if not re.match('\d+$', item):
+            if not re.match(r'\d+$', item):
                 continue
             job_id = item
             job_dir = os.path.join(archive_dir, job_id)
index 0a737683fe2e578fe99fb3eb420dc6998a4722bb..a73ec1db6c04995b90606aec83f21d2f0a6db729 100644 (file)
@@ -83,9 +83,9 @@ class GenericReason(Reason):
         else:
             if "Test failure:" in self.failure_reason:
                 return self.failure_reason == job.get_failure_reason()
-            elif re.search("workunit test (.*)\) on ", self.failure_reason):
-                workunit_name = re.search("workunit test (.*)\) on ", self.failure_reason).group(1)
-                other_match = re.search("workunit test (.*)\) on ", job.get_failure_reason())
+            elif re.search(r"workunit test (.*)\) on ", self.failure_reason):
+                workunit_name = re.search(r"workunit test (.*)\) on ", self.failure_reason).group(1)
+                other_match = re.search(r"workunit test (.*)\) on ", job.get_failure_reason())
                 return other_match is not None and workunit_name == other_match.group(1)
             else:
                 reason_ratio = difflib.SequenceMatcher(None, self.failure_reason, job.get_failure_reason()).ratio()
@@ -357,7 +357,7 @@ class Job(object):
         for line in grep(tlog_path, "command crashed with signal"):
             log.debug("Found a crash indication: {0}".format(line))
             # tasks.ceph.osd.1.plana82.stderr
-            match = re.search("tasks.ceph.([^\.]+).([^\.]+).([^\.]+).stderr", line)
+            match = re.search(r"tasks.ceph.([^\.]+).([^\.]+).([^\.]+).stderr", line)
             if not match:
                 log.warning("Not-understood crash indication {0}".format(line))
                 continue
index 37f538e6fad0d0927bec925602d3b0cde69c5741..20b191d1daf5d7ebae6db0ac4abfdda517928ce4 100644 (file)
@@ -73,8 +73,8 @@ dict_templ = {
                 }
             },
             'flavor': Placeholder('flavor'),
-            'log-ignorelist': ['\(MDS_ALL_DOWN\)',
-                              '\(MDS_UP_LESS_THAN_MAX\)'],
+            'log-ignorelist': [r'\(MDS_ALL_DOWN\)',
+                              r'\(MDS_UP_LESS_THAN_MAX\)'],
             'sha1': Placeholder('ceph_hash'),
         },
         'ceph-deploy': {
index ab2d8f064f1b671239f84a5f731b625b54418a43..32bb80c51ff51cf76439c2cb916b6b1e554240ab 100644 (file)
@@ -294,7 +294,7 @@ class Run(object):
 
     @staticmethod
     def _repo_name(url):
-        return re.sub('\.git$', '', url.split('/')[-1])
+        return re.sub(r'\.git$', '', url.split('/')[-1])
 
     def choose_suite_branch(self):
         suite_repo_name = self.suite_repo_name
index 92ad7b2d62321d3980e5fbbe49a57a9093be574d..e1a290f78af65351a78ec4eda3e1a4709608a9f3 100644 (file)
@@ -142,7 +142,7 @@ def _remove(ctx, config, remote, debs):
             run.Raw('|'),
             # Any package that is unpacked or half-installed and also requires
             # reinstallation
-            'grep', '^.\(U\|H\)R',
+            'grep', r'^.\(U\|H\)R',
             run.Raw('|'),
             'awk', '{print $2}',
             run.Raw('|'),
index 23c164cd53d48944b1666232a9343b51a6277df0..8879963cafe0bd7bc27019f84c4ce3c82ba416df 100644 (file)
@@ -982,14 +982,14 @@ def generate_legacy_grub_entry(remote, newversion):
         if re.match('^title', line):
             titleline = line
             titlelinenum = linenum
-        if re.match('(^\s+)root', line):
+        if re.match(r'(^\s+)root', line):
             rootline = line
-        if re.match('(^\s+)kernel', line):
+        if re.match(r'(^\s+)kernel', line):
             kernelline = line
             for word in line.split(' '):
                 if 'vmlinuz' in word:
                     kernelversion = word.split('vmlinuz-')[-1]
-        if re.match('(^\s+)initrd', line):
+        if re.match(r'(^\s+)initrd', line):
             initline = line
         if (kernelline != '') and (initline != ''):
             break
index de4314822ddf5cab4ad3b0c763cc21799f8d3a7b..d28d606ef49b0691c04bc5588bd6c6b078eb7ca2 100644 (file)
@@ -141,7 +141,7 @@ class SELinux(Task):
         se_allowlist = self.config.get('allowlist', [])
         if se_allowlist:
             known_denials.extend(se_allowlist)
-        ignore_known_denials = '\'\(' + str.join('\|', known_denials) + '\)\''
+        ignore_known_denials = r'\'\(' + str.join(r'\|', known_denials) + r'\)\''
         for remote in self.cluster.remotes.keys():
             proc = remote.run(
                 args=['sudo', 'grep', '-a', 'avc: .*denied',