This is an automated email from the ASF dual-hosted git repository. dahn pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push: new c6d3f6e623e pre-commit: enable Python flake8 rule `E271` (#9358) c6d3f6e623e is described below commit c6d3f6e623e35aadbe6e7d1db56d1d3244b55f09 Author: John Bampton <jbamp...@users.noreply.github.com> AuthorDate: Tue Jul 9 18:17:53 2024 +1000 pre-commit: enable Python flake8 rule `E271` (#9358) --- .github/linters/.flake8 | 3 ++- python/lib/cloud_utils.py | 2 +- python/lib/cloudutils/syscfg.py | 4 ++-- python/lib/cloudutils/utilities.py | 4 ++-- systemvm/debian/root/monitorServices.py | 2 +- test/integration/component/maint/testpath_vMotion_vmware.py | 2 +- test/integration/component/test_interop_xd_ccp.py | 4 ++-- test/integration/component/test_rootvolume_resize.py | 2 +- test/integration/smoke/test_kubernetes_clusters.py | 2 +- test/integration/smoke/test_privategw_acl.py | 2 +- test/integration/smoke/test_privategw_acl_ovs_gre.py | 2 +- tools/marvin/marvin/cloudstackException.py | 2 +- tools/marvin/marvin/dbConnection.py | 2 +- tools/marvin/marvin/lib/ncc.py | 2 +- 14 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/linters/.flake8 b/.github/linters/.flake8 index c513b0e3c4b..73cb430f182 100644 --- a/.github/linters/.flake8 +++ b/.github/linters/.flake8 @@ -22,6 +22,7 @@ # E224 Tab after operator # E227 Missing whitespace around bitwise or shift operator # E242 Tab after ',' +# E271 Multiple spaces after keyword # E273 Tab after keyword # E274 Tab before keyword # E713 Test for membership should be 'not in' @@ -38,4 +39,4 @@ exclude = .git, venv -select = E112,E113,E133,E223,E224,E227,E242,E273,E274,E713,E742,E743,E901,E902,W291,W292,W293,W391 +select = E112,E113,E133,E223,E224,E227,E242,E271,E273,E274,E713,E742,E743,E901,E902,W291,W292,W293,W391 diff --git a/python/lib/cloud_utils.py b/python/lib/cloud_utils.py index 3d452ee48d6..16d9f17e8b4 100644 --- a/python/lib/cloud_utils.py +++ b/python/lib/cloud_utils.py @@ -375,7 +375,7 @@ def list_zonespods(host): x = [ (zonename,podname) for pod in dom.childNodes[0].childNodes for podname in [ x.childNodes[0].wholeText for x in pod.childNodes if x.tagName == "name" ] - for zonename in [ x.childNodes[0].wholeText for x in pod.childNodes if x.tagName == "zonename" ] + for zonename in [ x.childNodes[0].wholeText for x in pod.childNodes if x.tagName == "zonename" ] ] return x diff --git a/python/lib/cloudutils/syscfg.py b/python/lib/cloudutils/syscfg.py index 19032ce4aff..fe68b02dfe8 100755 --- a/python/lib/cloudutils/syscfg.py +++ b/python/lib/cloudutils/syscfg.py @@ -114,7 +114,7 @@ class sysConfigAgent(sysConfig): pass if size != -1 and size < (30 * 1024 * 1024): - raise CloudRuntimeException("Need at least 30G free disk space under /var/lib/libvirt/images") + raise CloudRuntimeException("Need at least 30G free disk space under /var/lib/libvirt/images") #check memory mem = -1 @@ -124,7 +124,7 @@ class sysConfigAgent(sysConfig): pass if mem != -1 and mem < 1: - raise CloudRuntimeException("Need at least 1G memory") + raise CloudRuntimeException("Need at least 1G memory") if os.geteuid() != 0: diff --git a/python/lib/cloudutils/utilities.py b/python/lib/cloudutils/utilities.py index 5a6114f1011..5b07ff1eff6 100755 --- a/python/lib/cloudutils/utilities.py +++ b/python/lib/cloudutils/utilities.py @@ -47,11 +47,11 @@ class bash: alarm(0) except Alarm: os.kill(self.process.pid, SIGKILL) - raise CloudRuntimeException("Timeout during command execution") + raise CloudRuntimeException("Timeout during command execution") self.success = self.process.returncode == 0 except: - raise CloudRuntimeException(formatExceptionInfo()) + raise CloudRuntimeException(formatExceptionInfo()) if not self.success: logging.debug("Failed to execute:" + self.getErrMsg()) diff --git a/systemvm/debian/root/monitorServices.py b/systemvm/debian/root/monitorServices.py index 11169d4bdb8..0b7c9db8a5a 100755 --- a/systemvm/debian/root/monitorServices.py +++ b/systemvm/debian/root/monitorServices.py @@ -67,7 +67,7 @@ def getServicesConfig( config_file_path = "/etc/monitor.conf" ): process_dict[section][name] = value printd (" %s = %r" % (name, value)) - return process_dict + return process_dict def printd (msg): """ diff --git a/test/integration/component/maint/testpath_vMotion_vmware.py b/test/integration/component/maint/testpath_vMotion_vmware.py index b37db8aa09a..06facdd9212 100644 --- a/test/integration/component/maint/testpath_vMotion_vmware.py +++ b/test/integration/component/maint/testpath_vMotion_vmware.py @@ -1190,7 +1190,7 @@ class TestStorageLiveMigrationVmware(cloudstackTestCase): a) Create VM snapshots to check data integrity - @method used : VmSnapshotToCheckDataIntegrity(self, vm) c) Check for VM accessibility by sshing to the VM - @method used : check_for_vm_access_by_ssh_using_nat(self, virtual_machine_1) """ - if not self.zone.localstorageenabled: + if not self.zone.localstorageenabled: raise self.skipTest("The setup doesn't have local storage enabled") scope = first_value ostype = second_value diff --git a/test/integration/component/test_interop_xd_ccp.py b/test/integration/component/test_interop_xd_ccp.py index ae5a9ae9ae7..dc579336590 100644 --- a/test/integration/component/test_interop_xd_ccp.py +++ b/test/integration/component/test_interop_xd_ccp.py @@ -571,7 +571,7 @@ class TestXDCCPInterop(cloudstackTestCase): id=self.volume.id ) - if list_volume_response1[0].virtualmachineid is None: + if list_volume_response1[0].virtualmachineid is None: self.skipTest("Check if volume is attached to the VM before detach") self.virtual_machine.detach_volume(self.user_api_client, self.volume) @@ -618,7 +618,7 @@ class TestXDCCPInterop(cloudstackTestCase): id=self.volume.id ) - if list_volume_response1[0].virtualmachineid is not None: + if list_volume_response1[0].virtualmachineid is not None: self.skipTest("Check if volume is detached before deleting") cmd = deleteVolume.deleteVolumeCmd() diff --git a/test/integration/component/test_rootvolume_resize.py b/test/integration/component/test_rootvolume_resize.py index 7e58d1e3f42..fa2d4a018cd 100644 --- a/test/integration/component/test_rootvolume_resize.py +++ b/test/integration/component/test_rootvolume_resize.py @@ -647,7 +647,7 @@ class TestResizeVolume(cloudstackTestCase): self.assertEqual(virtualmachine_snapshot.id, virtulmachine_snapshot_list[0].id, "Virtual Machine Snapshot id do not match") - except Exception as e: + except Exception as e: raise Exception("Issue CLOUDSTACK-10080: Exception while performing" " vmsnapshot: %s" % e) else: diff --git a/test/integration/smoke/test_kubernetes_clusters.py b/test/integration/smoke/test_kubernetes_clusters.py index 488e5efd625..20f1cb3224a 100644 --- a/test/integration/smoke/test_kubernetes_clusters.py +++ b/test/integration/smoke/test_kubernetes_clusters.py @@ -766,7 +766,7 @@ class TestKubernetesCluster(cloudstackTestCase): self.verifyKubernetesCluster(cluster, cluster.name, None, size, control_nodes) self.debug("Existing Kubernetes cluster available with name %s" % cluster.name) return cluster - except AssertionError as error: + except AssertionError as error: self.debug("Existing cluster failed verification due to %s, need to deploy a new one" % error) self.deleteKubernetesClusterAndVerify(cluster.id, False, True) diff --git a/test/integration/smoke/test_privategw_acl.py b/test/integration/smoke/test_privategw_acl.py index 06a6241d199..b0553241dc2 100644 --- a/test/integration/smoke/test_privategw_acl.py +++ b/test/integration/smoke/test_privategw_acl.py @@ -920,6 +920,6 @@ class TestPrivateGwACL(cloudstackTestCase): (select id from physical_network where uuid='%s');" % physical_network.id ) for traffic_type in traffic_type_list: - if "Guest" in str(traffic_type[0]): + if "Guest" in str(traffic_type[0]): return physical_network return None diff --git a/test/integration/smoke/test_privategw_acl_ovs_gre.py b/test/integration/smoke/test_privategw_acl_ovs_gre.py index 94e5c3c839a..89e20af914e 100644 --- a/test/integration/smoke/test_privategw_acl_ovs_gre.py +++ b/test/integration/smoke/test_privategw_acl_ovs_gre.py @@ -683,7 +683,7 @@ class TestPrivateGwACLOvsGRE(cloudstackTestCase): (select id from physical_network where uuid='%s');" % physical_network.id ) for traffic_type in traffic_type_list: - if "Guest" in str(traffic_type[0]): + if "Guest" in str(traffic_type[0]): return physical_network return None diff --git a/tools/marvin/marvin/cloudstackException.py b/tools/marvin/marvin/cloudstackException.py index 5a2f72d8c59..477a61829fb 100644 --- a/tools/marvin/marvin/cloudstackException.py +++ b/tools/marvin/marvin/cloudstackException.py @@ -88,7 +88,7 @@ class CloudstackAclException(): @staticmethod def verifyErrorCodeinException(e,errorCode): errorString = " errorCode: " + errorCode - if errorString in str(e): + if errorString in str(e): return True else: return False diff --git a/tools/marvin/marvin/dbConnection.py b/tools/marvin/marvin/dbConnection.py index 04140bab3c2..eb48e5852ed 100644 --- a/tools/marvin/marvin/dbConnection.py +++ b/tools/marvin/marvin/dbConnection.py @@ -47,7 +47,7 @@ class DbConnection(object): with contextlib.closing(conn.cursor(buffered=True)) as cursor: cursor.execute(sql, params) try: - if sql.lower().startswith('select') and cursor.rowcount > 0: + if sql.lower().startswith('select') and cursor.rowcount > 0: # we have more than just the row count/success resultRow = cursor.fetchall() except errors.InterfaceError: diff --git a/tools/marvin/marvin/lib/ncc.py b/tools/marvin/marvin/lib/ncc.py index 3fbffe0ae2c..09ef26ea713 100755 --- a/tools/marvin/marvin/lib/ncc.py +++ b/tools/marvin/marvin/lib/ncc.py @@ -93,7 +93,7 @@ class NCC: elif isolation_policy.lower() == "dedicated": srv_pkg = self.createServicePackageDedicated(name, tnt_group_id, dv_group_id, isolation_policy ) else: - raise Exception("NS device must be either in shared or dedicated mode") + raise Exception("NS device must be either in shared or dedicated mode") if srv_pkg.status_code != 201: raise Exception("Error: %s" % self.__lastError) dev_add_res =self.addDevicetoServicePackage(dv_group_id, device_ip)