Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code_shauri #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions CORE/AutoAttendee_Shauri/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions CORE/AutoAttendee_Shauri/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions CORE/AutoAttendee_Shauri/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions CORE/AutoAttendee_Shauri/.idea/pythonProject1.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file added CORE/AutoAttendee_Shauri/Media/icon.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 CORE/AutoAttendee_Shauri/Media/winicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions CORE/AutoAttendee_Shauri/Schedule.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Link,Start,End,Day,Course Website,LAB/TUT
https://tiet.zoom.us/j/4859929922?_x_zm_rtaid=eimSCaGyQU-MHSD89cTQdw.1596773451370.7e01edc1cfa68d59966f250c5cfef01d&_x_zm_rhtaid=313#,20:30,20:31,Thursday,https://ada-lms.thapar.edu/moodle/course/view.php?id=154,No
https://tiet.zoom.us/j/4859929922?_x_zm_rtaid=eimSCaGyQU-MHSD89cTQdw.1596773451370.7e01edc1cfa68d59966f250c5cfef01d&_x_zm_rhtaid=313#,21:55,21:54,Thursday,https://ada-lms.thapar.edu/moodle/course/view.php?id=154,Yes
187 changes: 187 additions & 0 deletions CORE/AutoAttendee_Shauri/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import sys
import re
try:
from itertools import izip
except ImportError: #python3.x
izip = zip


def lms_login():
from selenium import webdriver
from getpass import getpass
import time
from datetime import datetime
import calendar
import random
import csv
my_date = datetime.today()

# https://chromedriver.chromium.org/downloads
username = input("Enter in your username: ")
password = getpass("Enter your password: ")

lms = webdriver.Chrome(executable_path="ChromeDriver/chromedriver.exe")
lms.get("https://ada-lms.thapar.edu/moodle/login/index.php")

username_textbox = lms.find_element_by_id("username")
username_textbox.send_keys(username)

password_textbox = lms.find_element_by_id("password")
password_textbox.send_keys(password)

login_button = lms.find_element_by_id("loginbtn")
login_button.submit()

with open('Schedule.csv', newline='') as f:
reader = csv.reader(f)
lst = list(reader)
lst.remove(lst[0])
for i in range(len(lst)):
lst[i].remove(lst[i][0])
for j in range(len(lst)):
if lst[j - 1][0] == '':
lst.remove(lst[j - 1])
# print(lst)

isStarted = False

for i in lst:
while True:
if isStarted == False:
if datetime.now().hour == int(i[0].split(':')[0]) and datetime.now().minute == int(
i[0].split(':')[1]) and calendar.day_name[my_date.weekday()] == i[2]:
lms.get(i[3])
time.sleep(10)
isStarted = True
elif datetime.now().hour == int(i[1].split(':')[0]):
# print('1')
if datetime.now().minute > int(i[1].split(':')[1]) and calendar.day_name[my_date.weekday()] == i[2]:
# print('2')
isStarted = False
break
elif datetime.now().hour > int(i[1].split(':')[0]):
if calendar.day_name[my_date.weekday()] == i[2]:
# print('3')
isStarted = False
break
elif calendar.day_name[my_date.weekday()] != i[2]:
isStarted = False
break
else:
num = random.randint(1, 3)
if num == 1:
lms.get('https://ada-lms.thapar.edu/moodle/my/')
time.sleep(2)
elif num == 2:
lms.get('https://ada-lms.thapar.edu/moodle/calendar/view.php?view=month')
time.sleep(2)
else:
lms.get('https://ada-lms.thapar.edu/moodle/')
time.sleep(2)
elif isStarted == True:
if datetime.now().hour == int(i[1].split(':')[0]) and datetime.now().minute == int(
i[1].split(':')[1]) and calendar.day_name[my_date.weekday()] == i[2]:
time.sleep(1)
isStarted = False
break


def zoom_login():
import time
from datetime import datetime
# from pynput.keyboard import Controller, Key
# from data import lst
import webbrowser
import calendar
import csv
from pynotifier import Notification
from playsound import playsound
my_date = datetime.today()

def labtutnotify():
i = 1
while i <= 4:
try:
Notification(
title='You have have a LAB/TUT',
description='Bro, Please Lab/Tut toh laga le!',
icon_path='Media/winicon.ico', # On Windows .ico is required, on Linux - .png
duration=10, # Duration in seconds
urgency=Notification.URGENCY_CRITICAL
).send()
except:
Notification(
title='You have have a LAB/TUT',
description='Kuch toh sharam kro!',
icon_path='Media/winicon.ico', # On Windows .ico is required, on Linux - .png
duration=10, # Duration in seconds
urgency=Notification.URGENCY_CRITICAL
).send()
playsound('Media/Alien_Siren-KevanGC-610357990.mp3')
time.sleep(5)
i += 1

with open('Schedule.csv', newline='') as f:
reader = csv.reader(f)
lst = list(reader)
lst.remove(lst[0])
# for i in range(len(lst)):
# lst[i].remove(lst[i][-1])
# for j in range(len(lst)):
# if lst[j-1][0] == '':
# lst.remove(lst[j-1])
# print(lst)

# keyboard = Controller()

isStarted = False

for i in lst:
print(i)
while True:
# print('1')
if isStarted == False:
# print('2')
if datetime.now().hour == int(i[1].split(':')[0]) and datetime.now().minute == int(
i[1].split(':')[1]) and calendar.day_name[my_date.weekday()] == i[3]:
# print('3')
webbrowser.open(i[0])
if i[-1] == "Yes":
# print('4')
labtutnotify()
isStarted = True
elif datetime.now().hour == int(i[1].split(':')[0]):
# print('5')
if datetime.now().minute > int(i[1].split(':')[1]) and calendar.day_name[my_date.weekday()] == i[3]:
# print('6')
isStarted = False
break
elif datetime.now().hour > int(i[1].split(':')[0]):
if calendar.day_name[my_date.weekday()] == i[3]:
# print('10')
isStarted = False
break
elif calendar.day_name[my_date.weekday()] != i[3]:
isStarted = False
break
elif isStarted == True:
# print('7')
if datetime.now().hour == int(i[2].split(':')[0]) and datetime.now().minute == int(
i[2].split(':')[1]) and calendar.day_name[my_date.weekday()] == i[3]:
# print('8')
# keyboard.press('w')
time.sleep(1)
# keyboard.press(Key.enter)
isStarted = False
break
# print('9')
print('Day Complete')


def main():
zoom_login()
lms_login()


if __name__ == '__main__':
main()
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import sys
import os
import re
import importlib
import warnings


is_pypy = '__pypy__' in sys.builtin_module_names


def warn_distutils_present():
if 'distutils' not in sys.modules:
return
if is_pypy and sys.version_info < (3, 7):
# PyPy for 3.6 unconditionally imports distutils, so bypass the warning
# https://foss.heptapod.net/pypy/pypy/-/blob/be829135bc0d758997b3566062999ee8b23872b4/lib-python/3/site.py#L250
return
warnings.warn(
"Distutils was imported before Setuptools, but importing Setuptools "
"also replaces the `distutils` module in `sys.modules`. This may lead "
"to undesirable behaviors or errors. To avoid these issues, avoid "
"using distutils directly, ensure that setuptools is installed in the "
"traditional way (e.g. not an editable install), and/or make sure "
"that setuptools is always imported before distutils.")


def clear_distutils():
if 'distutils' not in sys.modules:
return
warnings.warn("Setuptools is replacing distutils.")
mods = [name for name in sys.modules if re.match(r'distutils\b', name)]
for name in mods:
del sys.modules[name]


def enabled():
"""
Allow selection of distutils by environment variable.
"""
which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'stdlib')
return which == 'local'


def ensure_local_distutils():
clear_distutils()
distutils = importlib.import_module('setuptools._distutils')
distutils.__name__ = 'distutils'
sys.modules['distutils'] = distutils

# sanity check that submodules load as expected
core = importlib.import_module('distutils.core')
assert '_distutils' in core.__file__, core.__file__


def do_override():
"""
Ensure that the local copy of distutils is preferred over stdlib.

See https://github.com/pypa/setuptools/issues/417#issuecomment-392298401
for more motivation.
"""
if enabled():
warn_distutils_present()
ensure_local_distutils()


class DistutilsMetaFinder:
def find_spec(self, fullname, path, target=None):
if path is not None:
return

method_name = 'spec_for_{fullname}'.format(**locals())
method = getattr(self, method_name, lambda: None)
return method()

def spec_for_distutils(self):
import importlib.abc
import importlib.util

class DistutilsLoader(importlib.abc.Loader):

def create_module(self, spec):
return importlib.import_module('setuptools._distutils')

def exec_module(self, module):
pass

return importlib.util.spec_from_loader('distutils', DistutilsLoader())

def spec_for_pip(self):
"""
Ensure stdlib distutils when running under pip.
See pypa/pip#8761 for rationale.
"""
if self.pip_imported_during_build():
return
clear_distutils()
self.spec_for_distutils = lambda: None

@staticmethod
def pip_imported_during_build():
"""
Detect if pip is being imported in a build script. Ref #2355.
"""
import traceback
return any(
frame.f_globals['__file__'].endswith('setup.py')
for frame, line in traceback.walk_stack(None)
)


DISTUTILS_FINDER = DistutilsMetaFinder()


def add_shim():
sys.meta_path.insert(0, DISTUTILS_FINDER)


def remove_shim():
try:
sys.meta_path.remove(DISTUTILS_FINDER)
except ValueError:
pass
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('_distutils_hack').do_override()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'stdlib') == 'local'; enabled and __import__('_distutils_hack').add_shim();
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Run the EasyInstall command"""

if __name__ == '__main__':
from setuptools.command.easy_install import main
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip
Loading