Skip to content

Commit

Permalink
Added command line arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
kcq888 committed Oct 22, 2024
1 parent edbf16a commit e7769fa
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 25 deletions.
49 changes: 31 additions & 18 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": ["-s", "Season2024-2025"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS" : "${workspaceFolder}/attendance.json"
}
}
]
}
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Sheet To Datastore",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"-s", "Season2024-2025", "-sid", "18vRwbW5gEwPMeg7Bsh9_92S2x-OcImO88Tw9RasKfrw"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "${workspaceFolder}/attendance.json"
}
},
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": ["-s", "Season2024-2025"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "${workspaceFolder}/attendance.json"
}
}
]
}
6 changes: 5 additions & 1 deletion AttendantMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from PySide6.QtQml import qmlRegisterType
from AttendantModel import AttendantModel

DEFAULT_SEASON = "Season2024-2025"

def parse(app):
""" parse the application arguments and options"""
parser = QCommandLineParser()
Expand Down Expand Up @@ -37,6 +39,8 @@ def parse(app):

# create context object and table view model
season = parse(app)
if not season:
Season = DEFAULT_SEASON
attendant = Attendant(season)

# setting context objects to QML
Expand All @@ -52,4 +56,4 @@ def parse(app):
engine.quit.connect(app.quit)

#execute and cleanup
app.exec_()
app.exec()
22 changes: 16 additions & 6 deletions tools/gsheetToFirestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import print_function
import os
import pickle
import argparse
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
Expand All @@ -14,14 +15,16 @@
SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']

# The ID and range of the registration spreadsheet
REGISTRATION_SHEET_ID = '19ZccrRYr2O_GN2P27Yn8a62duCkYewjoAoq_F6yU_A4'
REGISTRATION_RANG_RFID = 'Roster-2023-2024!A2:D'
REGISTRATION_RANG_RFID = 'Registration!A2:D'

class SheetToFirestore():
Season = "Season2023-2024"
Season = None
SheetId = None
RFIDS = "members/rfids"

def __init__(self) -> None:
def __init__(self, season, sheetId) -> None:
self.Season = season
self.SheetId = sheetId
# Firestore setup
self.fcred = credentials.Certificate(os.environ.get("GOOGLE_APPLICATION_CREDENTIALS"))
firebase_admin.initialize_app(self.fcred)
Expand Down Expand Up @@ -54,7 +57,7 @@ def createFirestore(self):

# Call the Sheets API
sheet = self.service.spreadsheets()
result = sheet.values().get(spreadsheetId=REGISTRATION_SHEET_ID,
result = sheet.values().get(spreadsheetId=self.SheetId,
range=REGISTRATION_RANG_RFID).execute()
values = result.get('values', [])

Expand All @@ -75,7 +78,14 @@ def createFirestore(self):
print("No data found!")

if __name__ == "__main__":
sheetToFirestore = SheetToFirestore()
parser = argparse.ArgumentParser(
prog="gsheetToFirestore",
description="Importing Attendance into database from Google sheet")
parser.add_argument('-s', '--season')
parser.add_argument('-sid', '--sheetId')

args = parser.parse_args()
sheetToFirestore = SheetToFirestore(args.season, args.sheetId)
sheetToFirestore.createFirestore()


0 comments on commit e7769fa

Please sign in to comment.