added try/except for the delete logbook entry input from user
This commit is contained in:
parent
64656bf332
commit
bed5ab4a1a
@ -147,7 +147,7 @@ def addLogBook() :
|
|||||||
writeln("|CL")
|
writeln("|CL")
|
||||||
|
|
||||||
write("Enter the date for this log entry (YYYY-MM-DD HH:MM:SS): ")
|
write("Enter the date for this log entry (YYYY-MM-DD HH:MM:SS): ")
|
||||||
getDate = getstr(1,16,16,now)
|
getDate = getstr(1,20,20,now)
|
||||||
if not getDate :
|
if not getDate :
|
||||||
return isNull()
|
return isNull()
|
||||||
|
|
||||||
@ -222,16 +222,20 @@ def delLogBook() :
|
|||||||
writeln("["+str(I+1)+"] "+tmpDB[I])
|
writeln("["+str(I+1)+"] "+tmpDB[I])
|
||||||
write("|CREnter the number of the entry to delete: ")
|
write("|CREnter the number of the entry to delete: ")
|
||||||
getDate = getstr(1,16,16,"")
|
getDate = getstr(1,16,16,"")
|
||||||
if getDate :
|
try:
|
||||||
NUM = int(getDate) - 1
|
if getDate :
|
||||||
if tmpDB[NUM] in db["logs"] :
|
NUM = int(getDate) - 1
|
||||||
del db["logs"][tmpDB[NUM]]
|
if tmpDB[NUM] in db["logs"] :
|
||||||
saveDB()
|
del db["logs"][tmpDB[NUM]]
|
||||||
writeln("Deleted: "+getDate)
|
saveDB()
|
||||||
writeln("|PA")
|
writeln("Deleted: "+getDate)
|
||||||
else :
|
writeln("|PA")
|
||||||
writeln("No log entry with that date, please check and try again.")
|
else :
|
||||||
writeln("|PA")
|
writeln("No log entry with that date, please check and try again.")
|
||||||
|
writeln("|PA")
|
||||||
|
except:
|
||||||
|
writeln("You entered invalid data, aborted!")
|
||||||
|
writeln("|PA")
|
||||||
else:
|
else:
|
||||||
writeln("")
|
writeln("")
|
||||||
writeln("No records to delete. Aborted.".center(71))
|
writeln("No records to delete. Aborted.".center(71))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user