File 0001-lib-all-agents-use-r-for-all-regular-expressions-to-.patch of Package fence-agents.34832

From 55c7c987bd5e377db9bcaeb9a4f487397c12a128 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Wed, 20 Mar 2024 12:21:48 +0100
Subject: [PATCH 1/1] lib/all agents: use r"" for all regular expressions to
 avoid SyntaxWarning errors

---
 agents/azure_arm/fence_azure_arm.py |  2 +-
 lib/azure_fence.py.py               |  2 +-

diff --git a/agents/azure_arm/fence_azure_arm.py b/agents/azure_arm/fence_azure_arm.py
index 0dca8f30..227a7c2e 100755
--- a/agents/azure_arm/fence_azure_arm.py
+++ b/agents/azure_arm/fence_azure_arm.py
@@ -251,7 +251,7 @@ When using network fencing the reboot-action will cause a quick-return once the
     except ImportError:
         fail_usage("Azure Resource Manager Python SDK not found or not accessible")
     except Exception as e:
-        fail_usage("Failed: %s" % re.sub("^, ", "", str(e)))
+        fail_usage("Failed: %s" % re.sub(r"^, ", r"", str(e)))
 
     if "--network-fencing" in options:
         # use  off-action to quickly return off once network is fenced instead of
diff --git a/lib/azure_fence.py.py b/lib/azure_fence.py.py
index ab40b483..fcbc40ab 100644
--- a/lib/azure_fence.py.py
+++ b/lib/azure_fence.py.py
@@ -49,7 +49,7 @@ def get_from_metadata(parameter):
     return None
 
 def get_azure_resource(id):
-    match = re.match('(/subscriptions/([^/]*)/resourceGroups/([^/]*))(/providers/([^/]*/[^/]*)/([^/]*))?((/([^/]*)/([^/]*))*)', id)
+    match = re.match(r'(/subscriptions/([^/]*)/resourceGroups/([^/]*))(/providers/([^/]*/[^/]*)/([^/]*))?((/([^/]*)/([^/]*))*)', id)
     if not match:
         fail_usage("{get_azure_resource} cannot parse resource id %s" % id)
 
diff --git a/lib/fencing.py.py b/lib/fencing.py.py
index 3a60f53e..511eb268 100644
--- a/lib/fencing.py.py
+++ b/lib/fencing.py.py
@@ -614,7 +614,7 @@ def metadata(options, avail_opt, docs):
 	sorted_list.sort(key=lambda x: (x[1]["order"], x[0]))
 
 	if options["--action"] == "metadata":
-               docs["longdesc"] = re.sub("\\\\f[BPIR]|\.P|\.TP|\.br\n", "", docs["longdesc"])
+               docs["longdesc"] = re.sub(r"\\f[BPIR]|\.P|\.TP|\.br\n", r"", docs["longdesc"])
 
 	print("<?xml version=\"1.0\" ?>")
 	print("<resource-agent name=\"" + os.path.basename(sys.argv[0]) + \
@@ -649,7 +649,7 @@ def metadata(options, avail_opt, docs):
 			mixed = _encode_html_entities(mixed)
 
 			if not "shortdesc" in opt:
-				shortdesc = re.sub(".*\s\s+", "", opt["help"][31:])
+				shortdesc = re.sub(r".*\s\s+", r"", opt["help"][31:])
 			else:
 				shortdesc = opt["shortdesc"]
 
@@ -1359,7 +1359,7 @@ def _login_ssh_with_identity_file(options):
 
 def _login_telnet(options, re_login_string):
 	re_login = re.compile(re_login_string, re.IGNORECASE)
-	re_pass = re.compile("(password)|(pass phrase)", re.IGNORECASE)
+	re_pass = re.compile(r"(password)|(pass phrase)", re.IGNORECASE)
 
 	conn = fspawn(options, options["--telnet-path"])
 	conn.send("set binary\n")
@@ -1400,7 +1400,7 @@ def _login_telnet(options, re_login_string):
 
 def _login_ssh_with_password(options, re_login_string):
 	re_login = re.compile(re_login_string, re.IGNORECASE)
-	re_pass = re.compile("(password)|(pass phrase)", re.IGNORECASE)
+	re_pass = re.compile(r"(password)|(pass phrase)", re.IGNORECASE)
 
 	if "--inet6-only" in options:
 		force_ipvx = "-6 "
@@ -1608,7 +1608,7 @@ def _parse_input_stdin(avail_opt):
 
 		(name, value) = (line + "=").split("=", 1)
 		value = value[:-1]
-		value = re.sub("^\"(.*)\"$", "\\1", value)
+		value = re.sub(r"^\"(.*)\"$", r"\1", value)
 
 		if name.replace("-", "_") in mapping_longopt_names:
 			name = mapping_longopt_names[name.replace("-", "_")]
diff --git a/lib/fencing_snmp.py.py b/lib/fencing_snmp.py.py
index f9e57689..55f5db2a 100644
--- a/lib/fencing_snmp.py.py
+++ b/lib/fencing_snmp.py.py
@@ -91,7 +91,7 @@ class FencingSnmp:
 
 			logging.debug("%s\n", res_output)
 
-			if (res_code != 0) or (re.search("^Error ", res_output, re.MULTILINE) != None):
+			if (res_code != 0) or (re.search(r"^Error ", res_output, re.MULTILINE) != None):
 				fail_usage("Returned %d: %s"% (res_code, res_output))
 		except pexpect.ExceptionPexpect:
 			fail_usage("Cannot run command %s"%(command))
-- 
2.43.0

openSUSE Build Service is sponsored by