2fef8755bb
Resolves: RHEL-35663 - fix pycurl bundled path Resolves: RHEL-35986
532 lines
23 KiB
Diff
532 lines
23 KiB
Diff
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] lib/all agents: use r"" for all regular expressions to avoid
|
|
SyntaxWarning errors
|
|
|
|
---
|
|
agents/alom/fence_alom.py | 2 +-
|
|
agents/amt/fence_amt.py | 2 +-
|
|
agents/apc/fence_apc.py | 18 +++++++++---------
|
|
agents/azure_arm/fence_azure_arm.py | 2 +-
|
|
agents/cdu/fence_cdu.py | 8 ++++----
|
|
agents/cisco_ucs/fence_cisco_ucs.py | 14 +++++++-------
|
|
agents/gce/fence_gce.py | 6 +++---
|
|
agents/ilo/fence_ilo.py | 2 +-
|
|
agents/ilo_mp/fence_ilo_mp.py | 2 +-
|
|
agents/ilo_ssh/fence_ilo_ssh.py | 2 +-
|
|
agents/ipmilan/fence_ipmilan.py | 6 +++---
|
|
agents/ironic/fence_ironic.py | 4 ++--
|
|
agents/lpar/fence_lpar.py | 10 +++++-----
|
|
agents/netio/fence_netio.py | 2 +-
|
|
agents/raritan/fence_raritan.py | 2 +-
|
|
agents/rhevm/fence_rhevm.py | 10 +++++-----
|
|
agents/rsa/fence_rsa.py | 2 +-
|
|
agents/wti/fence_wti.py | 6 +++---
|
|
lib/azure_fence.py.py | 2 +-
|
|
lib/fencing.py.py | 12 ++++++------
|
|
lib/fencing_snmp.py.py | 2 +-
|
|
21 files changed, 58 insertions(+), 58 deletions(-)
|
|
|
|
diff --git a/agents/alom/fence_alom.py b/agents/alom/fence_alom.py
|
|
index a8e216f3f..e593f16b5 100644
|
|
--- a/agents/alom/fence_alom.py
|
|
+++ b/agents/alom/fence_alom.py
|
|
@@ -13,7 +13,7 @@
|
|
def get_power_status(conn, options):
|
|
conn.send_eol("showplatform")
|
|
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
|
|
- status = re.search("standby", conn.before.lower())
|
|
+ status = re.search(r"standby", conn.before.lower())
|
|
result = (status != None and "off" or "on")
|
|
|
|
return result
|
|
diff --git a/agents/amt/fence_amt.py b/agents/amt/fence_amt.py
|
|
index 183bbc713..67e2112d3 100644
|
|
--- a/agents/amt/fence_amt.py
|
|
+++ b/agents/amt/fence_amt.py
|
|
@@ -13,7 +13,7 @@
|
|
|
|
def get_power_status(_, options):
|
|
output = amt_run_command(options, create_command(options, "status"))
|
|
- match = re.search('Powerstate:[\\s]*(..)', str(output))
|
|
+ match = re.search(r'Powerstate:[\s]*(..)', str(output))
|
|
status = match.group(1) if match else None
|
|
|
|
if status == None:
|
|
diff --git a/agents/apc/fence_apc.py b/agents/apc/fence_apc.py
|
|
index bc52aa244..805b83141 100644
|
|
--- a/agents/apc/fence_apc.py
|
|
+++ b/agents/apc/fence_apc.py
|
|
@@ -36,21 +36,21 @@ def get_power_status(conn, options):
|
|
admin = 0
|
|
switch = 0
|
|
|
|
- if None != re.compile('.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before):
|
|
+ if None != re.compile(r'.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before):
|
|
switch = 1
|
|
- if None != re.compile('.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before):
|
|
+ if None != re.compile(r'.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before):
|
|
if "--switch" not in options:
|
|
fail_usage("Failed: You have to enter physical switch number")
|
|
else:
|
|
if "--switch" not in options:
|
|
options["--switch"] = "1"
|
|
|
|
- if None == re.compile('.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before):
|
|
+ if None == re.compile(r'.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before):
|
|
version = 2
|
|
else:
|
|
version = 3
|
|
|
|
- if None == re.compile('.*Outlet Control/Configuration.*', re.IGNORECASE | re.S).match(conn.before):
|
|
+ if None == re.compile(r'.*Outlet Control/Configuration.*', re.IGNORECASE | re.S).match(conn.before):
|
|
admin = 0
|
|
else:
|
|
admin = 1
|
|
@@ -109,26 +109,26 @@ def set_power_status(conn, options):
|
|
admin3 = 0
|
|
switch = 0
|
|
|
|
- if None != re.compile('.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before):
|
|
+ if None != re.compile(r'.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before):
|
|
switch = 1
|
|
## MasterSwitch has different schema for on/off actions
|
|
action = {
|
|
'on' : "1",
|
|
'off': "3"
|
|
}[options["--action"]]
|
|
- if None != re.compile('.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before):
|
|
+ if None != re.compile(r'.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before):
|
|
if "--switch" not in options:
|
|
fail_usage("Failed: You have to enter physical switch number")
|
|
else:
|
|
if "--switch" not in options:
|
|
options["--switch"] = 1
|
|
|
|
- if None == re.compile('.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before):
|
|
+ if None == re.compile(r'.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before):
|
|
version = 2
|
|
else:
|
|
version = 3
|
|
|
|
- if None == re.compile('.*Outlet Control/Configuration.*', re.IGNORECASE | re.S).match(conn.before):
|
|
+ if None == re.compile(r'.*Outlet Control/Configuration.*', re.IGNORECASE | re.S).match(conn.before):
|
|
admin2 = 0
|
|
else:
|
|
admin2 = 1
|
|
@@ -142,7 +142,7 @@ def set_power_status(conn, options):
|
|
else:
|
|
conn.send_eol("2")
|
|
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
|
|
- if None == re.compile('.*2- Outlet Restriction.*', re.IGNORECASE | re.S).match(conn.before):
|
|
+ if None == re.compile(r'.*2- Outlet Restriction.*', re.IGNORECASE | re.S).match(conn.before):
|
|
admin3 = 0
|
|
else:
|
|
admin3 = 1
|
|
diff --git a/agents/azure_arm/fence_azure_arm.py b/agents/azure_arm/fence_azure_arm.py
|
|
index 0dca8f30d..227a7c2e2 100755
|
|
--- a/agents/azure_arm/fence_azure_arm.py
|
|
+++ b/agents/azure_arm/fence_azure_arm.py
|
|
@@ -251,7 +251,7 @@ def main():
|
|
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/agents/cdu/fence_cdu.py b/agents/cdu/fence_cdu.py
|
|
index ba76e6d76..6373158e9 100644
|
|
--- a/agents/cdu/fence_cdu.py
|
|
+++ b/agents/cdu/fence_cdu.py
|
|
@@ -51,11 +51,11 @@ def get_power_status(conn, options):
|
|
if options["api-version"] == "8":
|
|
# AA13 Arm-Console3 Wake On On Normal
|
|
# AA14 Master_Outlet_14 Wake On On Normal
|
|
- show_re = re.compile('(\w+)\s+(\S+)\s+(On|Idle On|Off|Wake On)\s+(On|Off)')
|
|
+ show_re = re.compile(r'(\w+)\s+(\S+)\s+(On|Idle On|Off|Wake On)\s+(On|Off)')
|
|
else:
|
|
# .A12 TowerA_Outlet12 On Idle On
|
|
# .A12 test-01 On Idle On
|
|
- show_re = re.compile('(\.\w+)\s+(\w+|\w+\W\w+)\s+(On|Off)\s+(On|Idle On|Off|Wake On)')
|
|
+ show_re = re.compile(r'(\.\w+)\s+(\w+|\w+\W\w+)\s+(On|Off)\s+(On|Idle On|Off|Wake On)')
|
|
for line in lines:
|
|
res = show_re.search(line)
|
|
if res != None:
|
|
@@ -89,7 +89,7 @@ def set_power_status(conn, options):
|
|
# else:
|
|
# .A12 TowerA_Outlet12
|
|
# .A12 test-01
|
|
- show_re = re.compile('(\S+)\s+(\w+|\w+\W\w+)\s+')
|
|
+ show_re = re.compile(r'(\S+)\s+(\w+|\w+\W\w+)\s+')
|
|
for line in lines:
|
|
res = show_re.search(line)
|
|
if res != None:
|
|
@@ -112,7 +112,7 @@ def get_version(conn, options):
|
|
conn.send("VERSION\r\n")
|
|
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
|
|
lines = conn.before.split("\n")
|
|
- show_re = re.compile('Sentry Switched [PC]DU Version (\d)(.\d|)(\w)\r')
|
|
+ show_re = re.compile(r'Sentry Switched [PC]DU Version (\d)(.\d|)(\w)\r')
|
|
for line in lines:
|
|
res = show_re.search(line)
|
|
if res != None:
|
|
diff --git a/agents/cisco_ucs/fence_cisco_ucs.py b/agents/cisco_ucs/fence_cisco_ucs.py
|
|
index cada20d5e..bcfabdbaa 100644
|
|
--- a/agents/cisco_ucs/fence_cisco_ucs.py
|
|
+++ b/agents/cisco_ucs/fence_cisco_ucs.py
|
|
@@ -8,13 +8,13 @@
|
|
from fencing import *
|
|
from fencing import fail, EC_STATUS, EC_LOGIN_DENIED, run_delay
|
|
|
|
-RE_COOKIE = re.compile("<aaaLogin .* outCookie=\"(.*?)\"", re.IGNORECASE)
|
|
-RE_STATUS = re.compile("<lsPower .*? state=\"(.*?)\"", re.IGNORECASE)
|
|
-RE_GET_DN = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
|
|
-RE_GET_PNDN = re.compile(" pndn=\"(.*?)\"", re.IGNORECASE)
|
|
-RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
|
|
-RE_GET_OPERPOWER = re.compile(" operPower=\"(.*?)\"", re.IGNORECASE)
|
|
-RE_GET_PRESENCE = re.compile(" presence=\"(.*?)\"", re.IGNORECASE)
|
|
+RE_COOKIE = re.compile(r"<aaaLogin .* outCookie=\"(.*?)\"", re.IGNORECASE)
|
|
+RE_STATUS = re.compile(r"<lsPower .*? state=\"(.*?)\"", re.IGNORECASE)
|
|
+RE_GET_DN = re.compile(r" dn=\"(.*?)\"", re.IGNORECASE)
|
|
+RE_GET_PNDN = re.compile(r" pndn=\"(.*?)\"", re.IGNORECASE)
|
|
+RE_GET_DESC = re.compile(r" descr=\"(.*?)\"", re.IGNORECASE)
|
|
+RE_GET_OPERPOWER = re.compile(r" operPower=\"(.*?)\"", re.IGNORECASE)
|
|
+RE_GET_PRESENCE = re.compile(r" presence=\"(.*?)\"", re.IGNORECASE)
|
|
|
|
options_global = None
|
|
|
|
diff --git a/agents/gce/fence_gce.py b/agents/gce/fence_gce.py
|
|
index b8871038e..759567c6f 100644
|
|
--- a/agents/gce/fence_gce.py
|
|
+++ b/agents/gce/fence_gce.py
|
|
@@ -85,8 +85,8 @@ def replace_api_uri(options, http_request):
|
|
uri_replacements.append(
|
|
{
|
|
"matchlength": 4,
|
|
- "match": "https://compute.googleapis.com/compute/v1/projects/(.*)/zones/(.*)/instances/(.*)/reset(.*)",
|
|
- "replace": "https://baremetalsolution.googleapis.com/v1/projects/\\1/locations/\\2/instances/\\3:resetInstance\\4"
|
|
+ "match": r"https://compute.googleapis.com/compute/v1/projects/(.*)/zones/(.*)/instances/(.*)/reset(.*)",
|
|
+ "replace": r"https://baremetalsolution.googleapis.com/v1/projects/\1/locations/\2/instances/\3:resetInstance\4"
|
|
})
|
|
for uri_replacement in uri_replacements:
|
|
# each uri_replacement should have matchlength, match, and replace
|
|
@@ -97,7 +97,7 @@ def replace_api_uri(options, http_request):
|
|
if match is None or len(match.groups()) != uri_replacement["matchlength"]:
|
|
continue
|
|
replaced_uri = re.sub(uri_replacement["match"], uri_replacement["replace"], http_request.uri)
|
|
- match = re.match("https:\/\/.*.googleapis.com", replaced_uri)
|
|
+ match = re.match(r"https:\/\/.*.googleapis.com", replaced_uri)
|
|
if match is None or match.start() != 0:
|
|
logging.warning("FENCE_GCE_URI_REPLACEMENTS replace is not "
|
|
"targeting googleapis.com, ignoring it: %s" % replaced_uri)
|
|
diff --git a/agents/ilo/fence_ilo.py b/agents/ilo/fence_ilo.py
|
|
index f30a1da28..9b9c08329 100644
|
|
--- a/agents/ilo/fence_ilo.py
|
|
+++ b/agents/ilo/fence_ilo.py
|
|
@@ -106,7 +106,7 @@ def main():
|
|
fail(EC_LOGIN_DENIED)
|
|
|
|
try:
|
|
- version = re.compile("<RIBCL VERSION=\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
|
|
+ version = re.compile(r"<RIBCL VERSION=\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
|
|
if "--ribcl-version" not in options:
|
|
options["--ribcl-version"] = float(version)
|
|
|
|
diff --git a/agents/ilo_mp/fence_ilo_mp.py b/agents/ilo_mp/fence_ilo_mp.py
|
|
index cc1c2decd..32530e947 100644
|
|
--- a/agents/ilo_mp/fence_ilo_mp.py
|
|
+++ b/agents/ilo_mp/fence_ilo_mp.py
|
|
@@ -8,7 +8,7 @@
|
|
def get_power_status(conn, options):
|
|
conn.send_eol("show /system1")
|
|
|
|
- re_state = re.compile('EnabledState=(.*)', re.IGNORECASE)
|
|
+ re_state = re.compile(r'EnabledState=(.*)', re.IGNORECASE)
|
|
conn.log_expect(re_state, int(options["--shell-timeout"]))
|
|
|
|
status = conn.match.group(1).lower()
|
|
diff --git a/agents/ilo_ssh/fence_ilo_ssh.py b/agents/ilo_ssh/fence_ilo_ssh.py
|
|
index 1d5be21ef..6f1d37688 100644
|
|
--- a/agents/ilo_ssh/fence_ilo_ssh.py
|
|
+++ b/agents/ilo_ssh/fence_ilo_ssh.py
|
|
@@ -9,7 +9,7 @@
|
|
def get_power_status(conn, options):
|
|
conn.send_eol("show /system1")
|
|
|
|
- re_state = re.compile('EnabledState=(.*)', re.IGNORECASE)
|
|
+ re_state = re.compile(r'EnabledState=(.*)', re.IGNORECASE)
|
|
conn.log_expect(re_state, int(options["--shell-timeout"]))
|
|
|
|
status = conn.match.group(1).lower()
|
|
diff --git a/agents/ipmilan/fence_ipmilan.py b/agents/ipmilan/fence_ipmilan.py
|
|
index a47fbdd82..083186201 100644
|
|
--- a/agents/ipmilan/fence_ipmilan.py
|
|
+++ b/agents/ipmilan/fence_ipmilan.py
|
|
@@ -13,7 +13,7 @@
|
|
|
|
def get_power_status(_, options):
|
|
output = _run_command(options, "status")
|
|
- match = re.search('[Cc]hassis [Pp]ower is [\\s]*([a-zA-Z]{2,3})', str(output))
|
|
+ match = re.search(r'[Cc]hassis [Pp]ower is [\s]*([a-zA-Z]{2,3})', str(output))
|
|
status = match.group(1) if match else None
|
|
return status
|
|
|
|
@@ -23,11 +23,11 @@ def set_power_status(_, options):
|
|
|
|
def reboot_cycle(_, options):
|
|
output = _run_command(options, "cycle")
|
|
- return bool(re.search('chassis power control: cycle', str(output).lower()))
|
|
+ return bool(re.search(r'chassis power control: cycle', str(output).lower()))
|
|
|
|
def reboot_diag(_, options):
|
|
output = _run_command(options, "diag")
|
|
- return bool(re.search('chassis power control: diag', str(output).lower()))
|
|
+ return bool(re.search(r'chassis power control: diag', str(output).lower()))
|
|
|
|
def _run_command(options, action):
|
|
cmd, log_cmd = create_command(options, action)
|
|
diff --git a/agents/ironic/fence_ironic.py b/agents/ironic/fence_ironic.py
|
|
index 76a9250f1..efccebd26 100644
|
|
--- a/agents/ironic/fence_ironic.py
|
|
+++ b/agents/ironic/fence_ironic.py
|
|
@@ -20,7 +20,7 @@ def get_name_or_uuid(options):
|
|
def get_power_status(_, options):
|
|
output = ironic_run_command(options, "status")
|
|
stdout = output[1]
|
|
- match = re.search('power[\\s]*([a-zA-Z]{2,3})', str(stdout))
|
|
+ match = re.search(r'power[\s]*([a-zA-Z]{2,3})', str(stdout))
|
|
status = match.group(1) if match else None
|
|
return status
|
|
|
|
@@ -40,7 +40,7 @@ def get_devices_list(_, options):
|
|
pass
|
|
if "UUID" in uuid:
|
|
continue # skip line header
|
|
- match = re.search('power[\\s]*([a-zA-Z]{2,3})', state)
|
|
+ match = re.search(r'power[\s]*([a-zA-Z]{2,3})', state)
|
|
status = match.group(1) if match else None
|
|
nodes[uuid] = (name, status)
|
|
|
|
diff --git a/agents/lpar/fence_lpar.py b/agents/lpar/fence_lpar.py
|
|
index a18e1c9ae..1703eb3e9 100644
|
|
--- a/agents/lpar/fence_lpar.py
|
|
+++ b/agents/lpar/fence_lpar.py
|
|
@@ -44,10 +44,10 @@ def get_power_status(conn, options):
|
|
|
|
try:
|
|
if options["--hmc-version"] == "3":
|
|
- status = re.compile("^" + options["--plug"] + ",(.*?),.*$",
|
|
+ status = re.compile(r"^" + options["--plug"] + r",(.*?),.*$",
|
|
re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
|
|
elif options["--hmc-version"] in ["4", "IVM"]:
|
|
- status = re.compile(",state=(.*?),", re.IGNORECASE).search(conn.before).group(1)
|
|
+ status = re.compile(r",state=(.*?),", re.IGNORECASE).search(conn.before).group(1)
|
|
except AttributeError as e:
|
|
logging.debug("Command on HMC failed: {}\n{}".format(command, str(e)))
|
|
fail(EC_STATUS_HMC)
|
|
@@ -60,7 +60,7 @@ def is_comanaged(conn, options):
|
|
conn.log_expect(options["--command-prompt"], int(options["--power-timeout"]))
|
|
|
|
try:
|
|
- cm = re.compile(",curr_master_mtms=(.*?),", re.IGNORECASE).search(conn.before).group(1)
|
|
+ cm = re.compile(r",curr_master_mtms=(.*?),", re.IGNORECASE).search(conn.before).group(1)
|
|
except AttributeError as e:
|
|
cm = False
|
|
|
|
@@ -106,7 +106,7 @@ def get_lpar_list(conn, options):
|
|
|
|
## We have to remove next 2 lines (header) and last line (part of new prompt)
|
|
####
|
|
- res = re.search("^(.+?\n){2}(.*)\n.*$", conn.before, re.S)
|
|
+ res = re.search(r"^(.+?\n){2}(.*)\n.*$", conn.before, re.S)
|
|
|
|
if res == None:
|
|
fail_usage("Unable to parse output of list command")
|
|
@@ -126,7 +126,7 @@ def get_lpar_list(conn, options):
|
|
|
|
## We have to remove last line (part of new prompt)
|
|
####
|
|
- res = re.search("^(.*)\n.*$", conn.before, re.S)
|
|
+ res = re.search(r"^(.*)\n.*$", conn.before, re.S)
|
|
|
|
if res == None:
|
|
fail_usage("Unable to parse output of list command")
|
|
diff --git a/agents/netio/fence_netio.py b/agents/netio/fence_netio.py
|
|
index fc3bf9d83..948fc4ce0 100755
|
|
--- a/agents/netio/fence_netio.py
|
|
+++ b/agents/netio/fence_netio.py
|
|
@@ -8,7 +8,7 @@
|
|
|
|
def get_power_status(conn, options):
|
|
conn.send_eol("port %s" % options["--plug"])
|
|
- re_status = re.compile("250 [01imt]")
|
|
+ re_status = re.compile(r"250 [01imt]")
|
|
conn.log_expect(re_status, int(options["--shell-timeout"]))
|
|
status = {
|
|
"0" : "off",
|
|
diff --git a/agents/raritan/fence_raritan.py b/agents/raritan/fence_raritan.py
|
|
index d3510e4a1..c78a7b30c 100644
|
|
--- a/agents/raritan/fence_raritan.py
|
|
+++ b/agents/raritan/fence_raritan.py
|
|
@@ -8,7 +8,7 @@
|
|
|
|
def get_power_status(conn, options):
|
|
conn.send_eol("show -d properties=powerState %s" % options["--plug"])
|
|
- re_status = re.compile(".*powerState is [12].*")
|
|
+ re_status = re.compile(r".*powerState is [12].*")
|
|
conn.log_expect(re_status, int(options["--shell-timeout"]))
|
|
status = {
|
|
#"0" : "off",
|
|
diff --git a/agents/rhevm/fence_rhevm.py b/agents/rhevm/fence_rhevm.py
|
|
index 1eb53bed0..87cd4cf45 100644
|
|
--- a/agents/rhevm/fence_rhevm.py
|
|
+++ b/agents/rhevm/fence_rhevm.py
|
|
@@ -9,10 +9,10 @@
|
|
from fencing import *
|
|
from fencing import fail, EC_FETCH_VM_UUID, run_delay
|
|
|
|
-RE_GET_ID = re.compile("<vm( .*)? id=\"(.*?)\"", re.IGNORECASE)
|
|
-RE_STATUS = re.compile("<status>(.*?)</status>", re.IGNORECASE)
|
|
-RE_STATE = re.compile("<state>(.*?)</state>", re.IGNORECASE)
|
|
-RE_GET_NAME = re.compile("<name>(.*?)</name>", re.IGNORECASE)
|
|
+RE_GET_ID = re.compile(r"<vm( .*)? id=\"(.*?)\"", re.IGNORECASE)
|
|
+RE_STATUS = re.compile(r"<status>(.*?)</status>", re.IGNORECASE)
|
|
+RE_STATE = re.compile(r"<state>(.*?)</state>", re.IGNORECASE)
|
|
+RE_GET_NAME = re.compile(r"<name>(.*?)</name>", re.IGNORECASE)
|
|
|
|
def get_power_status(conn, options):
|
|
del conn
|
|
@@ -80,7 +80,7 @@ def send_command(opt, command, method="GET"):
|
|
if opt["--api-version"] == "auto":
|
|
opt["--api-version"] = "4"
|
|
res = send_command(opt, "")
|
|
- if re.search("<title>Error</title>", res):
|
|
+ if re.search(r"<title>Error</title>", res):
|
|
opt["--api-version"] = "3"
|
|
logging.debug("auto-detected API version: " + opt["--api-version"])
|
|
|
|
diff --git a/agents/rsa/fence_rsa.py b/agents/rsa/fence_rsa.py
|
|
index 79ed109eb..6efde753c 100644
|
|
--- a/agents/rsa/fence_rsa.py
|
|
+++ b/agents/rsa/fence_rsa.py
|
|
@@ -16,7 +16,7 @@ def get_power_status(conn, options):
|
|
conn.send_eol("power state")
|
|
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
|
|
|
|
- match = re.compile("Power: (.*)", re.IGNORECASE).search(conn.before)
|
|
+ match = re.compile(r"Power: (.*)", re.IGNORECASE).search(conn.before)
|
|
if match != None:
|
|
status = match.group(1)
|
|
else:
|
|
diff --git a/agents/wti/fence_wti.py b/agents/wti/fence_wti.py
|
|
index ffa3d019c..9c16f364d 100644
|
|
--- a/agents/wti/fence_wti.py
|
|
+++ b/agents/wti/fence_wti.py
|
|
@@ -27,7 +27,7 @@ def get_listing(conn, options, listing_command):
|
|
re_all = list(options["--command-prompt"])
|
|
else:
|
|
re_all = [options["--command-prompt"]]
|
|
- re_next = re.compile("Enter: ", re.IGNORECASE)
|
|
+ re_next = re.compile(r"Enter: ", re.IGNORECASE)
|
|
re_all.append(re_next)
|
|
|
|
result = conn.log_expect(re_all, int(options["--shell-timeout"]))
|
|
@@ -208,8 +208,8 @@ def main():
|
|
conn.send("set binary\n")
|
|
conn.send("open %s -%s\n"%(options["--ip"], options["--ipport"]))
|
|
|
|
- re_login = re.compile("(login: )|(Login Name: )|(username: )|(User Name :)", re.IGNORECASE)
|
|
- re_prompt = re.compile("|".join(["(" + x + ")" for x in options["--command-prompt"]]), re.IGNORECASE)
|
|
+ re_login = re.compile(r"(login: )|(Login Name: )|(username: )|(User Name :)", re.IGNORECASE)
|
|
+ re_prompt = re.compile(r"|".join(["(" + x + ")" for x in options["--command-prompt"]]), re.IGNORECASE)
|
|
|
|
result = conn.log_expect([re_login, "Password: ", re_prompt], int(options["--shell-timeout"]))
|
|
if result == 0:
|
|
diff --git a/lib/azure_fence.py.py b/lib/azure_fence.py.py
|
|
index ab40b483a..fcbc40ab0 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 3a60f53ee..511eb2689 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"]
|
|
|
|
@@ -1272,7 +1272,7 @@ def source_env(env_file):
|
|
executable="/bin/sh")
|
|
# replace env
|
|
os.environ.clear()
|
|
- os.environ.update(line.partition('=')[::2] for line in output.decode("utf-8").split('\0') if not re.match("^\s*$", line))
|
|
+ os.environ.update(line.partition('=')[::2] for line in output.decode("utf-8").split('\0') if not re.match(r"^\s*$", line))
|
|
|
|
# Convert array of format [[key1, value1], [key2, value2], ... [keyN, valueN]] to dict, where key is
|
|
# in format a.b.c.d...z and returned dict has key only z
|
|
@@ -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 f9e576894..55f5db2ad 100644
|
|
--- a/lib/fencing_snmp.py.py
|
|
+++ b/lib/fencing_snmp.py.py
|
|
@@ -91,7 +91,7 @@ def run_command(self, command, additional_timeout=0):
|
|
|
|
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))
|