mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-12 19:38:57 +00:00
Fix DeprecationWarning: invalid escape sequence. Fixes https://github.com/GNS3/gns3-gui/issues/2670
This commit is contained in:
parent
4b52e9313e
commit
456ef1348b
@ -637,7 +637,7 @@ class BaseNode:
|
||||
try:
|
||||
await self._ubridge_send(cmd)
|
||||
except UbridgeError as e:
|
||||
match = re.search("Cannot compile filter '(.*)': syntax error", str(e))
|
||||
match = re.search(r"Cannot compile filter '(.*)': syntax error", str(e))
|
||||
if match:
|
||||
message = "Warning: ignoring BPF packet filter '{}' due to syntax error".format(self.name, match.group(1))
|
||||
log.warning(message)
|
||||
|
@ -171,10 +171,10 @@ class IOUVM(BaseNode):
|
||||
|
||||
try:
|
||||
output = await gns3server.utils.asyncio.subprocess_check_output(self._path, "-h", cwd=self.working_dir, stderr=True)
|
||||
match = re.search("-n <n>\s+Size of nvram in Kb \(default ([0-9]+)KB\)", output)
|
||||
match = re.search(r"-n <n>\s+Size of nvram in Kb \(default ([0-9]+)KB\)", output)
|
||||
if match:
|
||||
self.nvram = int(match.group(1))
|
||||
match = re.search("-m <n>\s+Megabytes of router memory \(default ([0-9]+)MB\)", output)
|
||||
match = re.search(r"-m <n>\s+Megabytes of router memory \(default ([0-9]+)MB\)", output)
|
||||
if match:
|
||||
self.ram = int(match.group(1))
|
||||
except (ValueError, OSError, subprocess.SubprocessError) as e:
|
||||
@ -380,7 +380,7 @@ class IOUVM(BaseNode):
|
||||
log.warning("Could not determine the shared library dependencies for {}: {}".format(self._path, e))
|
||||
return
|
||||
|
||||
p = re.compile("([\.\w]+)\s=>\s+not found")
|
||||
p = re.compile(r"([\.\w]+)\s=>\s+not found")
|
||||
missing_libs = p.findall(output)
|
||||
if missing_libs:
|
||||
raise IOUError("The following shared library dependencies cannot be found for IOU image {}: {}".format(self._path,
|
||||
@ -604,7 +604,7 @@ class IOUVM(BaseNode):
|
||||
if nio.capturing:
|
||||
await self._ubridge_send('iol_bridge start_capture {name} "{output_file}" {data_link_type}'.format(name=bridge_name,
|
||||
output_file=nio.pcap_output_file,
|
||||
data_link_type=re.sub("^DLT_", "", nio.pcap_data_link_type)))
|
||||
data_link_type=re.sub(r"^DLT_", "", nio.pcap_data_link_type)))
|
||||
|
||||
await self._ubridge_apply_filters(bay_id, unit_id, nio.filters)
|
||||
unit_id += 1
|
||||
@ -1036,7 +1036,7 @@ class IOUVM(BaseNode):
|
||||
env["IOURC"] = self.iourc_path
|
||||
try:
|
||||
output = await gns3server.utils.asyncio.subprocess_check_output(self._path, "-h", cwd=self.working_dir, env=env, stderr=True)
|
||||
if re.search("-l\s+Enable Layer 1 keepalive messages", output):
|
||||
if re.search(r"-l\s+Enable Layer 1 keepalive messages", output):
|
||||
command.extend(["-l"])
|
||||
else:
|
||||
raise IOUError("layer 1 keepalive messages are not supported by {}".format(os.path.basename(self._path)))
|
||||
@ -1295,7 +1295,7 @@ class IOUVM(BaseNode):
|
||||
bay=adapter_number,
|
||||
unit=port_number,
|
||||
output_file=output_file,
|
||||
data_link_type=re.sub("^DLT_", "", data_link_type)))
|
||||
data_link_type=re.sub(r"^DLT_", "", data_link_type)))
|
||||
|
||||
async def stop_capture(self, adapter_number, port_number):
|
||||
"""
|
||||
|
@ -177,7 +177,7 @@ class Qemu(BaseManager):
|
||||
try:
|
||||
with open(version_file, "rb") as file:
|
||||
version = file.read().decode("utf-8").strip()
|
||||
match = re.search("[0-9\.]+", version)
|
||||
match = re.search(r"[0-9\.]+", version)
|
||||
if match:
|
||||
return version
|
||||
except (UnicodeDecodeError, OSError) as e:
|
||||
@ -186,7 +186,7 @@ class Qemu(BaseManager):
|
||||
else:
|
||||
try:
|
||||
output = await subprocess_check_output(qemu_path, "-version")
|
||||
match = re.search("version\s+([0-9a-z\-\.]+)", output)
|
||||
match = re.search(r"version\s+([0-9a-z\-\.]+)", output)
|
||||
if match:
|
||||
version = match.group(1)
|
||||
return version
|
||||
@ -205,7 +205,7 @@ class Qemu(BaseManager):
|
||||
|
||||
try:
|
||||
output = await subprocess_check_output(qemu_img_path, "--version")
|
||||
match = re.search("version\s+([0-9a-z\-\.]+)", output)
|
||||
match = re.search(r"version\s+([0-9a-z\-\.]+)", output)
|
||||
if match:
|
||||
version = match.group(1)
|
||||
return version
|
||||
|
@ -221,7 +221,7 @@ class VirtualBoxVM(BaseNode):
|
||||
for image in tree.getroot().findall("{http://www.virtualbox.org/}Image"):
|
||||
currentSnapshot = machine.get("currentSnapshot")
|
||||
if currentSnapshot:
|
||||
newSnapshot = re.sub("\{.*\}", "{" + str(uuid.uuid4()) + "}", currentSnapshot)
|
||||
newSnapshot = re.sub(r"\{.*\}", "{" + str(uuid.uuid4()) + "}", currentSnapshot)
|
||||
shutil.move(os.path.join(self.working_dir, self._vmname, "Snapshots", currentSnapshot) + ".vdi",
|
||||
os.path.join(self.working_dir, self._vmname, "Snapshots", newSnapshot) + ".vdi")
|
||||
image.set("uuid", newSnapshot)
|
||||
@ -443,7 +443,7 @@ class VirtualBoxVM(BaseNode):
|
||||
hdd_files = await self._get_all_hdd_files()
|
||||
vm_info = await self._get_vm_info()
|
||||
for entry, value in vm_info.items():
|
||||
match = re.search("^([\s\w]+)\-(\d)\-(\d)$", entry) # match Controller-PortNumber-DeviceNumber entry
|
||||
match = re.search(r"^([\s\w]+)\-(\d)\-(\d)$", entry) # match Controller-PortNumber-DeviceNumber entry
|
||||
if match:
|
||||
controller = match.group(1)
|
||||
port = match.group(2)
|
||||
|
@ -135,7 +135,7 @@ class VMware(BaseManager):
|
||||
except OSError:
|
||||
pass
|
||||
if version is not None:
|
||||
match = re.search("([0-9]+)\.", version)
|
||||
match = re.search(r"([0-9]+)\.", version)
|
||||
if match:
|
||||
version = match.group(1)
|
||||
return version
|
||||
@ -222,14 +222,14 @@ class VMware(BaseManager):
|
||||
|
||||
try:
|
||||
output = await subprocess_check_output(vmware_path, "-v")
|
||||
match = re.search("VMware Workstation ([0-9]+)\.", output)
|
||||
match = re.search(r"VMware Workstation ([0-9]+)\.", output)
|
||||
version = None
|
||||
if match:
|
||||
# VMware Workstation has been detected
|
||||
version = match.group(1)
|
||||
log.debug("VMware Workstation version {} detected".format(version))
|
||||
await self._check_vmware_workstation_requirements(version)
|
||||
match = re.search("VMware Player ([0-9]+)\.", output)
|
||||
match = re.search(r"VMware Player ([0-9]+)\.", output)
|
||||
if match:
|
||||
# VMware Player has been detected
|
||||
version = match.group(1)
|
||||
@ -278,7 +278,7 @@ class VMware(BaseManager):
|
||||
try:
|
||||
with open(vmware_networking_file, "r", encoding="utf-8") as f:
|
||||
for line in f.read().splitlines():
|
||||
match = re.search("VNET_([0-9]+)_VIRTUAL_ADAPTER", line)
|
||||
match = re.search(r"VNET_([0-9]+)_VIRTUAL_ADAPTER", line)
|
||||
if match:
|
||||
vmnet = "vmnet{}".format(match.group(1))
|
||||
if vmnet not in ("vmnet0", "vmnet1", "vmnet8"):
|
||||
@ -297,7 +297,7 @@ class VMware(BaseManager):
|
||||
windows_name = interface["netcard"]
|
||||
else:
|
||||
windows_name = interface["name"]
|
||||
match = re.search("(VMnet[0-9]+)", windows_name)
|
||||
match = re.search(r"(VMnet[0-9]+)", windows_name)
|
||||
if match:
|
||||
vmnet = match.group(1)
|
||||
if vmnet not in ("VMnet0", "VMnet1", "VMnet8"):
|
||||
@ -312,7 +312,7 @@ class VMware(BaseManager):
|
||||
|
||||
self._vmnet_start_range = self.config.get_section_config("VMware").getint("vmnet_start_range", self._vmnet_start_range)
|
||||
self._vmnet_end_range = self.config.get_section_config("VMware").getint("vmnet_end_range", self._vmnet_end_range)
|
||||
match = re.search("vmnet([0-9]+)$", vmnet, re.IGNORECASE)
|
||||
match = re.search(r"vmnet([0-9]+)$", vmnet, re.IGNORECASE)
|
||||
if match:
|
||||
vmnet_number = match.group(1)
|
||||
if self._vmnet_start_range <= int(vmnet_number) <= self._vmnet_end_range:
|
||||
@ -424,7 +424,7 @@ class VMware(BaseManager):
|
||||
|
||||
try:
|
||||
output = await subprocess_check_output(vmrun_path)
|
||||
match = re.search("vmrun version ([0-9\.]+)", output)
|
||||
match = re.search(r"vmrun version ([0-9\.]+)", output)
|
||||
version = None
|
||||
if match:
|
||||
version = match.group(1)
|
||||
|
@ -204,7 +204,7 @@ class VPCSVM(BaseNode):
|
||||
"""
|
||||
try:
|
||||
output = await subprocess_check_output(self._vpcs_path(), "-v", cwd=self.working_dir)
|
||||
match = re.search("Welcome to Virtual PC Simulator, version ([0-9a-z\.]+)", output)
|
||||
match = re.search(r"Welcome to Virtual PC Simulator, version ([0-9a-z\.]+)", output)
|
||||
if match:
|
||||
version = match.group(1)
|
||||
self._vpcs_version = parse_version(version)
|
||||
|
@ -365,7 +365,7 @@ class Link:
|
||||
self._nodes[1]["node"].name,
|
||||
self._nodes[1]["adapter_number"],
|
||||
self._nodes[1]["port_number"])
|
||||
return re.sub("[^0-9A-Za-z_-]", "", capture_file_name) + ".pcap"
|
||||
return re.sub(r"[^0-9A-Za-z_-]", "", capture_file_name) + ".pcap"
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
|
@ -135,7 +135,7 @@ class Hypervisor(UBridgeHypervisor):
|
||||
"""
|
||||
try:
|
||||
output = await subprocess_check_output(self._path, "-v", cwd=self._working_dir, env=env)
|
||||
match = re.search("ubridge version ([0-9a-z\.]+)", output)
|
||||
match = re.search(r"ubridge version ([0-9a-z\.]+)", output)
|
||||
if match:
|
||||
self._version = match.group(1)
|
||||
if sys.platform.startswith("win") or sys.platform.startswith("darwin"):
|
||||
|
@ -129,7 +129,7 @@ class Documentation:
|
||||
def _file_path(self, path):
|
||||
path = path.replace("compute", "")
|
||||
path = path.replace("controller", "")
|
||||
return re.sub("^v2", "", re.sub("[^a-z0-9]", "", path))
|
||||
return re.sub("^v2", "", re.sub(r"[^a-z0-9]", "", path))
|
||||
|
||||
def _write_definitions(self, f, schema):
|
||||
if "definitions" in schema:
|
||||
|
Loading…
Reference in New Issue
Block a user