Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from crossphoton/test-heroku
Browse files Browse the repository at this point in the history
add Deploy to Heroku
  • Loading branch information
crossphoton authored Dec 29, 2020
2 parents b4ec16c + 7db15ec commit 246a5ab
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: python3 -m http.server $PORT
run: python3 script.py
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/crossphoton/AIMS-Grades-Script/)

# AIMS-Grades-Script

**Exculsively for IIIT Raichur students

** Can be used for other institute AIMS portal too. Change the url for that. (Eg. IITH, IIIT Dharwad [Didn't tried it though])

By running this script you don't have to check for your grades again and again on the institute AIMS portal.
By running this script you don't have to check for your grades again and again on the institute AIMS portal, instead you'll get an email whenever there's an update

## How to use (Heroku - obv better)

Click on the deploy button above and create an app.

![Create heroku app](assets/create-app.png)

Now Manage app --> settings --> Reveal Config Vars

Add following variables
```
cookie (As shown below)
email (Gmail account email address to send email)
password (Password for given gmail account [Use app passwords])
period (Academic Period)
reciever (Reciever's email address)
web (your app url[Use open app button])
```
![Set Env](assets/env.png)

(Get the cookie value as shown below)

Lastly Resources --> edit run process --> Turn on switch --> Confirm
![Starting Script](assets/heroku-start.png)

Make sure the cost is zero......xD (It'll be though)

## How to use
## How to use (local/self hosted)

Install python requirements.

Expand Down
11 changes: 11 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "AIMS-Grades-Script",
"description": "A app to get notifications(email) for grade changes on IIITR AIMS portal",
"repository": "https://github.com/crossphoton/AIMS-Grades-Script",
"logo": "https://aims.iiitr.ac.in/iiitraichur/version1.0.04/images/aims_logo.png",
"keywords": ["python", "aims", "heroku"],
"image": "heroku/python",
"buildpacks": [
{"url": "heroku/python"}
]
}
Binary file added assets/create-app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/env.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/heroku-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AIMS Script</title>
</head>
<body>
<h1>The script is already running in background.(Hopefully)</h1>

</body>
</html>
File renamed without changes.
1 change: 1 addition & 0 deletions runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.9.1
23 changes: 11 additions & 12 deletions script.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import requests
import time
import time, os
import smtplib, datetime
from email.message import EmailMessage

Expand All @@ -15,14 +15,12 @@
"A+": 10, "A": 10, "A-": 9, "B": 8, "B-": 7, "C": 6, "C-": 5, "D": 4, "S": 0
}

email = "" #Update this with sender's email address
password = "" #Update this with corresponding email address's password
email = os.environ['email']
password = os.environ['password']

#Change URL if another institute (Not IIITR or URL is changed)
url = 'https://aims.iiitr.ac.in/iiitraichur/courseReg/loadMyCoursesHistroy?studentId=0&courseCd=&courseName=&orderBy=1&degreeIds=&acadPeriodIds=&regTypeIds=&gradeIds=&resultIds=&isGradeIds='
token = str(input("Cookie value: "))
cookie = {'JSESSIONID' : token}
academicPeriod = int(input("Academic Period ID: "))
url = 'https://aims.iiitr.ac.in/iiitraichur/courseReg/loadMyCoursesHistroy?studentId=3&courseCd=&courseName=&orderBy=1&degreeIds=&acadPeriodIds=&regTypeIds=&gradeIds=&resultIds=&isGradeIds='
cookie = {'JSESSIONID' : os.environ['cookie']}
academicPeriod = int(os.environ['period'])

def sendEmail(r, cgpa, totalCredit):
try:
Expand All @@ -33,13 +31,13 @@ def sendEmail(r, cgpa, totalCredit):
gradeData = ""

for course in r:
if course["acadPeriodId"] == academicPeriod:
if course["acadPeriodId"] == academicPeriod and course["gradeDesc"] != "":
gradeData += f'{course["courseName"]} : {course["gradeDesc"]}\n'


msg["subject"] = "Semester Grades Uploaded"
msg["To"] = "" # Update this with sender's address
msg["From"] = "" # Update this with reciever(s) address(es)
msg["To"] = os.environ['receiver']
msg["From"] = f'AIMS Script<{email}>'
msg.set_content("Semester Result\n\nYour CGPA till now for the semester is " + str(cgpa/totalCredit) + ". Below is a breakdown of grades. Have a nice day.\n\n" + gradeData)

smtp.send_message(msg)
Expand All @@ -52,6 +50,7 @@ def sendEmail(r, cgpa, totalCredit):
def gradeChecker(tillNow):

r = requests.get(url, cookies=cookie).json()
requests.get(os.environ['web'])

courseCount = 0
currentCount = 0
Expand All @@ -72,7 +71,7 @@ def gradeChecker(tillNow):
sendEmail(r, cgpa, totalCredit)
tillNow = currentCount
if(courseCount != currentCount):
print(f'[{datetime.datetime.now()}] {currentCount}/{courseCount} courses till now. Trying again in an hour.....')
print(f'[{datetime.datetime.now()}] {currentCount}/{courseCount} courses till now. Trying again in 10 mins.....')
time.sleep(600)
gradeChecker(tillNow)
else:
Expand Down

0 comments on commit 246a5ab

Please sign in to comment.