diff --git a/checkbox-support/checkbox_support/scripts/audio_settings.py b/checkbox-support/checkbox_support/scripts/audio_settings.py index 41291c8ceb..9e91df896e 100644 --- a/checkbox-support/checkbox_support/scripts/audio_settings.py +++ b/checkbox-support/checkbox_support/scripts/audio_settings.py @@ -30,14 +30,14 @@ DIRECTIONS = {"source": "input", "sink": "output"} # use %s string format to compatible with other python version -default_pattern = "(?<=Default %s: ).*" -index_regex = re.compile("(?<=Sink Input #)[0-9]*") -muted_regex = re.compile("(?<=Mute: ).*") -name_regex = re.compile("(?<=Name:).*") -channel_map_regex = re.compile("(?<=Channel Map: ).*") +default_pattern = r"(?<=Default %s: ).*" +index_regex = re.compile(r"(?<=Sink Input #)[0-9]*") +muted_regex = re.compile(r"(?<=Mute: ).*") +name_regex = re.compile(r"(?<=Name:).*") +channel_map_regex = re.compile(r"(?<=Channel Map: ).*") # use %s string format to compatible with other python version -entry_pattern = "Name: %s.*?(?=Properties)" +entry_pattern = r"Name: %s.*?(?=Properties)" volume_pattern = r"Volume: .*(?:%s):[\w\/0-9 ]* ([0-9]*)%%" diff --git a/checkbox-support/checkbox_support/scripts/fwts_test.py b/checkbox-support/checkbox_support/scripts/fwts_test.py index 8dc9abd04b..17b587a9c9 100644 --- a/checkbox-support/checkbox_support/scripts/fwts_test.py +++ b/checkbox-support/checkbox_support/scripts/fwts_test.py @@ -165,7 +165,7 @@ ) # By default, we launch all the tests TESTS = sorted(list(set(QA_TESTS + HWE_TESTS))) -SLEEP_TIME_RE = re.compile("(Suspend|Resume):\s+([\d\.]+)\s+seconds.") +SLEEP_TIME_RE = re.compile(r"(Suspend|Resume):\s+([\d\.]+)\s+seconds.") def get_sleep_times(log, start_marker): diff --git a/providers/base/bin/battery_test.py b/providers/base/bin/battery_test.py index 79fd7b7939..ad791a7444 100755 --- a/providers/base/bin/battery_test.py +++ b/providers/base/bin/battery_test.py @@ -66,7 +66,7 @@ def find_battery(): else: out, err = batinfo.communicate() if out: - device_regex = re.compile("Device: (.*battery_.*)") + device_regex = re.compile(r"Device: (.*battery_.*)") batteries = device_regex.findall(out) if len(batteries) == 0: return None diff --git a/providers/base/bin/disk_info.py b/providers/base/bin/disk_info.py index 99fd093d39..f957f1d606 100755 --- a/providers/base/bin/disk_info.py +++ b/providers/base/bin/disk_info.py @@ -39,11 +39,11 @@ def main(): Outputs kernel name, model and size data """ pattern = re.compile( - 'KNAME="(?P.*)" ' - 'TYPE="(?P.*)" ' - 'SIZE="(?P.*)" ' - 'MODEL="(?P.*)" ' - 'MOUNTPOINT="(?P.*)"' + r'KNAME="(?P.*)" ' + r'TYPE="(?P.*)" ' + r'SIZE="(?P.*)" ' + r'MODEL="(?P.*)" ' + r'MOUNTPOINT="(?P.*)"' ) try: lsblk = check_output( diff --git a/providers/base/bin/frequency_governors_test.py b/providers/base/bin/frequency_governors_test.py index 0bf5f0d952..b4b051349b 100755 --- a/providers/base/bin/frequency_governors_test.py +++ b/providers/base/bin/frequency_governors_test.py @@ -34,7 +34,7 @@ def getCPUFreqDirectories(self): logging.error("No file %s" % self.sysCPUDirectory) return None # look for cpu subdirectories - pattern = re.compile("cpu(?P[0-9]+)") + pattern = re.compile(r"cpu(?P[0-9]+)") self.cpufreqDirectories = list() for subdirectory in os.listdir(self.sysCPUDirectory): match = pattern.search(subdirectory) diff --git a/providers/base/bin/graphics_stress_test.py b/providers/base/bin/graphics_stress_test.py index e857c74754..1ee4588fcb 100755 --- a/providers/base/bin/graphics_stress_test.py +++ b/providers/base/bin/graphics_stress_test.py @@ -233,8 +233,8 @@ def _print_test_info(self, suites="all", iteration=1, show_errors=False): temp_file.close() # Read values from the file - errors = re.compile(".*test error.*") - results = re.compile("(.+) tests passed of (.+) total.*") + errors = re.compile(r".*test error.*") + results = re.compile(r"(.+) tests passed of (.+) total.*") first_error = True with open(temp_file.name) as temp_handle: @@ -308,7 +308,7 @@ def get_suites_list(self): proc = process.communicate()[1].split("\n") found = False - tests_pattern = re.compile(".*Available tests: *(.+).*") + tests_pattern = re.compile(r".*Available tests: *(.+).*") temp_line = "" tests = [] for line in proc: diff --git a/providers/base/bin/ipmi_test.py b/providers/base/bin/ipmi_test.py index 9bab23409c..dadaae70a3 100755 --- a/providers/base/bin/ipmi_test.py +++ b/providers/base/bin/ipmi_test.py @@ -170,7 +170,7 @@ def get_pwr_status(self): """ logging.info("-----------------------") logging.info("Fetching power status:") - regex = re.compile("^System Power") + regex = re.compile(r"^System Power") try: output = self._subproc_logging(self._cmd_ipmi_chassis) for line in output.rstrip().split("\n"): @@ -198,7 +198,7 @@ def get_bmc_info(self): def _ipmi_version_hlpr(self): """Ipmi version discovery loop.""" - regex = re.compile("^IPMI Version") + regex = re.compile(r"^IPMI Version") output = self._subproc_logging(self._cmd_get_bmc_info) for line in output.rstrip().split("\n"): if re.search(regex, line): @@ -245,7 +245,7 @@ def get_ipmi_channel(self): logging.info("Fetching IPMI channels:") # support multiple channels channel = [] - regex = re.compile("Section User") + regex = re.compile(r"Section User") # test channels 0 - 15 for i in range(16): # channel 12, 13 are invalid channels, skip diff --git a/providers/base/bin/network.py b/providers/base/bin/network.py index a858a32e8e..6ac375cf45 100755 --- a/providers/base/bin/network.py +++ b/providers/base/bin/network.py @@ -461,7 +461,7 @@ def run(self): print("Running ping test...") result = 0 - time_re = re.compile("(?<=time=)[0-9]*") + time_re = re.compile(r"(?<=time=)[0-9]*") for line in out.decode().split("\n"): time = time_re.search(line) diff --git a/providers/base/bin/pm_log_check.py b/providers/base/bin/pm_log_check.py index c123f986e5..4a89dc50b2 100755 --- a/providers/base/bin/pm_log_check.py +++ b/providers/base/bin/pm_log_check.py @@ -41,14 +41,14 @@ class Parser(object): r"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}" ).search is_getting_info_line = re.compile( - "Gathering hardware information...$" + r"Gathering hardware information...$" ).search - is_executing_line = re.compile("Executing: '(?P.*)'...$").search - is_output_line = re.compile("Output:$").search + is_executing_line = re.compile(r"Executing: '(?P.*)'...$").search + is_output_line = re.compile(r"Output:$").search is_field_line = re.compile( - "^- (?Preturncode|stdout|stderr):$" + r"^- (?Preturncode|stdout|stderr):$" ).match - is_test_complete_line = re.compile("test complete$").search + is_test_complete_line = re.compile(r"test complete$").search def __init__(self, filename): self.filename = filename diff --git a/providers/base/bin/removable_storage_test.py b/providers/base/bin/removable_storage_test.py index 8a663b0147..53ef3431e3 100755 --- a/providers/base/bin/removable_storage_test.py +++ b/providers/base/bin/removable_storage_test.py @@ -181,9 +181,9 @@ def clean_up(self, target): def _find_parent(self, device): if self.lsblk: pattern = re.compile( - 'KNAME="(?P.*)" ' - 'TYPE="(?P.*)" ' - 'MOUNTPOINT="(?P.*)"' + r'KNAME="(?P.*)" ' + r'TYPE="(?P.*)" ' + r'MOUNTPOINT="(?P.*)"' ) for line in self.lsblk.splitlines(): m = pattern.match(line) diff --git a/providers/resource/bin/block_device_resource.py b/providers/resource/bin/block_device_resource.py index 9a23a74947..cac4ea84db 100755 --- a/providers/resource/bin/block_device_resource.py +++ b/providers/resource/bin/block_device_resource.py @@ -8,7 +8,7 @@ from itertools import chain from subprocess import check_output, CalledProcessError -rootdir_pattern = re.compile("^.*?/devices") +rootdir_pattern = re.compile(r"^.*?/devices") # NOTE: If raid_types changes, also change it in disk_smart script! raid_types = ["megaraid", "cciss", "3ware", "areca"]