Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

Commit

Permalink
Reformatted project structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sklyvan committed Nov 24, 2021
1 parent 6a4e69e commit 4956769
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 403 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ cython_debug/
UserPreferences.ini
/res/EspaiAulaFiles/
/res/JSON Files/
/keys/token.pickle
/key/token.pickle
/res/GUI/AppLogo.xcf
src/MainWindowNew.py
src/InformationWindowNew.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
PYTHON_VERSION = {'Major': 3, 'Minor': 8} # This is the required Python version used to run the program.
LOG_FILE_PATH = '../Logs.txt'
START_PROGRAM_TIME = get_time()
TOKEN_FILE = '../key/token.pickle'
CREDS_FILE = '../key/credentials.json'
API_URL = 'https://www.googleapis.com/auth/calendar'

# Graphic User Interface variables.
REPOSITORY_URL = "https://github.com/Sklyvan/ScrapingUPF"
Expand Down
17 changes: 7 additions & 10 deletions src/GoogleCalendar.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
from __future__ import print_function
import datetime
import os.path
import pickle
import datetime, os.path, pickle
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
tokenPath, credsPath = '../keys/token.pickle', '../keys/credentials.json'
from Constants import TOKEN_FILE, CREDS_FILE, API_URL

class Calendar:
def __init__(self):
self.Service = None
SCOPES = ['https://www.googleapis.com/auth/calendar']
SCOPES = [API_URL]
CREDS = None # Google API Function, generating the current Auth without opening the browser, so cool :).
if os.path.exists(tokenPath):
with open(tokenPath, 'rb') as token:
if os.path.exists(TOKEN_FILE):
with open(TOKEN_FILE, 'rb') as token:
CREDS = pickle.load(token)
if not CREDS or not CREDS.valid:
if CREDS and CREDS.expired and CREDS.refresh_token:
CREDS.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
credsPath, SCOPES)
flow = InstalledAppFlow.from_client_secrets_file(CREDS_FILE, SCOPES)
CREDS = flow.run_local_server(port=0)
with open(tokenPath, 'wb') as token:
with open(TOKEN_FILE, 'wb') as token:
pickle.dump(CREDS, token)

service = build('calendar', 'v3', credentials=CREDS)
Expand Down
74 changes: 0 additions & 74 deletions src/InformationWindowNew.py

This file was deleted.

Loading

0 comments on commit 4956769

Please sign in to comment.