diff --git a/.gitignore b/.gitignore index ee9bc2c..33de96c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *~* *.pyc -stringOutputs +stringOutputs/* token.json *.notes \ No newline at end of file diff --git a/GoogleCloudDocumentation.docx b/GoogleCloudDocumentation.docx index f095447..06ec6e0 100644 Binary files a/GoogleCloudDocumentation.docx and b/GoogleCloudDocumentation.docx differ diff --git a/README.md b/README.md index 3fc3d49..d123315 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,42 @@ # Substitution-Requests -System for CSE 102 staff to request subs. \ No newline at end of file +System for CSE 102 staff to request subs. + +***Installing and configuring for the first time:*** + +Install the libraries in your Python environment: + + pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib + pip install --upgrade pandas + pip install --upgrade pysimplegui + + Versions that are proven to work (newer versions probably work, older versions maybe work) + Pysimplegui 4.60.4 + pandas: 1.4.4 + google-api-python-client 2.100.0 + google-auth-httplib2 0.1.1 + google-auth-oauthlib 0.5.2 + +Install Git + https://git-scm.com/downloads + Be sure to use the right version (32 vs 64 bit, Windows vs Linux, etc.) you can find your version of Windows by typing “about” in the start bar + When installing Git, there are many settings, if you don’t know what it does, just keep the default option. + +Run Git bash and within run this command: + git config --global core.autocrlf false + +Close Git bash and open Git Gui + Click “Clone Existing Repository” and paste https://git.egr.msu.edu/CSE102/Substitution-Requests.git into the “Source Location” box. + The “Target Directory” box is the path to the folder you want to store your local copy in. The folder must NOT already exist. + E.g. “C:\Users\USERNAME\Substitution-Requests” will create the Substitution Requests folder and put all the files inside it. + Open the Repo in GitGui (this might happen automatically after cloning). Click “Tools” and “Add” + Put “Pull” in the name box and “git pull origin master” (no quotes) in the command box and click “Add” + +Run the code for the first time (or since 7 days have elapsed since this step was last performed on this computer) + It will take you to a login page, you MUST log in as cse102msu@gmail.com (password is python_1107) + This login has mandatory 2-factor authentication (b/c of Google policy on API access) + So if this is the first time or if you've reset your browser cookies it will call the office phone in EGR 1107 to give you the code + Once logged in, just click continue on each increasingly dire warning page until it says “The authentication flow has completed. You may close this window” + + +***Workflow:*** \ No newline at end of file diff --git a/helperFunctions.py b/helperFunctions.py index e012708..8be6333 100644 --- a/helperFunctions.py +++ b/helperFunctions.py @@ -271,23 +271,23 @@ def getNumFulfilledInDateRange(subRequestsArchiveFilename,earlyDate,lateDate): def createStrings(): stfD = pd.read_csv(staffDatabaseFilename,dtype=str,index_col=False) secD = pd.read_csv(sectionDatabaseFilename,dtype=str,index_col=False) - with open("stringOutputs/staffIDs.txt",'w') as f: + with open("stringOutputs/staffIDs.txt",'w+') as f: netIDs=stfD['NetID'].values netIDs.sort() f.write('\n'.join(netIDs)) - with open("stringOutputs/emails.txt",'w') as f: + with open("stringOutputs/emails.txt",'w+') as f: vals=cp.deepcopy(stfD['NetID'].values) for i in range(len(vals)): vals[i]=vals[i]+"@msu.edu" f.write('; '.join(vals)) - with open("stringOutputs/sectionTitles.txt",'w') as f: + with open("stringOutputs/sectionTitles.txt",'w+') as f: vals=secD['Section'].values seen=set() f.write('\n'.join([x for x in vals if not (x in seen or seen.add(x))])) - with open("stringOutputs/periodDates.txt",'w') as f: + with open("stringOutputs/periodDates.txt",'w+') as f: vals=secD['Date'].values seen=set() f.write('\n'.join([x for x in vals if not (x in seen or seen.add(x))])) @@ -486,7 +486,7 @@ def getForms(subRequestsFilename): flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES) creds = flow.run_local_server(port=0) #Save the credentials for the next run - with open('token.json', 'w') as token: + with open('token.json', 'w+') as token: token.write(creds.to_json()) #service = discovery.build('forms', 'v1', http=creds.authorize(Http()), discoveryServiceUrl=DISCOVERY_DOC, static_discovery=False) @@ -548,5 +548,5 @@ def getForms(subRequestsFilename): #Write the updated request list to file subs.to_csv(subRequestsFilename,index=False,index_label=False) #Write the timestamp to the token for checking when this function was last run - with open("lastUpdatedToken.txt",'w') as f: + with open("lastUpdatedToken.txt",'w+') as f: f.write(str(datetime.now())) diff --git a/lastUpdatedToken.txt b/lastUpdatedToken.txt index f4ad2d8..d07efab 100644 --- a/lastUpdatedToken.txt +++ b/lastUpdatedToken.txt @@ -1 +1 @@ -2023-10-25 11:42:15.835048 \ No newline at end of file +2023-10-25 12:30:36.615443 \ No newline at end of file