Skip to content

Commit 62cd9d2

Browse files
committed
Move serial validation to as soon as it is entered
1 parent 1f33e4e commit 62cd9d2

File tree

1 file changed

+5
-5
lines changed
  • hardware/raspberrypi/bootmodes/pxetools

1 file changed

+5
-5
lines changed

hardware/raspberrypi/bootmodes/pxetools/pxetools

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ def add():
5555
else:
5656
serial = sys.argv[2]
5757

58+
# Validate serial
59+
serial = serial.lstrip("0")
60+
if not re.search("^[0-9a-f]{8}$", serial):
61+
raise Exception("Invalid serial number {}".format(serial))
62+
5863
print("Serial: {}".format(serial))
5964
owner = input("Owner Name (ex Gordon): ")
6065
name = input("Name for pi: ")
@@ -66,11 +71,6 @@ def add():
6671

6772
img_choice = input("Enter an option number: ")
6873

69-
# Validate stuff
70-
serial = serial.lstrip("0")
71-
if not re.search("^[0-9a-f]{8}$", serial):
72-
raise Exception("Invalid serial number {}".format(serial))
73-
7474
tftp_path = "/tftpboot/{}".format(serial)
7575
nfs_path = "/nfs/{}".format(serial)
7676
if os.path.exists(tftp_path):

0 commit comments

Comments
 (0)