From bebdbba4a60bc226e204113b6933dd280467bdd5 Mon Sep 17 00:00:00 2001 From: cuixucui <350255958@qq.com> Date: Wed, 1 Jul 2020 11:13:39 +0800 Subject: [PATCH] Modify static method --- hwcompatible/commandUI.py | 3 +-- hwcompatible/compatibility.py | 3 +-- hwcompatible/device.py | 4 ++-- hwcompatible/job.py | 3 +-- tests/acpi/acpi.py | 3 +-- tests/cdrom/cdrom.py | 6 ++---- tests/clock/clock.py | 3 +-- tests/cpufreq/cpufreq.py | 15 +++++---------- tests/disk/disk.py | 3 +-- tests/ipmi/ipmi.py | 6 ++---- tests/memory/memory.py | 9 +++------ tests/network/network.py | 9 +++------ tests/nvme/nvme.py | 3 +-- tests/system/system.py | 15 +++++---------- tests/usb/usb.py | 3 +-- tests/watchdog/watchdog.py | 3 +-- 16 files changed, 31 insertions(+), 60 deletions(-) diff --git a/hwcompatible/commandUI.py b/hwcompatible/commandUI.py index bf83692..9fb055d 100755 --- a/hwcompatible/commandUI.py +++ b/hwcompatible/commandUI.py @@ -98,8 +98,7 @@ class CommandUI(object): return False sys.stdout.write("Please reply %s or %s.\n" % (YES, NO)) - @staticmethod - def prompt_edit(label, value, choices=None): + def prompt_edit(self, label, value, choices=None): """ prompt choice edit :param label: diff --git a/hwcompatible/compatibility.py b/hwcompatible/compatibility.py index 6492cac..00cc9dd 100755 --- a/hwcompatible/compatibility.py +++ b/hwcompatible/compatibility.py @@ -461,8 +461,7 @@ class EulerCertification(object): self.test_factory.sort(key=lambda k: k["name"]) FactoryDocument(CertEnv.factoryfile, self.test_factory).save() - @staticmethod - def search_factory(obj_test, test_factory): + def search_factory(self, obj_test, test_factory): """ Determine whether test exists by searching test_factory :param obj_test: diff --git a/hwcompatible/device.py b/hwcompatible/device.py index 2ee2ac5..1b11026 100755 --- a/hwcompatible/device.py +++ b/hwcompatible/device.py @@ -63,8 +63,8 @@ class CertDevice(object): else: prop = line.split(":", 1) if len(prop) == 2: - tp = prop[0].strip(r'\ \'\n') - attribute = prop[1].strip(r'\ \'\n') + tp = prop[0].strip('\ \'\n') + attribute = prop[1].strip('\ \'\n') if tp == "E": keyvalue = attribute.split("=", 1) if len(keyvalue) == 2: diff --git a/hwcompatible/job.py b/hwcompatible/job.py index 0089984..90c4170 100755 --- a/hwcompatible/job.py +++ b/hwcompatible/job.py @@ -51,8 +51,7 @@ class Job(object): for parameter_name, parameter_value in self.args.test_parameters: self.test_parameters[parameter_name] = parameter_value - @staticmethod - def discover(testname, subtests_filter=None): + def discover(self, testname, subtests_filter=None): """ discover test :param testname: diff --git a/tests/acpi/acpi.py b/tests/acpi/acpi.py index 17cc752..f267210 100755 --- a/tests/acpi/acpi.py +++ b/tests/acpi/acpi.py @@ -24,8 +24,7 @@ class AcpiTest(Test): Test.__init__(self) self.requirements = ["acpica-tools"] - @staticmethod - def test(): + def test(self): try: Command("acpidump").echo() return True diff --git a/tests/cdrom/cdrom.py b/tests/cdrom/cdrom.py index 967b1be..37e7f0e 100755 --- a/tests/cdrom/cdrom.py +++ b/tests/cdrom/cdrom.py @@ -77,8 +77,7 @@ class CDRomTest(Test): return False return True - @staticmethod - def get_type(device): + def get_type(self, device): """ Get the type of CDROM :param device: @@ -234,8 +233,7 @@ class CDRomTest(Test): print(e) return False - @staticmethod - def cmp_tree(dir1, dir2): + def cmp_tree(self, dir1, dir2): """ Compare the differences between the two directories :param dir1: diff --git a/tests/clock/clock.py b/tests/clock/clock.py index d0c20f9..df5a1c9 100755 --- a/tests/clock/clock.py +++ b/tests/clock/clock.py @@ -23,8 +23,7 @@ class ClockTest(Test): """ Clock Test """ - @staticmethod - def test(): + def test(self): """ Clock test case :return: diff --git a/tests/cpufreq/cpufreq.py b/tests/cpufreq/cpufreq.py index 4d1de9f..66bc8da 100644 --- a/tests/cpufreq/cpufreq.py +++ b/tests/cpufreq/cpufreq.py @@ -63,8 +63,7 @@ class CPU(object): return True - @staticmethod - def set_freq(freq, cpu='all'): + def set_freq(self, freq, cpu='all'): """ Set CPU frequency :param freq: @@ -79,8 +78,7 @@ class CPU(object): print(e) return False - @staticmethod - def get_freq(cpu): + def get_freq(self, cpu): """ Get CPU frequency :param cpu: @@ -93,8 +91,7 @@ class CPU(object): print(e) return False - @staticmethod - def set_governor(governor, cpu='all'): + def set_governor(self, governor, cpu='all'): """ Set the frequency governor mode of CPU :param governor: @@ -109,8 +106,7 @@ class CPU(object): print(e) return False - @staticmethod - def get_governor(cpu): + def get_governor(self, cpu): """ Get cpu governor :param cpu: @@ -123,8 +119,7 @@ class CPU(object): print(e) return False - @staticmethod - def find_path(parent_dir, target_name): + def find_path(self, parent_dir, target_name): """ Find the target path from the specified directory :param parent_dir: diff --git a/tests/disk/disk.py b/tests/disk/disk.py index 3bb7682..d561a41 100755 --- a/tests/disk/disk.py +++ b/tests/disk/disk.py @@ -207,8 +207,7 @@ class DiskTest(Test): print("#############") return return_code - @staticmethod - def do_fio(filepath, size, option): + def do_fio(self, filepath, size, option): if os.path.isdir(filepath): file_opt = "-directory=%s" % filepath else: diff --git a/tests/ipmi/ipmi.py b/tests/ipmi/ipmi.py index 5f8fa31..c336d35 100755 --- a/tests/ipmi/ipmi.py +++ b/tests/ipmi/ipmi.py @@ -24,8 +24,7 @@ class IpmiTest(Test): Test.__init__(self) self.requirements = ["OpenIPMI", "ipmitool"] - @staticmethod - def start_ipmi(): + def start_ipmi(self): """ Start IPMI test :return: @@ -38,8 +37,7 @@ class IpmiTest(Test): return False return True - @staticmethod - def ipmitool(): + def ipmitool(self): """ Testing with iptool tools :return: diff --git a/tests/memory/memory.py b/tests/memory/memory.py index 89f515d..8f64221 100755 --- a/tests/memory/memory.py +++ b/tests/memory/memory.py @@ -186,8 +186,7 @@ class MemoryTest(Test): return False return True - @staticmethod - def hot_plug_verify(): + def hot_plug_verify(self): """ Verify hot plug :return: @@ -232,8 +231,7 @@ class MemoryTest(Test): if total_mem_3 != total_mem_1: return False - @staticmethod - def online_memory(memory_path): + def online_memory(self, memory_path): """ Set memory online :param memory_path: @@ -247,8 +245,7 @@ class MemoryTest(Test): print("Error: fail to online %s." % memory_path) return False - @staticmethod - def offline_memory(memory_path): + def offline_memory(self, memory_path): """ Set memory offline :param memory_path: diff --git a/tests/network/network.py b/tests/network/network.py index 296e561..ba6d621 100755 --- a/tests/network/network.py +++ b/tests/network/network.py @@ -50,8 +50,7 @@ class NetworkTest(Test): self.target_bandwidth_percent = 0.8 self.testfile = 'testfile' - @staticmethod - def ifdown(interface): + def ifdown(self, interface): """ Judge whether the specified interface is closed successfully :param interface: @@ -64,8 +63,7 @@ class NetworkTest(Test): time.sleep(1) return False - @staticmethod - def ifup(interface): + def ifup(self, interface): """ Judge whether the specified interface is enabled successfully :param interface: @@ -78,8 +76,7 @@ class NetworkTest(Test): return True return False - @staticmethod - def get_other_interfaces(): + def get_other_interfaces(self): """ Get other interfaces :return: diff --git a/tests/nvme/nvme.py b/tests/nvme/nvme.py index 23ca495..daf0634 100755 --- a/tests/nvme/nvme.py +++ b/tests/nvme/nvme.py @@ -86,8 +86,7 @@ class NvmeTest(Test): print(e) return False - @staticmethod - def in_use(disk): + def in_use(self, disk): """ Determine whether the swapon is in use :param disk: diff --git a/tests/system/system.py b/tests/system/system.py index 55dc1c2..7967735 100755 --- a/tests/system/system.py +++ b/tests/system/system.py @@ -68,8 +68,7 @@ class SystemTest(Test): return return_code - @staticmethod - def check_certrpm(): + def check_certrpm(self): """ Check installed cert package :return: @@ -168,8 +167,7 @@ class SystemTest(Test): return return_code - @staticmethod - def get_modules(sign): + def get_modules(self, sign): """ Get the module with signs character :param sign: @@ -238,8 +236,7 @@ class SystemTest(Test): print("") return True - @staticmethod - def read_abi_whitelist(whitelist): + def read_abi_whitelist(self, whitelist): """ Read abi whitelist :param whitelist: @@ -296,8 +293,7 @@ class SystemTest(Test): nm.close() return self.readSymbols(symbols) - @staticmethod - def get_modulefile(module): + def get_modulefile(self, module): """ Get module file :param module: @@ -312,8 +308,7 @@ class SystemTest(Test): print("Error: could no find module file for %s:" % module) return None - @staticmethod - def check_selinux(): + def check_selinux(self): """ check selinux :return: diff --git a/tests/usb/usb.py b/tests/usb/usb.py index 78500b7..5b7c09a 100755 --- a/tests/usb/usb.py +++ b/tests/usb/usb.py @@ -97,8 +97,7 @@ class UsbTest(Test): if self.ui.prompt_confirm("All usb sockets have been tested?"): return True - @staticmethod - def get_usb(): + def get_usb(self): """ Get usb :return: diff --git a/tests/watchdog/watchdog.py b/tests/watchdog/watchdog.py index 39548bb..12ca1bb 100755 --- a/tests/watchdog/watchdog.py +++ b/tests/watchdog/watchdog.py @@ -65,8 +65,7 @@ class WatchDogTest(Test): print("") return False - @staticmethod - def startup(): + def startup(self): """ Initialization before test :return: -- GitLab