adds regular processing script whichs writes to database in server
This commit is contained in:
parent
aaf66a1f10
commit
8d546e37a8
33
Routine.py
Normal file
33
Routine.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from server import db
|
||||||
|
from server.models import User
|
||||||
|
from backend import caltojson
|
||||||
|
|
||||||
|
import google.oauth2.credentials
|
||||||
|
import json
|
||||||
|
|
||||||
|
class Routine:
|
||||||
|
|
||||||
|
def start(self, time=10):
|
||||||
|
self.updateCalendars()
|
||||||
|
|
||||||
|
|
||||||
|
def updateCalendars(self):
|
||||||
|
users = User.query.all()
|
||||||
|
for user in users:
|
||||||
|
# check google:
|
||||||
|
credentials = user.getGoogleCredentials()
|
||||||
|
if credentials is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
credentials = google.oauth2.credentials.Credentials(**credentials)
|
||||||
|
calendarjson = caltojson.generateJsonFromCalendarEntries(credentials)
|
||||||
|
|
||||||
|
user.setJson(calendarjson)
|
||||||
|
|
||||||
|
with open('userinfo/'+ user.id +'/calendarevents.json', 'w', encoding='utf-8') as f:
|
||||||
|
json.dump(calendarjson, f, ensure_ascii=False, indent=4)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
routine = Routine()
|
||||||
|
routine.start()
|
3
__init__.py
Normal file
3
__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from backend.Routine import Routine
|
||||||
|
|
||||||
|
routine = Routine()
|
@ -1 +0,0 @@
|
|||||||
{"kind": "calendar#events", "events": [{"name": "Sleep", "isAllDay": false, "color": "#616161", "startDateTime": {"date": {"year": 2020, "month": 3, "day": 28}, "time": {"hour": 0, "minute": 0, "second": 0}}, "stopDateTime": {"date": {"year": 2020, "month": 3, "day": 28}, "time": {"hour": 8, "minute": 0, "second": 0}}}, {"name": "Sleep", "isAllDay": false, "color": "#616161", "startDateTime": {"date": {"year": 2020, "month": 3, "day": 29}, "time": {"hour": 0, "minute": 0, "second": 0}}, "stopDateTime": {"date": {"year": 2020, "month": 3, "day": 29}, "time": {"hour": 8, "minute": 0, "second": 0}}}]}
|
|
@ -1 +0,0 @@
|
|||||||
{"calendars": [{"name": "Todoist"}, {"name": "https://intranet.fhwn.ac.at/ics/Default.aspx?FHTimetable.ics&id=YUWSjNJUx5I%3d&datediffmonths=1&replaceSpecialChars=1"}, {"name": "Hightower"}, {"name": "Home \ud83c\udfe0"}, {"name": "D-ARIA"}, {"name": "Office"}, {"name": "http://followshows.com/ical/AS3Bbq0q"}, {"name": "Grey"}, {"name": "Privat"}, {"name": "Work"}, {"name": "Social"}, {"name": "Life"}, {"name": "https://poledancevienna.at/mypdv/ical/XJSY-56GQ-G2VC"}, {"name": "Contacts"}, {"name": "Holidays in Austria"}, {"name": "Week Numbers"}]}
|
|
@ -1 +0,0 @@
|
|||||||
{"installed":{"client_id":"590778864034-e3gjrjk8csdu2mee29dpe3mkql419no9.apps.googleusercontent.com","project_id":"quickstart-1583661954000","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"kj-suDOOuYQ3M4RpYG2exHyK","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}
|
|
BIN
token.pickle2
BIN
token.pickle2
Binary file not shown.
Loading…
Reference in New Issue
Block a user