some more error handling for the interface commands

This commit is contained in:
alpcentaur 2023-12-14 17:17:58 +01:00
parent acc00d1ccd
commit 892e8057c9

View file

@ -286,10 +286,15 @@ if __name__ == '__main__':
answer = "The room_id to update the tags was not found" answer = "The room_id to update the tags was not found"
if user_input_list[0] == 'printtags': if user_input_list[0] == 'printtags':
if len(user_input_list[1]) >= 1: try:
room_id_to_print_tags = user_input_list[1]
except:
answer = "after the command printtags, the second argument has to be the room id.. use printrooms and look up the id of the room you want to print the tags"
room_id_to_print_tags = 'NONE'
if room_id_to_print_tags not 'NONE':
try: try:
room_file = open('rooms/' + user_input_list[1] + '.txt', 'r') room_file = open('rooms/' + room_id_to_print_tags + '.txt', 'r')
room_info_raw = room_file.read() room_info_raw = room_file.read()
room_file.close() room_file.close()
room_info = room_info_raw.split('§%§%') room_info = room_info_raw.split('§%§%')
@ -303,7 +308,6 @@ if __name__ == '__main__':
answer = "The room_id to get the tags was not found" answer = "The room_id to get the tags was not found"
if user_input_list[0] == 'printcommands': if user_input_list[0] == 'printcommands':
answer = """ answer = """
@ -344,9 +348,10 @@ if __name__ == '__main__':
answer = str(room_list) answer = str(room_list)
if user_input_list[0] == 'updaterooms': if user_input_list[0] == 'updaterooms':
try:
if len(user_input_list[1]) >= 1: if len(user_input_list[1]) >= 1:
room_to_update = user_input_list[1] room_to_update = user_input_list[1]
else: except Exception as e:
room_to_update = 'NONE' room_to_update = 'NONE'
room_list = [] room_list = []
rooms = os.listdir('rooms') rooms = os.listdir('rooms')
@ -427,10 +432,12 @@ if __name__ == '__main__':
except Exception as e: except Exception as e:
print("probably i was not there in last page, original error is:", e) print("probably i was not there in last page, original error is:", e)
if room_was_found == False: if room_to_update == 'NONE':
answer = 'Den angegebenen Raum gibt es nicht.. Versuche es noch einmal mit -> updaterooms <room-id>' answer = 'No room was specified, all rooms will get an update based on the data available'
if room_was_found == True: if room_was_found == False and room_to_update != 'NONE':
answer = "Ich update die Rooms auf Basis der Daten in fdb-spider/spiders/output.." answer = 'The room you specified does not exist, or there are no rooms configured, try the command without argument -> updaterooms'
if room_was_found == True and room_to_update != 'NONE':
answer = "I am updating the specified room based on the data in fdb-spider/spiders/output.."
if user_input_list[0] == 'printfdbs': if user_input_list[0] == 'printfdbs':