_IES_CA_FILE = "ca"
#: Valid LVS output line regex
-_LVSLINE_REGEX = re.compile("^ *([^|]+)\|([^|]+)\|([0-9.]+)\|([^|]{6,})\|?$")
+_LVSLINE_REGEX = re.compile(r"^ *([^|]+)\|([^|]+)\|([0-9.]+)\|([^|]{6,})\|?$")
# Actions for the master setup script
_MASTER_START = "start"
try:
fh = open("/proc/cpuinfo")
try:
- cpu_total = len(re.findall("(?m)^processor\s*:\s*[0-9]+\s*$",
+ cpu_total = len(re.findall(r"(?m)^processor\s*:\s*[0-9]+\s*$",
fh.read()))
finally:
fh.close()
_VIRTIO = "virtio"
_VIRTIO_NET_PCI = "virtio-net-pci"
- _MIGRATION_STATUS_RE = re.compile("Migration\s+status:\s+(\w+)",
+ _MIGRATION_STATUS_RE = re.compile(r"Migration\s+status:\s+(\w+)",
re.M | re.I)
_MIGRATION_PROGRESS_RE = \
re.compile(r"\s*transferred\s+ram:\s+(?P<transferred>\d+)\s+kbytes\s*\n"
if netinfo.mac_prefix:
data.write("NETWORK_MAC_PREFIX=%s\n" % netinfo.mac_prefix)
if netinfo.tags:
- data.write("NETWORK_TAGS=%s\n" % "\ ".join(netinfo.tags))
+ data.write("NETWORK_TAGS=%s\n" % r"\ ".join(netinfo.tags))
data.write("MAC=%s\n" % nic.mac)
data.write("IP=%s\n" % nic.ip)
"""
__slots__ = ["tags"]
- VALID_TAG_RE = re.compile("^[\w.+*/:@-]+$")
+ VALID_TAG_RE = re.compile(r"^[\w.+*/:@-]+$")
@classmethod
def ValidateTag(cls, tag):
raw_string = ET.tostring(self.tree)
parsed_xml = xml.dom.minidom.parseString(raw_string)
xml_string = parsed_xml.toprettyxml(indent=" ")
- text_re = re.compile(">\n\s+([^<>\s].*?)\n\s+</", re.DOTALL)
- return text_re.sub(">\g<1></", xml_string)
+ text_re = re.compile(r">\n\s+([^<>\s].*?)\n\s+</", re.DOTALL)
+ return text_re.sub(r">\g<1></", xml_string)
class Converter(object):
_, disk_path = self._CompressDisk(disk_path, disk_compression,
DECOMPRESS)
disk, _ = os.path.splitext(disk)
- if self._GetDiskQemuInfo(disk_path, "file format: (\S+)") != "raw":
+ if self._GetDiskQemuInfo(disk_path, r"file format: (\S+)") != "raw":
logging.info("Conversion to raw format is required")
ext, new_disk_path = self._ConvertDisk("raw", disk_path)
ext, new_disk_path = self._ConvertDisk(self.options.disk_format, disk_path)
results["format"] = self.options.disk_format
results["virt-size"] = self._GetDiskQemuInfo(
- new_disk_path, "virtual size: \S+ \((\d+) bytes\)")
+ new_disk_path, r"virtual size: \S+ \((\d+) bytes\)")
if compression:
ext2, new_disk_path = self._CompressDisk(new_disk_path, "gzip",
COMPRESS)
"""
_VALID_NAME_RE = re.compile("^[a-zA-Z0-9+_.-]*$")
- _PARSE_PV_DEV_RE = re.compile("^([^ ()]+)\([0-9]+\)$")
+ _PARSE_PV_DEV_RE = re.compile(r"^([^ ()]+)\([0-9]+\)$")
_INVALID_NAMES = compat.UniqueFrozenset([".", "..", "snapshot", "pvmove"])
_INVALID_SUBSTRINGS = compat.UniqueFrozenset(["_mlog", "_mimage"])
"""
UNCONF_RE = re.compile(r"\s*[0-9]+:\s*cs:Unconfigured$")
LINE_RE = re.compile(r"\s*[0-9]+:\s*cs:(\S+)\s+(?:st|ro):([^/]+)/(\S+)"
- "\s+ds:([^/]+)/(\S+)\s+.*$")
+ r"\s+ds:([^/]+)/(\S+)\s+.*$")
SYNC_RE = re.compile(r"^.*\ssync'ed:\s*([0-9.]+)%.*"
# Due to a bug in drbd in the kernel, introduced in
# commit 4b0715f096 (still unfixed as of 2011-08-22)
- "(?:\s|M)"
- "finish: ([0-9]+):([0-9]+):([0-9]+)\s.*$")
+ r"(?:\s|M)"
+ r"finish: ([0-9]+):([0-9]+):([0-9]+)\s.*$")
CS_UNCONFIGURED = "Unconfigured"
CS_STANDALONE = "StandAlone"
_SORTER_GROUPS = 8
-_SORTER_RE = re.compile("^%s(.*)$" % (_SORTER_GROUPS * "(\D+|\d+)?"))
+_SORTER_RE = re.compile("^%s(.*)$" % (_SORTER_GROUPS * r"(\D+|\d+)?"))
def UniqueSequence(seq):
def UnescapeAndSplit(text, sep=","):
- """Split and unescape a string based on a given separator.
+ r"""Split and unescape a string based on a given separator.
This function splits a string based on a separator where the
separator itself can be escape in order to be an element of the