Skip to contentSkip to conversation

KVM Test: Add re.IGNORECASE to re.compile to verify_ip_address_ in kvm_utils.py

PATCH Michael Goldish 3 participants 3 messages Oct 28, 2009 1 message not in the archive KVM

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Thanks for catching this.
While we're at it, why not remove the 2 occurrences of re.IGNORECASE that have no effect?
We can also replace re.search(regex, o) with the slightly shorter regex.search(o), but that's just a cosmetic change.

----- Original Message -----
From: "Chen Cao" <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], "Chen Cao" <[email protected]>
Sent: Tuesday, October 27, 2009 6:03:36 AM (GMT+0200) Auto-Detected
Subject: [PATCH] KVM Test: Add re.IGNORECASE to re.compile to verify_ip_address_ in kvm_utils.py

Since the mac address is (changed to) lowercase and the output of 'arping' is in uppercase, we need re.IGNORECASE in the re.compile.

(the re.IGNORECASE in the re.search function takes no effect on the compiled regex.)

---
 client/tests/kvm/kvm_utils.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
client/tests/kvm/kvm_utils.py +1 -1
index f72984a..934f223 100644
@@ -190,7 +190,7 @@ def verify_ip_address_ownership(ip, macs, timeout=10.0):
     # Compile a regex that matches the given IP address and any of the given
     # MAC addresses
     mac_regex = "|".join("(%s)" % mac for mac in macs)
-    regex = re.compile(r"\b%s\b.*\b(%s)\b" % (ip, mac_regex))
+    regex = re.compile(r"\b%s\b.*\b(%s)\b" % (ip, mac_regex), re.IGNORECASE)
 
     # Check the ARP cache
     o = commands.getoutput("/sbin/arp -n")
Signature · 6 lines
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 3 lines · Michael Goldish

Thanks for catching this.
While we're at it, why not remove the 2 occurrences of re.IGNORECASE that have no effect?

I just chose to ignore the code that does not break the tests.

I'd like to send a patch to remove the 2 're.IGNORECASE's and use regex.search(o), as you recommended, to let Lucas to decide the perferred way to fix. :-)

Thanks for your advice.

Cao, Chen
2009/10/28

Quoted 48 lines

We can also replace re.search(regex, o) with the slightly shorter regex.search(o), but that's just a cosmetic change.

----- Original Message -----
From: "Chen Cao" <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], "Chen Cao" <[email protected]>
Sent: Tuesday, October 27, 2009 6:03:36 AM (GMT+0200) Auto-Detected
Subject: [PATCH] KVM Test: Add re.IGNORECASE to re.compile to verify_ip_address_ in kvm_utils.py

Since the mac address is (changed to) lowercase and the output of 'arping' is in uppercase, we need re.IGNORECASE in the re.compile.

(the re.IGNORECASE in the re.search function takes no effect on the compiled regex.)

---
 client/tests/kvm/kvm_utils.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
client/tests/kvm/kvm_utils.py +1 -1
index f72984a..934f223 100644
@@ -190,7 +190,7 @@ def verify_ip_address_ownership(ip, macs, timeout=10.0):
     # Compile a regex that matches the given IP address and any of the given
     # MAC addresses
     mac_regex = "|".join("(%s)" % mac for mac in macs)
-    regex = re.compile(r"\b%s\b.*\b(%s)\b" % (ip, mac_regex))
+    regex = re.compile(r"\b%s\b.*\b(%s)\b" % (ip, mac_regex), re.IGNORECASE)
 
     # Check the ARP cache
     o = commands.getoutput("/sbin/arp -n")
Signature · 10 lines
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

Thanks guys, applied!

Quoted 69 lines · Chen
Quoted 3 lines · Michael Goldish

Thanks for catching this.
While we're at it, why not remove the 2 occurrences of re.IGNORECASE that have no effect?

I just chose to ignore the code that does not break the tests.

I'd like to send a patch to remove the 2 're.IGNORECASE's and use regex.search(o), as you recommended, to let Lucas to decide the perferred way to fix. :-)

Thanks for your advice.

Cao, Chen
2009/10/28

Quoted 40 lines

We can also replace re.search(regex, o) with the slightly shorter regex.search(o), but that's just a cosmetic change.

----- Original Message -----
From: "Chen Cao" <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], "Chen Cao" <[email protected]>
Sent: Tuesday, October 27, 2009 6:03:36 AM (GMT+0200) Auto-Detected
Subject: [PATCH] KVM Test: Add re.IGNORECASE to re.compile to verify_ip_address_ in kvm_utils.py

Since the mac address is (changed to) lowercase and the output of 'arping' is in uppercase, we need re.IGNORECASE in the re.compile.

(the re.IGNORECASE in the re.search function takes no effect on the compiled regex.)

---
 client/tests/kvm/kvm_utils.py |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
client/tests/kvm/kvm_utils.py +1 -2
index f72984a..934f223 100644
@@ -190,7 +190,7 @@ def verify_ip_address_ownership(ip, macs, timeout=10.0):
      # Compile a regex that matches the given IP address and any of the given
      # MAC addresses
      mac_regex = "|".join("(%s)" % mac for mac in macs)
-    regex = re.compile(r"\b%s\b.*\b(%s)\b" % (ip, mac_regex))
+    regex = re.compile(r"\b%s\b.*\b(%s)\b" % (ip, mac_regex), re.IGNORECASE)
 
      # Check the ARP cache
      o = commands.getoutput("/sbin/arp -n")
--

1.6.0.6

Quoted 8 lines

--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Signature · 1 line
Lucas