code cleanup: Fix warnings according to pylint
PATCH 2/2 code cleanup: Fix warnings according to pylint
* use of possibly unitialized values
* redefining built-in functions
* unused block of code
--- fence/agents/ibmblade/fence_ibmblade.py | 2 -- fence/agents/lib/fencing_snmp.py.py | 10 +++++----- fence/agents/vmware_soap/fence_vmware_soap.py | 1 - fence/agents/wti/fence_wti.py | 5 +++++ fence/agents/xenapi/fence_xenapi.py | 4 ---- 5 files changed, 10 insertions(+), 12 deletions(-)
fence/agents/ibmblade/fence_ibmblade.py +0 -2
@@ -50,8 +50,6 @@ def get_outlets_status(conn, options): # Main agent method def main(): - global port_oid - device_opt = [ "ipaddr", "login", "passwd", "passwd_script", "test", "port", "separator", "no_login", "no_password", "snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
fence/agents/lib/fencing_snmp.py.py +5 -5
@@ -26,8 +26,8 @@ class FencingSnmp: if self.options["log"] >= LOG_MODE_VERBOSE: self.options["debug_fh"].write(message+"\n") - def quote_for_run(self, str): - return ''.join(map(lambda x:x==r"'" and "'\\''" or x, str)) + def quote_for_run(self, string): + return ''.join(map(lambda x:x==r"'" and "'\\''" or x, string)) def complete_missed_params(self): mapping = [
@@ -112,14 +112,14 @@ class FencingSnmp: def set(self, oid, value, additional_timemout=0): mapping = ((int, 'i'), (str, 's')) - type = '' + type_of_value = '' for item in mapping: if (isinstance(value, item[0])): - type = item[1] + type_of_value = item[1] break - cmd = "%s '%s' %s '%s'"% (self.prepare_cmd("snmpset"), self.quote_for_run(oid), type, self.quote_for_run(str(value))) + cmd = "%s '%s' %s '%s'"% (self.prepare_cmd("snmpset"), self.quote_for_run(oid), type_of_value, self.quote_for_run(str(value))) self.run_command(cmd, additional_timemout)
fence/agents/vmware_soap/fence_vmware_soap.py +0 -1
@@ -139,7 +139,6 @@ def get_power_status(conn, options): return "on" else: return "off" - return status except KeyError, ex: fail(EC_STATUS)
fence/agents/wti/fence_wti.py +5 -0
@@ -47,7 +47,12 @@ def get_power_status(conn, options): fail(EC_TIMED_OUT) plug_section = 0 + plug_index = -1 + name_index = -1 + status_index = -1 + plug_header = list() outlets = {} + for line in listing.splitlines(): if (plug_section == 2) and line.find("|") >= 0 and line.startswith("PLUG") == False: plug_line = [x.strip().lower() for x in line.split("|")]
fence/agents/xenapi/fence_xenapi.py +0 -4
@@ -78,10 +78,6 @@ def get_power_fn(session, options): # Set the state of the port given in the -U flag of options. def set_power_fn(session, options): action = options["-o"].lower() - if options.has_key("-v"): - verbose = True - else: - verbose = False try: # Get a reference to the vm specified in the UUID or vm_name/port parameter
Signature · 1 line
1.7.7.6
PATCH 2/2 code cleanup: Fix warnings according to pylint
Marx,
as with previous patch, just a simple check (in fact, indicated by git apply):
Quoted 5 lines · Marek 'marx' Grac
fence/agents/wti/fence_wti.py +0
-0
fence/agents/wti/fence_wti.py def get_power_status(conn, options): · line 55
Quoted 9 lines
fence/agents/wti/fence_wti.py +5
-0@@ -47,7 +47,12 @@ def get_power_status(conn, options): fail(EC_TIMED_OUT) plug_section = 0 + plug_index = -1 + name_index = -1 + status_index = -1 + plug_header = list() outlets = {} +
last line contains trailing whitespace
Signature · 1 line
Jan