fence-agents: master - [cleanup] Remove warning logging-not-lazy

Marek GrĂ¡c marx at fedoraproject.org
Wed Apr 23 15:50:37 UTC 2014


Gitweb:        http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=c84df1578d288fb23e2cd72e1704f7c4234b7fd4
Commit:        c84df1578d288fb23e2cd72e1704f7c4234b7fd4
Parent:        364de00cdd7619ad65f5eabdab2d8499d448045d
Author:        Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate:    Wed Apr 16 17:18:04 2014 +0200
Committer:     Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Wed Apr 23 17:38:41 2014 +0200

[cleanup] Remove warning logging-not-lazy

---
 fence/agents/cisco_ucs/fence_cisco_ucs.py |    4 +-
 fence/agents/dummy/fence_dummy.py         |    2 +-
 fence/agents/eps/fence_eps.py             |    8 +++---
 fence/agents/lib/XenAPI.py.py             |    2 +-
 fence/agents/lib/fencing.py.py            |   30 ++++++++++++++--------------
 fence/agents/lib/fencing_snmp.py.py       |    2 +-
 fence/agents/ovh/fence_ovh.py             |    8 +++---
 fence/agents/rhevm/fence_rhevm.py         |    4 +-
 fence/agents/vmware/fence_vmware.py       |    6 ++--
 9 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index 0a4bff7..afe2c0d 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -96,8 +96,8 @@ def send_command(opt, command, timeout):
 	conn.perform()
 	result = web_buffer.getvalue()
 
-	logging.debug("%s\n" % command)
-	logging.debug("%s\n" % result)
+	logging.debug("%s\n", command)
+	logging.debug("%s\n", result)
 
 	return result
 
diff --git a/fence/agents/dummy/fence_dummy.py b/fence/agents/dummy/fence_dummy.py
index 9f0e950..f460746 100644
--- a/fence/agents/dummy/fence_dummy.py
+++ b/fence/agents/dummy/fence_dummy.py
@@ -128,7 +128,7 @@ def main():
 	if options.has_key("--random_sleep_range"):
 		val = int(options["--random_sleep_range"])
 		ran = random.randint(1, val)
-		logging.info("Random sleep for %d seconds\n" % ran)
+		logging.info("Random sleep for %d seconds\n", ran)
 		time.sleep(ran)
 
 	if options["--type"] == "fail":
diff --git a/fence/agents/eps/fence_eps.py b/fence/agents/eps/fence_eps.py
index 68a0991..740a9e5 100644
--- a/fence/agents/eps/fence_eps.py
+++ b/fence/agents/eps/fence_eps.py
@@ -30,7 +30,7 @@ def eps_run_command(options, params):
 		if params != "":
 			request_str += "?"+params
 
-		logging.debug("GET %s\n" % request_str)
+		logging.debug("GET %s\n", request_str)
 		conn.putrequest('GET', request_str)
 
 		if options.has_key("--username"):
@@ -39,21 +39,21 @@ def eps_run_command(options, params):
 
 			# String for Authorization header
 			auth_str = 'Basic ' + string.strip(base64.encodestring(options["--username"]+':'+options["--password"]))
-			logging.debug("Authorization: %s\n" % auth_str)
+			logging.debug("Authorization: %s\n", auth_str)
 			conn.putheader('Authorization', auth_str)
 
 		conn.endheaders()
 
 		response = conn.getresponse()
 
-		logging.debug("%d %s\n"%(response.status, response.reason))
+		logging.debug("%d %s\n", response.status, response.reason)
 
 		#Response != OK -> couldn't login
 		if response.status != 200:
 			fail(EC_LOGIN_DENIED)
 
 		result = response.read()
-		logging.debug("%s \n" % result)
+		logging.debug("%s \n", result)
 		conn.close()
 	except socket.timeout:
 		fail(EC_TIMED_OUT)
diff --git a/fence/agents/lib/XenAPI.py.py b/fence/agents/lib/XenAPI.py.py
index 9928bba..f9b7687 100644
--- a/fence/agents/lib/XenAPI.py.py
+++ b/fence/agents/lib/XenAPI.py.py
@@ -73,7 +73,7 @@ class Failure(Exception):
 			return "Message database broken: %s.\nXen-API failure: %s" % \
 				   (exn, str(self.details))
 		except Exception, exn:
-			logging.error("%s\n" % str(exn))
+			logging.error("%s\n", str(exn))
 			return "Xen-API failure: %s" % str(self.details)
 
 	def _details_map(self):
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 63c046d..b4ecea7 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -382,17 +382,17 @@ DEPENDENCY_OPT = {
 
 class fspawn(pexpect.spawn):
 	def __init__(self, options, command):
-		logging.info("Running command: %s" % command)
+		logging.info("Running command: %s", command)
 		pexpect.spawn.__init__(self, command)
 		self.opt = options
 
 	def log_expect(self, options, pattern, timeout):
 		result = self.expect(pattern, timeout)
-		logging.debug("Received: %s" % (self.before + self.after))
+		logging.debug("Received: %s", self.before + self.after)
 		return result
 
 	def send(self, message):
-		logging.debug("Sent: %s" % message)
+		logging.debug("Sent: %s", message)
 		return pexpect.spawn.send(self, message)
 
 	# send EOL according to what was detected in login process (telnet)
@@ -404,7 +404,7 @@ def atexit_handler():
 		sys.stdout.close()
 		os.close(1)
 	except IOError:
-		logging.error("%s failed to close standard output\n" % (sys.argv[0]))
+		logging.error("%s failed to close standard output\n", sys.argv[0])
 		syslog.syslog(syslog.LOG_ERR, "Failed to close standard output")
 		sys.exit(EC_GENERIC_ERROR)
 
@@ -418,7 +418,7 @@ def add_dependency_options(options):
 
 def fail_usage(message = ""):
 	if len(message) > 0:
-		logging.error("%s\n" % message)
+		logging.error("%s\n", message)
 	logging.error("Please use '-h' for usage\n")
 	sys.exit(EC_GENERIC_ERROR)
 
@@ -435,7 +435,7 @@ def fail(error_code):
 		EC_PASSWORD_MISSING : "Failed: You have to set login password",
 		EC_INVALID_PRIVILEGES : "Failed: The user does not have the correct privileges to do the requested action."
 	}[error_code] + "\n"
-	logging.error("%s\n" % message)
+	logging.error("%s\n", message)
 	syslog.syslog(syslog.LOG_ERR, message)
 	sys.exit(EC_GENERIC_ERROR)
 
@@ -603,8 +603,8 @@ def process_input(avail_opt):
 			value = value[:-1]
 
 			if avail_opt.count(name) == 0:
-				logging.warning("Parse error: Ignoring unknown option '%s'\n" % line)
-				syslog.syslog(syslog.LOG_WARNING, "Parse error: Ignoring unknown option '"+line)
+				logging.warning("Parse error: Ignoring unknown option '%s'\n", line)
+				syslog.syslog(syslog.LOG_WARNING, "Parse error: Ignoring unknown option '" + line)
 				continue
 
 			if all_opt[name]["getopt"].endswith(":"):
@@ -741,7 +741,7 @@ def check_input(device_opt, opt):
 			fh.setLevel(logging.DEBUG)
 			logging.getLogger().addHandler(fh)
 		except IOError:
-			logging.error("Unable to create file %s" % options["--debug-file"])
+			logging.error("Unable to create file %s", options["--debug-file"])
 			fail_usage("Failed: Unable to create file " + options["--debug-file"])
 
 	if options.has_key("--snmp-priv-passwd-script"):
@@ -932,7 +932,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 				except Exception, ex:
 					# an error occured during power ON phase in reboot
 					# fence action was completed succesfully even in that case
-					logging.error("%s\n", str(ex))
+					logging.error("%s", str(ex))
 					syslog.syslog(syslog.LOG_NOTICE, str(ex))
 
 			if power_on == False:
@@ -952,7 +952,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 	except pexpect.TIMEOUT:
 		fail(EC_TIMED_OUT)
 	except pycurl.error, ex:
-		logging.error("%s\n" % str(ex))
+		logging.error("%s\n", str(ex))
 		syslog.syslog(syslog.LOG_ERR, ex[1])
 		fail(EC_TIMED_OUT)
 
@@ -976,7 +976,7 @@ def fence_login(options, re_login_string = r"(login\s*: )|(Login Name:  )|(usern
 	## Do the delay of the fence device before logging in
 	## Delay is important for two-node clusters fencing but we do not need to delay 'status' operations
 	if options["--action"] in ["off", "reboot"]:
-		logging.info("Delay %s second(s) before logging in to the fence device" % options["--delay"])
+		logging.info("Delay %s second(s) before logging in to the fence device", options["--delay"])
 		time.sleep(int(options["--delay"]))
 
 	try:
@@ -993,7 +993,7 @@ def fence_login(options, re_login_string = r"(login\s*: )|(Login Name:  )|(usern
 			try:
 				conn = fspawn(options, command)
 			except pexpect.ExceptionPexpect, ex:
-				logging.error("%s\n" % str(ex))
+				logging.error("%s\n", str(ex))
 				syslog.syslog(syslog.LOG_ERR, str(ex))
 				sys.exit(EC_GENERIC_ERROR)
 		elif options.has_key("--ssh") and 0 == options.has_key("--identity-file"):
@@ -1103,7 +1103,7 @@ def run_command(options, command, timeout = None, env = None):
 	if timeout is not None:
 		timeout = float(timeout)
 
-	logging.info("Executing: %s\n" % command)
+	logging.info("Executing: %s\n", command)
 
 	try:
 		process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
@@ -1123,6 +1123,6 @@ def run_command(options, command, timeout = None, env = None):
 	process.stdout.close()
 	process.stderr.close()
 
-	logging.debug("%s %s %s\n" % (str(status), str(pipe_stdout), str(pipe_stderr)))
+	logging.debug("%s %s %s\n", str(status), str(pipe_stdout), str(pipe_stderr))
 
 	return (status, pipe_stdout, pipe_stderr)
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index 24ad171..997e2da 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -22,7 +22,7 @@ class FencingSnmp:
 
 	# Log message if user set verbose option
 	def log_command(self, message):
-		logging.debug("%s\n" % message)
+		logging.debug("%s\n", message)
 
 	def quote_for_run(self, string):
 		return string.replace(r"'", "'\\''")
diff --git a/fence/agents/ovh/fence_ovh.py b/fence/agents/ovh/fence_ovh.py
index f4e9caf..0f460df 100644
--- a/fence/agents/ovh/fence_ovh.py
+++ b/fence/agents/ovh/fence_ovh.py
@@ -126,13 +126,13 @@ Poweroff is simulated with a reboot into rescue-pro mode."
 	# Verify that action was completed sucesfully
 	reboot_t = reboot_time(options)
 
-	logging.debug("reboot_start_end.start: %s\n" %
+	logging.debug("reboot_start_end.start: %s\n",
 		reboot_t.start.strftime('%Y-%m-%d %H:%M:%S'))
-	logging.debug("before_netboot_reboot: %s\n" %
+	logging.debug("before_netboot_reboot: %s\n",
 		before_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S'))
-	logging.debug("reboot_start_end.end: %s\n" %
+	logging.debug("reboot_start_end.end: %s\n",
 		reboot_t.end.strftime('%Y-%m-%d %H:%M:%S'))
-	logging.debug("after_netboot_reboot: %s\n" %
+	logging.debug("after_netboot_reboot: %s\n",
 		after_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S'))
 
 	if reboot_t.start < after_netboot_reboot < reboot_t.end:
diff --git a/fence/agents/rhevm/fence_rhevm.py b/fence/agents/rhevm/fence_rhevm.py
index 8ff5ee9..cd75c3b 100644
--- a/fence/agents/rhevm/fence_rhevm.py
+++ b/fence/agents/rhevm/fence_rhevm.py
@@ -101,8 +101,8 @@ def send_command(opt, command, method = "GET"):
 	conn.perform()
 	result = web_buffer.getvalue()
 
-	logging.debug("%s\n" % command)
-	logging.debug("%s\n" % result)
+	logging.debug("%s\n", command)
+	logging.debug("%s\n", result)
 
 	return result
 
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
index 00e7632..63e809a 100644
--- a/fence/agents/vmware/fence_vmware.py
+++ b/fence/agents/vmware/fence_vmware.py
@@ -144,7 +144,7 @@ def vmware_run_command(options, add_login_params, additional_params, additional_
 	command = vmware_prepare_command(options, add_login_params, additional_params)
 
 	try:
-		logging.debug("%s\n" % command)
+		logging.debug("%s\n", command)
 
 		(res_output, res_code) = pexpect.run(command,
 				int(options["--shell-timeout"]) + int(options["--login-timeout"]) + additional_timeout, True)
@@ -152,10 +152,10 @@ def vmware_run_command(options, add_login_params, additional_params, additional_
 		if res_code == None:
 			fail(EC_TIMED_OUT)
 		if res_code != 0 and add_login_params:
-			logging.debug("%s\n" % res_output)
+			logging.debug("%s\n", res_output)
 			fail_usage("%s returned %s"% (options["--exec"], res_output))
 		else:
-			logging.debug("%s\n" % res_output)
+			logging.debug("%s\n", res_output)
 
 	except pexpect.ExceptionPexpect:
 		fail_usage("Cannot run command %s"% (options["--exec"]))


More information about the cluster-commits mailing list