示例#1
0
def main():    
    #AUTH STUFF
    creds = None

    if os.path.exists('token.json'):
        creds = Credentials.from_authorized_user_file('token.json', SCOPES)
    else:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
        else:
            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:
            token.write(creds.to_json())

    service = build('calendar', 'v3', credentials=creds)

    #EDUPAGE STUFF
    
    login = input("Enter your edupage login: "******"Enter your edupage password: "******"%Y-%d-%m").strftime("%Y-%m-%d")
        yest = datetime.now() - timedelta(1)
        print('\n\n\n')
        if datetime.strptime(dateSting, "%Y-%m-%d") > yest:
            event = {
                'summary': hw.title,
                'description': hw.description,
                'start': {
                    'dateTime': '{0}T09:00:00-07:00'.format(dateSting),
                    'timeZone': 'Etc/GMT',
                },
                'end': {
                    'dateTime': '{0}T09:00:00-07:00'.format(dateSting),
                    'timeZone': 'Etc/GMT',
                },
            }
            if times < 9:
                times = times + 1
            else:
                times = 2
            event = service.events().insert(calendarId='primary', body=event).execute()
            print('Event created: {}'.format(event.get('htmlLink')))
        else:
            print('Too old')
示例#2
0
    def login(self):
        # 1. self.domain_edit 2. self.user_edit 3. self.pass_edit
        domain = self.domain_edit.text()
        user = self.user_edit.text()
        password = self.pass_edit.text()

        try:
            self.edu = Edupage(domain, user, password)
            try:
                self.edu.login()
                self.login_formular.hide()
                eci = EdupageClientIndex(self)
                eci.index_formular.show()

            except BadCredentialsException:
                self.render_err(
                    "Bad credentials",
                    "Check login credentials (username/password)!")
            except LoginDataParsingException:
                self.render_err(
                    "Login data parsing",
                    "Check internet connection, try again later or contact server "
                    "administrators!")
        except UnicodeError:
            return
        except IndexError:
            self.render_err(
                "Indexing error",
                "Check entered domain, if correct then check internet connection or est!"
            )
示例#3
0
from edupage_api import Edupage

edupage = Edupage()
edupage.login_auto("Username (or e-mail)", "Password")

grades = edupage.get_grades()

grades_by_subject = {}

for grade in grades:
    if grades_by_subject.get(grade.subject_name):
        grades_by_subject[grade.subject_name] += [grade]
    else:
        grades_by_subject[grade.subject_name] = [grade]

for subject in grades_by_subject:
    print(f"{subject}:")
    for grade in grades_by_subject[subject]:

        print(f"    {grade.title} -> ", end="")

        if grade.max_points != 100:
            print(f"{grade.grade_n}/{grade.max_points}")
        else:
            print(f"{grade.percent}%")
    print("----------------")
示例#4
0
from datetime import datetime
from edupage_api import Edupage, EduDate, EduTimetable, EduTime, EduLength
import telebot
import time

groupId = -1001163700495
edupage = Edupage("sdc", "*****@*****.**", "Ansar2003")
edupage.login()
bot = telebot.TeleBot('1724837486:AAHSCeHaZeyxW03Qd5TzEK7XCwgCGNDe53k')


@bot.message_handler(commands=['hw'])
def hw(message):
    try:
        for hw in edupage.get_homework():
            bot.send_message(groupId, hw)
    except:
        bot.send_message(groupId, 'Не удалось получить данные.')


lessonTime = EduTime(0, 0)


@bot.message_handler(commands=['lesson'])
def nextLesson(message):
    try:
        if str(
                edupage.get_timetable(EduDate.today()).get_next_lesson_at_time(
                    EduTime.now())) != 'None':
            bot.send_message(
                groupId, 'Следующий урок \n' +
示例#5
0
class EdupageClient:
    def __init__(self):
        self.app = QtWidgets.QApplication(sys.argv)
        self.login_formular = QtWidgets.QWidget()
        self.login_layout = QtWidgets.QVBoxLayout()

        #740x532
        self.login_formular.setGeometry(300, 200, 740 / 2 - 25, 532 / 2 - 25)
        self.login_formular.setFixedSize(self.login_formular.size())
        self.login_formular.setWindowTitle("Edupage Client: Login ")

        # Widgety

        self.text = QtWidgets.QLabel("Edupage Client - Login to your account",
                                     parent=self.login_formular)
        self.text.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.text.setAlignment(QtCore.Qt.AlignCenter)
        self.domain_edit = QtWidgets.QLineEdit()
        self.domain_label = QtWidgets.QLabel(".edupage.org")

        self.user_label = QtWidgets.QLabel("Username: "******"Password: "******"Login")
        self.submit_button.clicked.connect(self.login)

        self.about_button = QtWidgets.QPushButton("About")
        self.about_button.clicked.connect(self.about)

        # Layouty
        self.login_grid = QGridLayout()
        self.domain_box = QtWidgets.QHBoxLayout()
        self.user_box = QtWidgets.QHBoxLayout()
        self.pass_box = QtWidgets.QHBoxLayout()
        self.submit_box = QtWidgets.QHBoxLayout()
        self.about_box = QtWidgets.QHBoxLayout()

        # Maintain main layout
        self.login_layout.addLayout(self.login_grid)
        self.login_layout.addStretch()

        self.login_layout.addLayout(self.domain_box)
        # self.login_layout.addStretch()

        self.login_layout.addLayout(self.user_box)

        self.login_layout.addLayout(self.pass_box)

        self.login_layout.addStretch()
        self.login_layout.addLayout(self.submit_box)

        # self.login_layout.addStretch()
        self.login_layout.addLayout(self.about_box)

        # Add widgets
        self.login_grid.addWidget(self.text, 0, 0)

        self.domain_box.addWidget(self.domain_edit)
        self.domain_box.addWidget(self.domain_label)

        self.user_box.addWidget(self.user_label)
        self.user_box.addWidget(self.user_edit)

        self.pass_box.addWidget(self.pass_label)
        self.pass_box.addWidget(self.pass_edit)

        self.submit_box.addWidget(self.submit_button)

        self.about_box.addWidget(self.about_button)

        self.login_formular.setLayout(self.login_layout)
        self.login_formular.show()
        sys.exit(self.app.exec_())

    def login(self):
        # 1. self.domain_edit 2. self.user_edit 3. self.pass_edit
        domain = self.domain_edit.text()
        user = self.user_edit.text()
        password = self.pass_edit.text()

        try:
            self.edu = Edupage(domain, user, password)
            try:
                self.edu.login()
                self.login_formular.hide()
                eci = EdupageClientIndex(self)
                eci.index_formular.show()

            except BadCredentialsException:
                self.render_err(
                    "Bad credentials",
                    "Check login credentials (username/password)!")
            except LoginDataParsingException:
                self.render_err(
                    "Login data parsing",
                    "Check internet connection, try again later or contact server "
                    "administrators!")
        except UnicodeError:
            return
        except IndexError:
            self.render_err(
                "Indexing error",
                "Check entered domain, if correct then check internet connection or est!"
            )

    def about(self):
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)
        msg.setText(
            "EdupageClient Version: 0.1\n\nEdupageClient Copyright (C) MMXXI \nTomáš Lovrant & Adam "
            "Vlčko\n\nThis program comes "
            "with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under "
            "the terms of the GNU General Public License as published by "
            "the Free Software Foundation, either version 3 of the License, or "
            "(at your option) any later version.\nSee: https://www.gnu.org/licenses/\n\nClick on Show Details "
            "... for more information.")
        msg.setDetailedText(
            "THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT "
            "WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE "
            "PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, "
            "BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A "
            "PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS "
            "WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY "
            "SERVICING, REPAIR OR CORRECTION.")
        msg.setWindowTitle("About EdupageClient")
        msg.setStandardButtons(QMessageBox.Ok)
        msg.setEscapeButton(QMessageBox.Ok)
        msg.exec_()

    def render_err(self, title, description):
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Critical)
        msg.setText(description)
        msg.setWindowTitle(title)
        msg.setStandardButtons(QMessageBox.Retry)
        msg.setEscapeButton(QMessageBox.Retry)
        msg.exec_()
示例#6
0
from edupage_api import Edupage, EduStudent, BadCredentialsException, LoginDataParsingException, EduDate
from subprocess import call

dom = input("Definuj doménu: (iba začiatok bez .edupage.org): ")
meno = input("Vlož prihlasovacie meno: ")
heslo = input("Vlož svoje heslo: ")
edu = Edupage(dom, meno, heslo)

try:
    call("clear")
    edu.login()
    print("Úspešne prihlásený ako ", meno, "na doméne", dom)
    print("1. Zobraziť list učiteľov (nefunkcne)")
    print("2. Zobraziť list spolužiakov")
    print("3. Úlohy")
    print("4. Rozvrh")
    vyber = int(input("Vitaj! Čo chceš robiť? "))

    if vyber == 1:
        call("clear")
        uc = edu.get_teachers()

        for teacher in uc:
            print("________________________________")
            print(str(teacher))
            print("________________________________")

    elif vyber == 2:
        call("clear")
        ziaci = edu.get_students()
        ziaci.sort(key=EduStudent.__sort__)
示例#7
0
from datetime import datetime

from edupage_api import Edupage

edupage = Edupage()
edupage.login_auto("Username (or e-mail)", "Password")

tomorrow = datetime.now()
missing_teachers = edupage.get_missing_teachers(tomorrow)

print(f"There are {len(missing_teachers)} missing tomorrow!")

print()

print("Teachers missing:", end=" ")
for i, teacher in enumerate(missing_teachers):
    if i != 0:
        print(", ", end="")

    print(f"{teacher.name}", end="")
示例#8
0

allLinks = {
    'Рауан  Жаукенов': 'https://us02web.zoom.us/j/6167704361?pwd=Z2tOUUJLSUFPSTk1QTEvWkVXR2htdz09',
    'Макпал Абдиева': 'https://us04web.zoom.us/j/4209084564?pwd=WURnMW53Q21IcVFqWEhBY2c3bXpUZz09',
    'Ремзия Пелтек': 'https://us04web.zoom.us/j/3191675202?pwd=aytkWkU5N3l1bXd6VU9aNHFNaGtBZz09',
    'Мерует Бекжасарова': 'https://us04web.zoom.us/j/8690240204?pwd=dkdXQ0lzejRaVDlPVHQ1U2pBWHNCQT09',
    'Досжан Алдаберген': 'https://us04web.zoom.us/j/5806683078?pwd=YU1tc3pGNkNnSkNMN3JmVmRQTkhqdz09',
    'Нури Гасанов': 'https://us04web.zoom.us/j/7043389639?pwd=TndhdFprb0NqY0ZqczNwaDRSZ0VIdz09'
}

version = '0.10b'
name = 'EduBot'
author = 'AnsarIK'

edupage = Edupage("sdc", "*****@*****.**", "Ansar2003")
edupage.login()
bot = telebot.TeleBot('1724837486:AAHSCeHaZeyxW03Qd5TzEK7XCwgCGNDe53k')

lessonTime = datetime.strptime('0:0', '%H:%M')
lessonDuration = 1800
groupId = -1001163700495



# bot.send_message(groupId, name + '\nВерсия ' + version )

def detectLesson():
    try:
        global lessonTime
        global timetable
示例#9
0
from edupage_api import Edupage
from edupage_api.people import EduTeacher

edupage = Edupage()
edupage.login_auto("Username (or e-mail)", "Password")

teachers = edupage.get_teachers()

def print_teacher_info(teacher: EduTeacher):
    print(f"{teacher.name} is in your school since {teacher.in_school_since}")

oldest_teacher = teachers[0]
for teacher in teachers:
    if not teacher.in_school_since:
        continue


    if teacher.in_school_since < oldest_teacher.in_school_since:
        oldest_teacher = teacher

print("The oldest teacher (the longest time in your school):")
print_teacher_info(oldest_teacher)

yonguest_teacher = teachers[0]
for teacher in teachers:
    if not teacher.in_school_since:
        continue

    if teacher.in_school_since > yonguest_teacher.in_school_since:
        yonguest_teacher = teacher
示例#10
0
from datetime import datetime

from edupage_api import Edupage

edupage = Edupage()
edupage.login_auto("Username (or e-mail)", "Password")

today = datetime.now()
lunch = edupage.get_lunches(today)

if lunch is None:
    print(f"No lunch choices for today ({today.date()}) yet!")
else:
    for menu_index_str in lunch.chooseable_menus:
        menu_index = int(menu_index_str)
        print(f"[{menu_index_str}] {lunch.menus[menu_index].name}")

    lunch_n = input("Which lunch do you want? ")
    while lunch_n not in lunch.chooseable_menus:
        lunch_n = input("Which lunch do you want? ")

    lunch.choose(edupage, int(lunch_n))
    print("Done!")