diff options
author | Sylvain Pineau <sylvain.pineau@canonical.com> | 2020-07-17 11:58:54 +0200 |
---|---|---|
committer | Sylvain Pineau <sylvain.pineau@canonical.com> | 2020-07-17 11:58:54 +0200 |
commit | 7a017ea84cc35c77055a068858b5ecae8ed30d21 (patch) | |
tree | e2d5f7c03cf53eac373dbce70237e794688fe3e5 /bin | |
parent | 0397f635a66ffb42031d05cd8977209b4e68a726 (diff) |
bin:*.py: Fix Flake8 W503 (Xenial version, 2.5.4)
Can be forced on recent versions with: flake8 --select=W503 ./accelerometer_test.py
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/accelerometer_test.py | 4 | ||||
-rwxr-xr-x | bin/create_connection.py | 4 | ||||
-rwxr-xr-x | bin/frequency_governors_test.py | 57 | ||||
-rwxr-xr-x | bin/graphics_driver.py | 10 | ||||
-rwxr-xr-x | bin/key_test.py | 6 | ||||
-rwxr-xr-x | bin/mac_passthrough.py | 4 | ||||
-rwxr-xr-x | bin/memory_test.py | 4 | ||||
-rwxr-xr-x | bin/pm_log_check.py | 12 | ||||
-rwxr-xr-x | bin/removable_storage_watcher.py | 62 |
9 files changed, 82 insertions, 81 deletions
diff --git a/bin/accelerometer_test.py b/bin/accelerometer_test.py index 93ae07f..130e22d 100755 --- a/bin/accelerometer_test.py +++ b/bin/accelerometer_test.py @@ -88,8 +88,8 @@ class AccelerometerUI(Gtk.Window): def update_axis_icon(self, direction): """Change desired directional icon to checkmark""" - exec('self.%s_icon.set_from_stock' % (direction) - + '(Gtk.STOCK_YES, size=Gtk.IconSize.BUTTON)') + exec('self.%s_icon.set_from_stock' % (direction) + + '(Gtk.STOCK_YES, size=Gtk.IconSize.BUTTON)') def update_debug_label(self, text): """Update axis information in center of UI""" diff --git a/bin/create_connection.py b/bin/create_connection.py index 880151d..9dc977e 100755 --- a/bin/create_connection.py +++ b/bin/create_connection.py @@ -167,8 +167,8 @@ def write_connection_file(name, connection_info): os.fchmod(connection_file.fileno(), 0o600) connection_file.close() except IOError: - print("Can't write to " + CONNECTIONS_PATH + name - + ". Is this command being run as root?", file=sys.stderr) + print("Can't write to " + CONNECTIONS_PATH + name + + ". Is this command being run as root?", file=sys.stderr) sys.exit(1) diff --git a/bin/frequency_governors_test.py b/bin/frequency_governors_test.py index 52dd74a..fb652f5 100755 --- a/bin/frequency_governors_test.py +++ b/bin/frequency_governors_test.py @@ -238,8 +238,8 @@ class CPUScalingTest(object): else: thisTime = stop_elapsed_time - start_elapsed_time if ( - (abs(thisTime - runTime) / runTime) * 100 - < self.retryTolerance + (abs(thisTime - runTime) / runTime) * 100 < + self.retryTolerance ): return runTime else: @@ -272,9 +272,9 @@ class CPUScalingTest(object): minimumFrequency = self.getParameter("scaling_min_freq") currentFrequency = self.getParameter("scaling_cur_freq") if ( - not minimumFrequency - or not currentFrequency - or (minimumFrequency != currentFrequency) + not minimumFrequency or + not currentFrequency or + (minimumFrequency != currentFrequency) ): return False @@ -377,9 +377,9 @@ class CPUScalingTest(object): minimumFrequency = self.getParameter("scaling_min_freq") currentFrequency = self.getParameter("scaling_cur_freq") if ( - not minimumFrequency - or not currentFrequency - or (minimumFrequency != currentFrequency) + not minimumFrequency or + not currentFrequency or + (minimumFrequency != currentFrequency) ): logging.error( "Could not verify that cpu frequency is set to the minimum" @@ -408,9 +408,9 @@ class CPUScalingTest(object): maximumFrequency = self.getParameter("scaling_max_freq") currentFrequency = self.getParameter("scaling_cur_freq") if ( - not maximumFrequency - or not currentFrequency - or (maximumFrequency != currentFrequency) + not maximumFrequency or + not currentFrequency or + (maximumFrequency != currentFrequency) ): logging.error( "Could not verify that cpu frequency is set to the" @@ -430,8 +430,8 @@ class CPUScalingTest(object): % self.maximumFrequencyTestTime) # Verify MHz increase is comparable to time % decrease - predictedSpeedup = (float(maximumFrequency) - / float(minimumFrequency)) + predictedSpeedup = (float(maximumFrequency) / + float(minimumFrequency)) # If "ida" turbo thing, increase the expectation by 8% if self.cpuFlags and self.idaFlag in self.cpuFlags: @@ -439,17 +439,17 @@ class CPUScalingTest(object): "Found %s flag, increasing expected speedup by %.1f%%" % (self.idaFlag, self.idaSpeedupFactor)) predictedSpeedup = \ - (predictedSpeedup - * (1.0 / (1.0 - (self.idaSpeedupFactor / 100.0)))) + (predictedSpeedup * + (1.0 / (1.0 - (self.idaSpeedupFactor / 100.0)))) if self.minimumFrequencyTestTime and self.maximumFrequencyTestTime: - measuredSpeedup = (self.minimumFrequencyTestTime - / self.maximumFrequencyTestTime) + measuredSpeedup = (self.minimumFrequencyTestTime / + self.maximumFrequencyTestTime) logging.info("CPU Frequency Speed Up: %.2f" % predictedSpeedup) logging.info("Measured Speed Up: %.2f" % measuredSpeedup) differenceSpeedUp = ( - ((measuredSpeedup - predictedSpeedup) / predictedSpeedup) - * 100) + ((measuredSpeedup - predictedSpeedup) / predictedSpeedup) * + 100) logging.info( "Percentage Difference %.1f%%" % differenceSpeedUp) if differenceSpeedUp > self.speedUpTolerance: @@ -504,8 +504,8 @@ class CPUScalingTest(object): # Compare the timing to the max results from earlier, # again time should be within self.speedUpTolerance differenceOnDemandVsMaximum = \ - (abs(onDemandTestTime - self.maximumFrequencyTestTime) - / self.maximumFrequencyTestTime) * 100 + (abs(onDemandTestTime - self.maximumFrequencyTestTime) / + self.maximumFrequencyTestTime) * 100 logging.info( "Percentage Difference vs. maximum frequency: %.1f%%" % differenceOnDemandVsMaximum) @@ -546,9 +546,9 @@ class CPUScalingTest(object): maximumFrequency = self.getParameter("scaling_max_freq") currentFrequency = self.getParameter("scaling_cur_freq") if ( - not maximumFrequency - or not currentFrequency - or (maximumFrequency != currentFrequency) + not maximumFrequency or + not currentFrequency or + (maximumFrequency != currentFrequency) ): logging.error( "Current cpu frequency of %s is not set to the maximum " @@ -567,8 +567,8 @@ class CPUScalingTest(object): if performanceTestTime and self.maximumFrequencyTestTime: # Compare the timing to the max results differencePerformanceVsMaximum = \ - (abs(performanceTestTime - self.maximumFrequencyTestTime) - / self.maximumFrequencyTestTime) * 100 + (abs(performanceTestTime - self.maximumFrequencyTestTime) / + self.maximumFrequencyTestTime) * 100 logging.info( "Percentage Difference vs. maximum frequency: %.1f%%" % differencePerformanceVsMaximum) @@ -631,8 +631,9 @@ class CPUScalingTest(object): if conservativeTestTime and self.minimumFrequencyTestTime: # Compare the timing to the max results differenceConservativeVsMinimum = \ - (abs(conservativeTestTime - self.minimumFrequencyTestTime) - / self.minimumFrequencyTestTime) * 100 + (abs(conservativeTestTime - + self.minimumFrequencyTestTime) / + self.minimumFrequencyTestTime) * 100 logging.info( "Percentage Difference vs. minimum frequency: %.1f%%" % differenceConservativeVsMinimum) diff --git a/bin/graphics_driver.py b/bin/graphics_driver.py index 0b41050..f9bdff3 100755 --- a/bin/graphics_driver.py +++ b/bin/graphics_driver.py @@ -351,12 +351,12 @@ def hybrid_graphics_check(xlog): drivers.append(module['name']) print('Loaded DDX Drivers: %s' % ', '.join(drivers)) - has_hybrid_graphics = (len(cards) > 1 and is_laptop() - and (cards_dict.get('8086') in formatted_cards - or cards_dict.get('1002') in formatted_cards)) + has_hybrid_graphics = (len(cards) > 1 and is_laptop() and + (cards_dict.get('8086') in formatted_cards or + cards_dict.get('1002') in formatted_cards)) - print('Hybrid Graphics: %s' % (has_hybrid_graphics - and 'yes' or 'no')) + print('Hybrid Graphics: %s' % (has_hybrid_graphics and + 'yes' or 'no')) return 0 diff --git a/bin/key_test.py b/bin/key_test.py index 883bf32..f94abd3 100755 --- a/bin/key_test.py +++ b/bin/key_test.py @@ -122,9 +122,9 @@ class Reporter(object): index = 0 length = len(raw_bytes) while index < length: - if (index + 2 < length and (raw_bytes[index] & 0x7f) == 0 - and (raw_bytes[index + 1] & 0x80) != 0 - and (raw_bytes[index + 2] & 0x80) != 0): + if (index + 2 < length and (raw_bytes[index] & 0x7f) == 0 and + (raw_bytes[index + 1] & 0x80) != 0 and + (raw_bytes[index + 2] & 0x80) != 0): code = (((raw_bytes[index + 1] & 0x7f) << 7) | (raw_bytes[2] & 0x7f)) index += 3 diff --git a/bin/mac_passthrough.py b/bin/mac_passthrough.py index 92d2eb6..1707a1e 100755 --- a/bin/mac_passthrough.py +++ b/bin/mac_passthrough.py @@ -53,8 +53,8 @@ def get_pass_through_mac(): for line in dsdt: if 'AUXMAC' in line: bios_mac = line.split('#')[1] - print('Pass-through MAC address from DSDT table: ' - + bios_mac.lower()) + print('Pass-through MAC address from DSDT table: ' + + bios_mac.lower()) return bios_mac.lower() raise SystemExit('No AUXMAC is found in DSDT table, ' 'MAC address pass-through is not working.') diff --git a/bin/memory_test.py b/bin/memory_test.py index 4cd6008..a472b71 100755 --- a/bin/memory_test.py +++ b/bin/memory_test.py @@ -75,8 +75,8 @@ class MemoryTest(): self.process_memory = self.free_memory try: arch = self._command_out("arch").decode() - if (re.match(r"(i[0-9]86|s390|arm.*)", arch) - and self.free_memory > 1024): + if (re.match(r"(i[0-9]86|s390|arm.*)", arch) and + self.free_memory > 1024): self.is_process_limited = True self.process_memory = 1024 # MB, due to 32-bit address space print("%s arch, Limiting Process Memory: %u" % ( diff --git a/bin/pm_log_check.py b/bin/pm_log_check.py index fae8eca..1d41ed6 100755 --- a/bin/pm_log_check.py +++ b/bin/pm_log_check.py @@ -104,8 +104,8 @@ class Parser(object): command_output = {} break if ( - self.is_executing_line(line) - or self.is_getting_info_line(line) + self.is_executing_line(line) or + self.is_getting_info_line(line) ): # Skip commands with no output iterator.unnext(line) @@ -135,8 +135,8 @@ class Parser(object): value = [] for line in iterator: if ( - self.is_logging_line(line) - or self.is_field_line(line) + self.is_logging_line(line) or + self.is_field_line(line) ): iterator.unnext(line) break @@ -209,8 +209,8 @@ def compare_results(results): result_output = result[command] error_messages = [] - fields = (set(baseline_output.keys()) - | set(result_output.keys())) + fields = (set(baseline_output.keys()) | + set(result_output.keys())) for field in fields: baseline_field = baseline_output.get(field, '') result_field = result_output.get(field, '') diff --git a/bin/removable_storage_watcher.py b/bin/removable_storage_watcher.py index 7120f6d..c13439e 100755 --- a/bin/removable_storage_watcher.py +++ b/bin/removable_storage_watcher.py @@ -127,10 +127,10 @@ class UDisks1StorageDeviceListener: for dev in desired_bus_devices: if self._memorycard: if ( - dev.bus != 'sdio' - and not FLASH_RE.search(dev.media) - and not CARD_READER_RE.search(dev.model) - and not GENERIC_RE.search(dev.vendor) + dev.bus != 'sdio' and + not FLASH_RE.search(dev.media) and + not CARD_READER_RE.search(dev.model) and + not GENERIC_RE.search(dev.vendor) ): logging.debug( "The device does not seem to be a memory" @@ -140,9 +140,9 @@ class UDisks1StorageDeviceListener: print(message % {'bus': 'memory card', 'file': dev.file}) else: if ( - FLASH_RE.search(dev.media) - or CARD_READER_RE.search(dev.model) - or GENERIC_RE.search(dev.vendor) + FLASH_RE.search(dev.media) or + CARD_READER_RE.search(dev.model) or + GENERIC_RE.search(dev.vendor) ): logging.debug("The device seems to be a memory" " card (bus: %r (model: %r), skipping", @@ -590,47 +590,47 @@ class UDisks2StorageDeviceListener: # require the device to be mounted if ( record.value.iface_name == - "org.freedesktop.UDisks2.Drive" - and record.value.delta_type == DELTA_TYPE_PROP - and record.value.prop_name == "ConnectionBus" - and record.value.prop_value == "" + "org.freedesktop.UDisks2.Drive" and + record.value.delta_type == DELTA_TYPE_PROP and + record.value.prop_name == "ConnectionBus" and + record.value.prop_value == "" ): needs.remove('mounted') # Detect block devices designated for filesystems if ( record.value.iface_name == - "org.freedesktop.UDisks2.Block" - and record.value.delta_type == DELTA_TYPE_PROP - and record.value.prop_name == "IdUsage" - and record.value.prop_value == "filesystem" + "org.freedesktop.UDisks2.Block" and + record.value.delta_type == DELTA_TYPE_PROP and + record.value.prop_name == "IdUsage" and + record.value.prop_value == "filesystem" ): found.add('block-fs') # Memorize the block device path elif ( record.value.iface_name == - "org.freedesktop.UDisks2.Block" - and record.value.delta_type == DELTA_TYPE_PROP - and record.value.prop_name == "PreferredDevice" + "org.freedesktop.UDisks2.Block" and + record.value.delta_type == DELTA_TYPE_PROP and + record.value.prop_name == "PreferredDevice" ): object_block_device = record.value.prop_value # Ensure the device is a partition elif (record.value.iface_name == - "org.freedesktop.UDisks2.Partition" - and record.value.delta_type == DELTA_TYPE_IFACE): + "org.freedesktop.UDisks2.Partition" and + record.value.delta_type == DELTA_TYPE_IFACE): found.add('partition') # Ensure the device is not empty elif (record.value.iface_name == - "org.freedesktop.UDisks2.Block" - and record.value.delta_type == DELTA_TYPE_PROP - and record.value.prop_name == "Size" - and record.value.prop_value > 0): + "org.freedesktop.UDisks2.Block" and + record.value.delta_type == DELTA_TYPE_PROP and + record.value.prop_name == "Size" and + record.value.prop_value > 0): found.add('non-empty') # Ensure the filesystem is mounted elif (record.value.iface_name == - "org.freedesktop.UDisks2.Filesystem" - and record.value.delta_type == DELTA_TYPE_PROP - and record.value.prop_name == "MountPoints" - and record.value.prop_value != []): + "org.freedesktop.UDisks2.Filesystem" and + record.value.delta_type == DELTA_TYPE_PROP and + record.value.prop_name == "MountPoints" and + record.value.prop_value != []): found.add('mounted') # On some systems partition are reported as mounted # filesystems, without 'partition' record @@ -638,9 +638,9 @@ class UDisks2StorageDeviceListener: needs.remove('partition') # Finally memorize the drive the block device belongs to elif (record.value.iface_name == - "org.freedesktop.UDisks2.Block" - and record.value.delta_type == DELTA_TYPE_PROP - and record.value.prop_name == "Drive"): + "org.freedesktop.UDisks2.Block" and + record.value.delta_type == DELTA_TYPE_PROP and + record.value.prop_name == "Drive"): drive_object_path = record.value.prop_value logging.debug("Finished analyzing %s, found: %s, needs: %s" " drive_object_path: %s", object_path, found, needs, |