[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH 08/15] [cleanup] Mark raw strings with r""



---
 fence/agents/alom/fence_alom.py               | 2 +-
 fence/agents/apc/fence_apc.py                 | 6 +++---
 fence/agents/bladecenter/fence_bladecenter.py | 6 +++---
 fence/agents/brocade/fence_brocade.py         | 2 +-
 fence/agents/cisco_mds/fence_cisco_mds.py     | 4 ++--
 fence/agents/drac/fence_drac.py               | 2 +-
 fence/agents/drac5/fence_drac5.py             | 8 ++++----
 fence/agents/eps/fence_eps.py                 | 2 +-
 fence/agents/hds_cb/fence_hds_cb.py           | 4 ++--
 fence/agents/hpblade/fence_hpblade.py         | 4 ++--
 fence/agents/ilo/fence_ilo.py                 | 6 +++---
 fence/agents/ldom/fence_ldom.py               | 6 +++---
 fence/agents/lib/check_used_options.py        | 8 ++++----
 fence/agents/lib/fencing.py.py                | 4 ++--
 fence/agents/lpar/fence_lpar.py               | 2 +-
 fence/agents/rsb/fence_rsb.py                 | 2 +-
 fence/agents/sanbox2/fence_sanbox2.py         | 6 +++---
 fence/agents/virsh/fence_virsh.py             | 2 +-
 fence/agents/vmware/fence_vmware.py           | 2 +-
 19 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py
index 2844904..2a72d7e 100644
--- a/fence/agents/alom/fence_alom.py
+++ b/fence/agents/alom/fence_alom.py
@@ -37,7 +37,7 @@ def main():
 	atexit.register(atexit_handler)
 
 	all_opt["secure"]["default"] = "1"
-	all_opt["cmd_prompt"]["default"] = [ "sc\>\ " ]
+	all_opt["cmd_prompt"]["default"] = [ r"sc\>\ " ]
 
 	options = check_input(device_opt, process_input(device_opt))
 	options["telnet_over_ssh"] = 1
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index 76b544b..3b17cd0 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -73,7 +73,7 @@ def get_power_status(conn, options):
 		exp_result = conn.log_expect(options,
 				["Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"]))
 		lines = conn.before.split("\n")
-		show_re = re.compile('(^|\x0D)\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
+		show_re = re.compile(r'(^|\x0D)\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
 		for x in lines:
 			res = show_re.search(x)
 			if (res != None):
@@ -185,7 +185,7 @@ def get_power_status5(conn, options):
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 	lines = conn.before.split("\n")
 
-	show_re = re.compile('^\s*(\d+): (.*): (On|Off)\s*$', re.IGNORECASE)
+	show_re = re.compile(r'^\s*(\d+): (.*): (On|Off)\s*$', re.IGNORECASE)
 
 	for x in lines:
 		res = show_re.search(x)
@@ -246,7 +246,7 @@ will block any necessary fencing actions."
 	## and continue with proper action
 	####
 	result = -1
-	firmware_version = re.compile('\s*v(\d)*\.').search(conn.before)
+	firmware_version = re.compile(r'\s*v(\d)*\.').search(conn.before)
 	if (firmware_version != None) and (firmware_version.group(1) == "5"):
 		result = fence_action(conn, options, set_power_status5, get_power_status5, get_power_status5)
 	else:
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 34a8975..3bb02fc 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -25,7 +25,7 @@ BUILD_DATE="March, 2008"
 #END_VERSION_GENERATION
 
 def get_power_status(conn, options):
-	node_cmd = "system:blade\[" + options["--plug"] + "\]>"
+	node_cmd = r"system:blade\[" + options["--plug"] + r"\]>"
 
 	conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
 	i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["--shell-timeout"]))
@@ -44,7 +44,7 @@ def get_power_status(conn, options):
 	return status.lower().strip()
 
 def set_power_status(conn, options):
-	node_cmd = "system:blade\[" + options["--plug"] + "\]>"
+	node_cmd = r"system:blade\[" + options["--plug"] + r"\]>"
 
 	conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
 	i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["--shell-timeout"]))
@@ -71,7 +71,7 @@ def get_blades_list(conn, options):
 	conn.log_expect(options, node_cmd, int(options["--shell-timeout"]))
 
 	lines = conn.before.split("\r\n")
-	filter_re = re.compile("^\s*blade\[(\d+)\]\s+(.*?)\s*$")
+	filter_re = re.compile(r"^\s*blade\[(\d+)\]\s+(.*?)\s*$")
 	for blade_line in lines:
 		res = filter_re.search(blade_line)
 		if res != None:
diff --git a/fence/agents/brocade/fence_brocade.py b/fence/agents/brocade/fence_brocade.py
index 2deab5b..c6b2bfc 100644
--- a/fence/agents/brocade/fence_brocade.py
+++ b/fence/agents/brocade/fence_brocade.py
@@ -17,7 +17,7 @@ def get_power_status(conn, options):
 
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-	show_re = re.compile('^\s*Persistent Disable\s*(ON|OFF)\s*$', re.IGNORECASE)
+	show_re = re.compile(r'^\s*Persistent Disable\s*(ON|OFF)\s*$', re.IGNORECASE)
 	lines = conn.before.split("\n")
 
 	for x in lines:
diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py b/fence/agents/cisco_mds/fence_cisco_mds.py
index 6af1e99..dc6c41b 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -37,7 +37,7 @@ PORT_OID = ""
 def cisco_port2oid(port):
 	port = port.lower()
 
-	nums = re.match('^fc(\d+)/(\d+)$', port)
+	nums = re.match(r'^fc(\d+)/(\d+)$', port)
 
 	if ((nums) and (len(nums.groups()))==2):
 		return "%s.%d.%d"% (PORT_ADMIN_STATUS_OID, int(nums.group(1))+21, int(nums.group(2))-1)
@@ -62,7 +62,7 @@ def get_outlets_status(conn, options):
 	res_fc = conn.walk(PORTS_OID, 30)
 	res_aliases = array_to_dict(conn.walk(ALIASES_OID, 30))
 
-	fc_re = re.compile('^"fc\d+/\d+"$')
+	fc_re = re.compile(r'^"fc\d+/\d+"$')
 
 	for x in res_fc:
 		if fc_re.match(x[1]):
diff --git a/fence/agents/drac/fence_drac.py b/fence/agents/drac/fence_drac.py
index ba08ee7..396f09e 100644
--- a/fence/agents/drac/fence_drac.py
+++ b/fence/agents/drac/fence_drac.py
@@ -14,7 +14,7 @@ BUILD_DATE=""
 def get_power_status(conn, options):
 	conn.send_eol("getmodinfo")
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
-	status = re.compile("\s+(on|off)\s+", re.IGNORECASE).search(conn.before).group(1)
+	status = re.compile(r"\s+(on|off)\s+", re.IGNORECASE).search(conn.before).group(1)
 	return (status.lower().strip())
 
 def set_power_status(conn, options):
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index 642dcda..cdf4f4f 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -35,7 +35,7 @@ def get_power_status(conn, options):
 
 		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-		status = re.compile("(^|: )(ON|OFF|Powering ON|Powering OFF)\s*$",
+		status = re.compile(r"(^|: )(ON|OFF|Powering ON|Powering OFF)\s*$",
 				re.IGNORECASE | re.MULTILINE).search(conn.before).group(2)
 
 	if status.lower().strip() in ["on", "powering on", "powering off"]:
@@ -70,7 +70,7 @@ def get_list_devices(conn, options):
 	if options["--drac-version"] == "DRAC CMC":
 		conn.send_eol("getmodinfo")
 
-		list_re = re.compile("^([^\s]*?)\s+Present\s*(ON|OFF)\s*.*$")
+		list_re = re.compile(r"^([^\s]*?)\s+Present\s*(ON|OFF)\s*.*$")
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 		for line in conn.before.splitlines():
 			if (list_re.search(line)):
@@ -78,7 +78,7 @@ def get_list_devices(conn, options):
 	elif options["--drac-version"] == "DRAC MC":
 		conn.send_eol("getmodinfo")
 
-		list_re = re.compile("^\s*([^\s]*)\s*---->\s*(.*?)\s+Present\s*(ON|OFF)\s*.*$")
+		list_re = re.compile(r"^\s*([^\s]*)\s*---->\s*(.*?)\s+Present\s*(ON|OFF)\s*.*$")
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 		for line in conn.before.splitlines():
 			if (list_re.search(line)):
@@ -110,7 +110,7 @@ def main():
 
 	define_new_opts()
 
-	all_opt["cmd_prompt"]["default"] = [ "\$", "DRAC\/MC:" ]
+	all_opt["cmd_prompt"]["default"] = [ r"\$", r"DRAC\/MC:" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/eps/fence_eps.py b/fence/agents/eps/fence_eps.py
index 3c4be8d..daffab4 100644
--- a/fence/agents/eps/fence_eps.py
+++ b/fence/agents/eps/fence_eps.py
@@ -71,7 +71,7 @@ def get_power_status(conn, options):
 	ret_val = eps_run_command(options,"")
 
 	result = {}
-	status = re.findall("p(\d{2})=(0|1)\s*\<br\>", ret_val.lower())
+	status = re.findall(r"p(\d{2})=(0|1)\s*\<br\>", ret_val.lower())
 	for out_num, out_stat in status:
 		result[out_num] = ("",(out_stat=="1" and "on" or "off"))
 
diff --git a/fence/agents/hds_cb/fence_hds_cb.py b/fence/agents/hds_cb/fence_hds_cb.py
index 78754fc..70ca185 100755
--- a/fence/agents/hds_cb/fence_hds_cb.py
+++ b/fence/agents/hds_cb/fence_hds_cb.py
@@ -21,7 +21,7 @@ REDHAT_COPYRIGHT=""
 BUILD_DATE="November, 2012"
 #END_VERSION_GENERATION
 
-RE_STATUS_LINE = "^([0-9]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+).*$"
+RE_STATUS_LINE = r"^([0-9]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+).*$"
 
 def get_power_status(conn, options):
 	#### Maybe should put a conn.log_expect here to make sure
@@ -113,7 +113,7 @@ def main():
 	atexit.register(atexit_handler)
 
 	all_opt["power_wait"]["default"] = "5"
-	all_opt["cmd_prompt"]["default"] = [ "\) :" ]
+	all_opt["cmd_prompt"]["default"] = [ r"\) :" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/hpblade/fence_hpblade.py b/fence/agents/hpblade/fence_hpblade.py
index 44032d3..6b883db 100644
--- a/fence/agents/hpblade/fence_hpblade.py
+++ b/fence/agents/hpblade/fence_hpblade.py
@@ -22,7 +22,7 @@ def get_power_status(conn, options):
 	conn.send_eol("show server status " + options["--plug"])
 	conn.log_expect(options, options["--command-prompt"] , int(options["--shell-timeout"]))
 
-	power_re = re.compile("^\s*Power: (.*?)\s*$")
+	power_re = re.compile(r"^\s*Power: (.*?)\s*$")
 	status = "unknown"
 	for line in conn.before.splitlines():
 		res = power_re.search(line)
@@ -50,7 +50,7 @@ def get_blades_list(conn, options):
 	conn.send_eol("show server list" )
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-	list_re = re.compile("^\s*(.*?)\s+(.*?)\s+(.*?)\s+OK\s+(.*?)\s+(.*?)\s*$")
+	list_re = re.compile(r"^\s*(.*?)\s+(.*?)\s+(.*?)\s+OK\s+(.*?)\s+(.*?)\s*$")
 	for line in conn.before.splitlines():
 		res = list_re.search(line)
 		if res != None:
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index 8171958..8719573 100644
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -109,11 +109,11 @@ the iLO card through an XML stream."
 		if options["--ribcl-version"] >= 2:
 			conn.send("<RIB_INFO MODE=\"read\"><GET_FW_VERSION />\r\n")
 			conn.send("</RIB_INFO>\r\n")
-			conn.log_expect(options, "<GET_FW_VERSION\s*\n", int(options["--shell-timeout"]))
+			conn.log_expect(options, r"<GET_FW_VERSION\s*\n", int(options["--shell-timeout"]))
 			conn.log_expect(options, "/>", int(options["--shell-timeout"]))
-			options["fw_version"] = float(re.compile("FIRMWARE_VERSION\s*=\s*\"(.*?)\"",
+			options["fw_version"] = float(re.compile(r"FIRMWARE_VERSION\s*=\s*\"(.*?)\"",
 					re.IGNORECASE).search(conn.before).group(1))
-			options["fw_processor"] = re.compile("MANAGEMENT_PROCESSOR\s*=\s*\"(.*?)\"",
+			options["fw_processor"] = re.compile(r"MANAGEMENT_PROCESSOR\s*=\s*\"(.*?)\"",
 					re.IGNORECASE).search(conn.before).group(1)
 		conn.send("</LOGIN>\r\n")
 	except pexpect.TIMEOUT:
diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py
index ffa8fe4..7545eed 100644
--- a/fence/agents/ldom/fence_ldom.py
+++ b/fence/agents/ldom/fence_ldom.py
@@ -19,7 +19,7 @@ REDHAT_COPYRIGHT=""
 BUILD_DATE=""
 #END_VERSION_GENERATION
 
-COMMAND_PROMPT_REG = "\[PEXPECT\]$"
+COMMAND_PROMPT_REG = r"\[PEXPECT\]$"
 COMMAND_PROMPT_NEW = "[PEXPECT]"
 
 # Start comunicating after login. Prepare good environment.
@@ -44,7 +44,7 @@ def get_power_status(conn, options):
 	fa_status = 0
 
 	for line in conn.before.splitlines():
-		domain = re.search("^(\S+)\s+(\S+)\s+.*$", line)
+		domain = re.search(r"^(\S+)\s+(\S+)\s+.*$", line)
 
 		if (domain!=None):
 			if ((fa_status==0) and (domain.group(1)=="NAME") and (domain.group(2)=="STATE")):
@@ -75,7 +75,7 @@ def main():
 	atexit.register(atexit_handler)
 
 	all_opt["secure"]["default"] = "1"
-	all_opt["cmd_prompt"]["default"] = [ "\ $" ]
+	all_opt["cmd_prompt"]["default"] = [ r"\ $" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/lib/check_used_options.py b/fence/agents/lib/check_used_options.py
index 2d2abbc..92a2ae6 100755
--- a/fence/agents/lib/check_used_options.py
+++ b/fence/agents/lib/check_used_options.py
@@ -25,8 +25,8 @@ def main():
 
 	## all_opt defined in fence agent are found
 	agent_file = open(agent)
-	opt_re = re.compile("\s*all_opt\[\"([^\"]*)\"\] = {")
-	opt_longopt_re = re.compile("\s*\"longopt\" : \"([^\"]*)\"")
+	opt_re = re.compile(r"\s*all_opt\[\"([^\"]*)\"\] = {")
+	opt_longopt_re = re.compile(r"\s*\"longopt\" : \"([^\"]*)\"")
 
 	in_opt = False
 	for line in agent_file:
@@ -38,8 +38,8 @@ def main():
 
 	## check if all options are defined
 	agent_file = open(agent)
-	option_use_re = re.compile("options\[\"(-[^\"]*)\"\]")
-	option_has_re = re.compile("options.has_key\(\"(-[^\"]*)\"\)")
+	option_use_re = re.compile(r"options\[\"(-[^\"]*)\"\]")
+	option_has_re = re.compile(r"options.has_key\(\"(-[^\"]*)\"\)")
 
 	counter = 0
 	without_errors = True
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 40ee919..47d6e83 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -489,7 +489,7 @@ def metadata(avail_opt, options, docs):
 
 			mixed = all_opt[option]["help"]
 			## split it between option and help text
-			res = re.compile("^(.*--\S+)\s+", re.IGNORECASE | re.S).search(mixed)
+			res = re.compile(r"^(.*--\S+)\s+", re.IGNORECASE | re.S).search(mixed)
 			if (None != res):
 				mixed = res.group(1)
 			mixed = mixed.replace("<", "&lt;").replace(">", "&gt;")
@@ -950,7 +950,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 
 	return result
 
-def fence_login(options, re_login_string = "(login\s*: )|(Login Name:  )|(username: )|(User Name :)"):
+def fence_login(options, re_login_string = r"(login\s*: )|(Login Name:  )|(username: )|(User Name :)"):
 	force_ipvx = ""
 
 	if (options.has_key("--inet6-only")):
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 4278650..630b2ca 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -131,7 +131,7 @@ def main():
 
 	all_opt["login_timeout"]["default"] = "15"
 	all_opt["secure"]["default"] = "1"
-	all_opt["cmd_prompt"]["default"] = [ ":~>", "]\$", "\$ " ]
+	all_opt["cmd_prompt"]["default"] = [ r":~>", r"]\$", r"\$ " ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/rsb/fence_rsb.py b/fence/agents/rsb/fence_rsb.py
index 89fb304..af3a2e4 100755
--- a/fence/agents/rsb/fence_rsb.py
+++ b/fence/agents/rsb/fence_rsb.py
@@ -14,7 +14,7 @@ BUILD_DATE=""
 def get_power_status(conn, options):
 	conn.send("2")
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
-	status = re.compile("Power Status[\s]*: (on|off)", re.IGNORECASE).search(conn.before).group(1)
+	status = re.compile(r"Power Status[\s]*: (on|off)", re.IGNORECASE).search(conn.before).group(1)
 	conn.send("0")
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
diff --git a/fence/agents/sanbox2/fence_sanbox2.py b/fence/agents/sanbox2/fence_sanbox2.py
index a9d7c76..0dfab37 100644
--- a/fence/agents/sanbox2/fence_sanbox2.py
+++ b/fence/agents/sanbox2/fence_sanbox2.py
@@ -37,7 +37,7 @@ def get_power_status(conn, options):
 			pass
 		fail(EC_TIMED_OUT)
 
-	status = re.compile(".*AdminState\s+(online|offline)\s+",
+	status = re.compile(r".*AdminState\s+(online|offline)\s+",
 			re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
 
 	try:
@@ -82,7 +82,7 @@ def get_list_devices(conn, options):
 		conn.send_eol("show port")
 		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-		list_re = re.compile("^\s+(\d+?)\s+(Online|Offline)\s+", re.IGNORECASE)
+		list_re = re.compile(r"^\s+(\d+?)\s+(Online|Offline)\s+", re.IGNORECASE)
 		for line in conn.before.splitlines():
 			if (list_re.search(line)):
 				status = {
@@ -129,7 +129,7 @@ because the connection will block any necessary fencing actions."
 	conn.send_eol("admin start")
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-	if (re.search("\(admin\)", conn.before, re.MULTILINE) == None):
+	if (re.search(r"\(admin\)", conn.before, re.MULTILINE) == None):
 		## Someone else is in admin section, we can't enable/disable
 		## ports so we will rather exit
 		sys.stderr.write("Failed: Unable to switch to admin section\n")
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index fa6993e..f03ea74 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -36,7 +36,7 @@ def get_outlets_status(conn, options):
 	fa_status = 0
 
 	for line in conn.before.splitlines():
-		domain = re.search("^\s*(\S+)\s+(\S+)\s+(\S+).*$", line)
+		domain = re.search(r"^\s*(\S+)\s+(\S+)\s+(\S+).*$", line)
 
 		if (domain!=None):
 			if ((fa_status==0) and (domain.group(1).lower()=="id") and (domain.group(2).lower()=="name")):
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
index 9f19cb9..42ac505 100644
--- a/fence/agents/vmware/fence_vmware.py
+++ b/fence/agents/vmware/fence_vmware.py
@@ -248,7 +248,7 @@ def set_power_status(conn, options):
 # Returns True, if user uses supported vmrun version (currently >=2.0.0) otherwise False.
 def vmware_is_supported_vmrun_version(options):
 	vmware_help_str = vmware_run_command(options, False, "", 0)
-	version_re = re.search("vmrun version (\d\.(\d[\.]*)*)", vmware_help_str.lower())
+	version_re = re.search(r"vmrun version (\d\.(\d[\.]*)*)", vmware_help_str.lower())
 	if (version_re==None):
 		return False   # Looks like this "vmrun" is not real vmrun
 
-- 
1.9.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]