added updaterooms for single rooms you specify in second commandline arg
This commit is contained in:
parent
77bd441dff
commit
0bac9ec8a7
1 changed files with 77 additions and 43 deletions
|
@ -214,6 +214,8 @@ if __name__ == '__main__':
|
|||
|
||||
|
||||
if user_input_list[0] == 'printrooms':
|
||||
|
||||
room_was_found = False
|
||||
# get all the rooms
|
||||
import os
|
||||
|
||||
|
@ -231,9 +233,37 @@ if __name__ == '__main__':
|
|||
answer = str(room_list)
|
||||
|
||||
if user_input_list[0] == 'updaterooms':
|
||||
|
||||
room_list = []
|
||||
rooms = os.listdir('rooms')
|
||||
for room in rooms:
|
||||
room_file = open('rooms/' + room, 'r')
|
||||
room_file_raw = room_file.read()
|
||||
room_file.close()
|
||||
|
||||
room_file_list = room_file_raw.split('§%§%')
|
||||
room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2]])
|
||||
|
||||
with open(spider_directory + '/spiders/config.yaml' , "r") as stream:
|
||||
try:
|
||||
config = yaml.safe_load(stream)
|
||||
except yaml.YAMLError as exc:
|
||||
print(exc)
|
||||
fdb_list = []
|
||||
#print(config)
|
||||
|
||||
for key in config:
|
||||
fdb_list.append(key)
|
||||
|
||||
|
||||
|
||||
|
||||
answer = "Ich update die Rooms auf Basis der Daten von heute morgen um 6 Uhr.."
|
||||
|
||||
data = dict({})
|
||||
for room in room_list:
|
||||
if room[0] == room_to_update:
|
||||
room_was_found = True
|
||||
print(room[0])
|
||||
room_fdbs = room[2]
|
||||
room_tags = room[3]
|
||||
|
@ -280,6 +310,10 @@ if __name__ == '__main__':
|
|||
|
||||
except Exception as e:
|
||||
print("probably i was not there in last page, original error is:", e)
|
||||
if room_was_found == False:
|
||||
answer = 'Den angegebenen Raum gibt es nicht.. Versuche es noch einmal mit -> updaterooms <room-id>'
|
||||
if room_was_found == True:
|
||||
answer = "Ich update die Rooms auf Basis der Daten in fdb-spider/spiders/output.."
|
||||
|
||||
|
||||
if user_input_list[0] == 'printfdbs':
|
||||
|
|
Loading…
Reference in a new issue