Skip to content

Commit 6a75bad

Browse files
committed
msp.py: Fix invalid escape sequence in string warnings
Correct invalid escape sequences in strings, especially in file paths, regex patterns, and Windows-specific strings to avoid unexpected run time behavior and improve code readability and reliability. Signed-off-by: Viswanath Kraleti <[email protected]>
1 parent 0062e23 commit 6a75bad

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

msp.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,7 @@ def CalculateMinDiskSize():
15051505
# if a number was specified, it's size in sectors and we're making a singleimage.bin
15061506
# otherwise, a drive /dev/sdb or something was specified
15071507

1508-
m = re.search("^(\d+)$", disk_name)
1508+
m = re.search(r"^(\d+)$", disk_name)
15091509
if type(m) is not NoneType:
15101510
## to be here means they specified a number must be making a single image or patching files
15111511
Patching = "FILES"
@@ -1526,7 +1526,7 @@ def CalculateMinDiskSize():
15261526
if type(m) is not NoneType:
15271527
ValidDiskName = True
15281528
else:
1529-
m = re.search("(PHYSICALDRIVE\d+)", disk_name)
1529+
m = re.search(r"(PHYSICALDRIVE\d+)", disk_name)
15301530
if type(m) is not NoneType:
15311531
ValidDiskName = True
15321532
Filename = "\\\\.\\"+m.group(1)
@@ -1583,9 +1583,9 @@ def CalculateMinDiskSize():
15831583

15841584
if disk_name is None:
15851585
if sys.platform.startswith("linux"):
1586-
device_log("Don't forget to specify your drive, EX '-d /dev/sdb' OR '-d 0' to create a singleimage");
1586+
device_log(r"Don't forget to specify your drive, EX '-d /dev/sdb' OR '-d 0' to create a singleimage");
15871587
else:
1588-
device_log("Don't foreget to specify your drive, EX '-d \\.\PHYSICALDRIVE1' OR '-d 0' to create a singleimage");
1588+
device_log(r"Don't foreget to specify your drive, EX '-d \\.\PHYSICALDRIVE1' OR '-d 0' to create a singleimage");
15891589

15901590
PrintBigError("You must specify a DISK, option -d")
15911591

@@ -1642,7 +1642,7 @@ def CalculateMinDiskSize():
16421642
#device_log("no filename for label '%s'"%Write['label'])
16431643
continue
16441644

1645-
m = re.search("\.ext4$", Write['filename'])
1645+
m = re.search(r"\.ext4$", Write['filename'])
16461646
if type(m) is not NoneType:
16471647
TestIfSparse(test_sparse,Write['filename'])
16481648

@@ -1693,9 +1693,9 @@ def CalculateMinDiskSize():
16931693
PrintBigError("")
16941694
device_log("Something went wrong, couldn't determine size of disk?")
16951695
if sys.platform.startswith("linux"):
1696-
device_log("Did you remember to specify your drive, EX '-d /dev/sdb'");
1696+
device_log(r"Did you remember to specify your drive, EX '-d /dev/sdb'");
16971697
else:
1698-
device_log("Did you remember to specify your drive, EX '-d \\.\PHYSICALDRIVE1'");
1698+
device_log(r"Did you remember to specify your drive, EX '-d \\.\PHYSICALDRIVE1'");
16991699

17001700
device_log("\nmsp.py failed - Log is log_msp.txt\n\n")
17011701
sys.exit()

0 commit comments

Comments
 (0)