added some important print commands, inputting first data of actual spider now
This commit is contained in:
parent
3e30365c90
commit
320e19875a
3 changed files with 111 additions and 30 deletions
Binary file not shown.
|
@ -3,6 +3,9 @@ from rocketchat.api import RocketChatAPI
|
|||
import configparser
|
||||
import json
|
||||
import requests
|
||||
import yaml
|
||||
|
||||
import subprocess
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
|
@ -50,7 +53,24 @@ if __name__ == '__main__':
|
|||
import time
|
||||
import schedule
|
||||
|
||||
def getroomdata():
|
||||
already_updated = False
|
||||
import datetime
|
||||
from datetime import timedelta
|
||||
while True:
|
||||
time.sleep(4)
|
||||
#already_updated = True
|
||||
now = datetime.datetime.now()
|
||||
|
||||
current_hour = now.strftime("%H")
|
||||
|
||||
if int(current_hour) > 6:
|
||||
aftersix = True
|
||||
|
||||
if int(current_hour) < 6:
|
||||
aftersix = False
|
||||
already_updated == False
|
||||
|
||||
if aftersix == True and already_updated == False:
|
||||
|
||||
room_list = []
|
||||
rooms = os.listdir('rooms')
|
||||
|
@ -60,21 +80,59 @@ if __name__ == '__main__':
|
|||
room_file.close()
|
||||
|
||||
room_file_list = room_file_raw.split('§%§%')
|
||||
room_list.append([room[:-3], room_file_list[0], room_file_list[1], room_file_list[2]])
|
||||
room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2]])
|
||||
|
||||
return room_list
|
||||
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)
|
||||
|
||||
|
||||
|
||||
data = dict({})
|
||||
for room in room_list:
|
||||
print(room[0])
|
||||
room_fdbs = room[2]
|
||||
#subprocess.run(["python", spider_directory + 'main.py', fdbs])
|
||||
|
||||
for room_fdb in eval(room_fdbs):
|
||||
#print('room_fdb',room_fdb, 'fdb_list',fdb_list)
|
||||
if room_fdb in fdb_list:
|
||||
try:
|
||||
iteration_var_list = config.get(room_fdb).get("entry-list").get("iteration-var-list")
|
||||
except Exception as e:
|
||||
print('there was an error with the entry-list parameter in the config regarding the fdb ', room_fdb)
|
||||
iterdict = {}
|
||||
for i in eval(iteration_var_list):
|
||||
f = open(spider_directory + "/spiders/output/" + room_fdb + str(i) + "entryList.txt")
|
||||
text = f.read()
|
||||
|
||||
dictionary_entry_list = eval(text)
|
||||
|
||||
iterdict[i] = dictionary_entry_list
|
||||
|
||||
data[room_fdb] = iterdict
|
||||
|
||||
|
||||
|
||||
|
||||
import datetime
|
||||
from datetime import timedelta
|
||||
while True:
|
||||
time.sleep(4)
|
||||
|
||||
print('data',data['giz'][2],'data')
|
||||
already_updated = True
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# if datestime.split over etc and updated= true etc
|
||||
|
||||
|
||||
n += 1
|
||||
print(n)
|
||||
|
||||
|
@ -143,11 +201,31 @@ if __name__ == '__main__':
|
|||
room_file.close()
|
||||
|
||||
room_file_list = room_file_raw.split('§%§%')
|
||||
room_list.append([room[:-3], room_file_list[0], room_file_list[1], room_file_list[2]])
|
||||
room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2]])
|
||||
|
||||
#print(room_list)
|
||||
answer = str(room_list)
|
||||
|
||||
if user_input_list[0] == 'printfdbs':
|
||||
|
||||
answer = str(fdb_list)
|
||||
|
||||
if len(user_input_list) > 1:
|
||||
answer = 'Die Syntax zum Ausgeben der konfigurierten Förderdatenbanken hat einen Fehler. Versuche es erneut, mit -> printfdbs'
|
||||
|
||||
if user_input_list[0] == 'deleteroom':
|
||||
try:
|
||||
room_id_del = user_input_list[1]
|
||||
except Exception as e:
|
||||
room_id_del = 'NONE'
|
||||
print(e)
|
||||
os.remove("rooms/" + room_id_del + ".txt")
|
||||
|
||||
anwer = 'deleting the requested room..'
|
||||
|
||||
if len(user_input_list) > 2:
|
||||
answer = 'Die Syntax zum Löschen eines Raumes hat einen Fehler. Versuche es erneut, nach dem Muster -> deleteroom <room_id>'
|
||||
|
||||
|
||||
if user_input_list[0] == 'createroom':
|
||||
try:
|
||||
|
@ -173,17 +251,20 @@ if __name__ == '__main__':
|
|||
answer = 'Um einen Raum zu erstellen, in dem neueste Einträge geteilt werden, lautet die Syntax: createroom <Raumname> <Liste-Datenbanken> <Liste-Filtertags>'
|
||||
|
||||
else:
|
||||
try:
|
||||
new_room = api.create_public_room(room_name,
|
||||
members=[latest_message_user_username],
|
||||
read_only=True)
|
||||
|
||||
|
||||
new_room_id = new_room['channel']['_id']
|
||||
room_file = open('rooms/' + new_room_id + '.txt', 'w')
|
||||
room_file.write( room_name + '§%§%' + databases + '§%§%' + filters)
|
||||
room_file.close()
|
||||
answer = 'Der Command wurde übermittelt'
|
||||
|
||||
except Exception as e:
|
||||
print('it was not able to create the room, the original error message is:', e)
|
||||
answer = 'There was an error creating the room, look up the logs.. the original error was: ' + str(e)
|
||||
|
||||
|
||||
#print('oi', user_input)
|
||||
api.send_message('Die Anfrage wird bearbeitet..', room_id)
|
||||
|
|
|
@ -1 +1 @@
|
|||
printrooms§%§%P6rQGgS9u7RqZM2iz
|
||||
printfdbs§%§%GGDZAhgELP2HDS5eM
|
Loading…
Reference in a new issue