Skip to content

Commit

Permalink
fix flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Oct 13, 2022
1 parent 1129b74 commit dffdd96
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion IM/VirtualMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ def get_ctxt_output(self, remote_dir, ssh, delete=False):
# And process it
self.process_ctxt_agent_out(ctxt_agent_out)
msg = "Contextualization agent output processed successfully"
except IOError as ex:
except IOError:
msg = "Error getting contextualization agent output " + \
remote_dir + "/ctxt_agent.out: No such file."
self.log_error(msg)
Expand Down
3 changes: 2 additions & 1 deletion IM/connectors/Azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
except Exception as ex:
AZURE_IDENTITY_AVAILABLE = False
print("WARN: Python azure-identity not installed. AzureCloudConnector may not work properly!.")
print(ex)


class AzureInstanceTypeInfo:
Expand Down Expand Up @@ -888,7 +889,7 @@ def launch(self, inf, radl, requested_radl, num_vm, auth_data):
deleted, msg = self.delete_resource_group(inf, rg_name, resource_client, max_retries=1)
if not deleted:
self.log_warn("Error removing errored RG %s: %s" % (rg_name, msg))
except Exception as ex:
except Exception:
self.log_exception("Error removing errored RG: %s" % rg_name)

if remaining_vms == 0:
Expand Down
1 change: 0 additions & 1 deletion IM/connectors/CloudConnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from IM.config import Config
from IM.LoggerMixin import LoggerMixin
from netaddr import IPNetwork, spanning_cidr
import IM.connectors


class CloudConnector(LoggerMixin):
Expand Down
4 changes: 2 additions & 2 deletions IM/connectors/Docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _generate_create_svc_request_data(self, image_name, outports, vm, ssh_port,
svc_data = {}
system = vm.info.systems[0]

cpu = int(system.getValue('cpu.count')) - 1
# cpu = int(system.getValue('cpu.count')) - 1
memory = int(system.getFeature('memory.size').getValue('B'))
name = system.getValue("disk.0.image.name")
if not name:
Expand Down Expand Up @@ -241,7 +241,7 @@ def _generate_create_cont_request_data(self, image_name, outports, vm, ssh_port)
cont_data = {}
system = vm.info.systems[0]

cpu = int(system.getValue('cpu.count')) - 1
# cpu = int(system.getValue('cpu.count')) - 1
memory = system.getFeature('memory.size').getValue('B')
# name = system.getValue("disk.0.image.name")

Expand Down
2 changes: 1 addition & 1 deletion IM/connectors/OCCI.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def get_floating_pool(occi_data):
pools = []
for line in lines:
if 'http://schemas.openstack.org/network/floatingippool#' in line:
for elem in l.split(';'):
for elem in line.split(';'):
if elem.startswith('Category: '):
pools.append(elem[10:])
if pools:
Expand Down
4 changes: 2 additions & 2 deletions IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1600,15 +1600,15 @@ def finalize(self, vm, last, auth_data):
self.log_debug("Dettaching volume %s." % vol_id)
volume = node.driver.ex_get_volume(vol_id)
node.driver.detach_volume(volume)
except Exception as ex:
except Exception:
self.log_exception("Error dettaching volume %s." % vol_id)

for sg_name in self._get_security_names(vm.inf):
try:
self.log_debug("Dettaching SG %s." % sg_name)
security_group = OpenStackSecurityGroup(None, None, sg_name, "", node.driver)
node.driver.ex_remove_security_group_from_node(security_group, node)
except Exception as ex:
except Exception:
self.log_exception("Error dettaching SG %s." % sg_name)

res = node.destroy()
Expand Down
1 change: 0 additions & 1 deletion IM/connectors/vSphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import time
from netaddr import IPNetwork, IPAddress

try:
Expand Down
2 changes: 1 addition & 1 deletion IM/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def _execute_retry(self, sql, args, fetch=False):
self.connect()
else:
raise ex
except sqlite.IntegrityError as ex:
except sqlite.IntegrityError:
raise IntegrityError()

def execute(self, sql, args=None):
Expand Down
2 changes: 1 addition & 1 deletion IM/tosca/Tosca.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ def _gen_configure_from_interfaces(self, node, compute, interfaces):
script_content = resp.text
if resp.status_code != 200:
raise Exception(resp.reason + "\n" + resp.text)
except Exception as ex:
except Exception:
raise Exception("Implementation file: '%s' is not located in the artifacts folder '%s' "
"or in the artifacts remote url '%s'." % (implementation,
Tosca.ARTIFACTS_PATH,
Expand Down
4 changes: 2 additions & 2 deletions test/loadtest/LoadTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ def test_23_removeresource(self):

def print_response_times(self):
total = 0.0
for time in self.response_times:
total += time
for rtime in self.response_times:
total += rtime
print("Mean Time: %.4f" % (total / len(self.response_times)))

def test_50_destroy(self):
Expand Down
4 changes: 2 additions & 2 deletions test/loadtest/LoadTestR.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def getstate(self, inf_id):

def print_response_times(self):
total = 0.0
for time in self.response_times:
total += time
for rtime in self.response_times:
total += rtime
print("Mean Time: %.4f" % (total / len(self.response_times)))


Expand Down
4 changes: 2 additions & 2 deletions test/loadtest/LoadTestREST.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ def test_95_destroy(self):

def print_response_times(self):
total = 0.0
for time in self.response_times:
total += time
for rtime in self.response_times:
total += rtime
print("Mean Time: %.4f" % (total / len(self.response_times)))


Expand Down
8 changes: 4 additions & 4 deletions test/loadtest/LoadTestRESTR.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ def getstate(self, inf_id):
self.assertEqual(
resp.status_code, 200, msg="ERROR getting the infrastructure state:" + resp.text)
res = json.loads(resp.text)
state = res['state']['state']
vm_states = res['state']['vm_states']
# state = res['state']['state']
# vm_states = res['state']['vm_states']

def print_response_times(self):
total = 0.0
for time in self.response_times:
total += time
for rtime in self.response_times:
total += rtime
print("Mean Time: %.4f" % (total / len(self.response_times)))


Expand Down
2 changes: 1 addition & 1 deletion test/unit/connectors/Fogbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_response(self, method, url, verify, headers={}, data=None):
resp = MagicMock()
parts = urlparse(url)
url = parts[2]
params = parts[4]
# params = parts[4]

if method not in self.call_count:
self.call_count[method] = {}
Expand Down
1 change: 0 additions & 1 deletion test/unit/connectors/Kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from IM.auth import Authentication
from radl import radl_parse
from IM.VirtualMachine import VirtualMachine
from IM.InfrastructureInfo import InfrastructureInfo
from IM.connectors.Kubernetes import KubernetesCloudConnector
try:
from urlparse import urlparse
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ commands = bash -c "nosetests -v test/unit/*.py test/unit/connectors/*.py -v --s
commands = bandit IM -r -f html -o bandit.html -s B108,B601,B104 --severity-level medium

[flake8]
ignore = E402,E265
ignore = E402,E265,W605,W504,F811
max-line-length = 120
exclude = doc,scripts

0 comments on commit dffdd96

Please sign in to comment.