mirror of
https://github.com/Rushilwiz/auto-mdh.git
synced 2025-04-09 23:00:18 -04:00
fix: .gitignore is now working
This commit is contained in:
parent
43f7da39c1
commit
54927e072d
164
.gitignore
vendored
Normal file
164
.gitignore
vendored
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
# special
|
||||||
|
*tar.gz
|
||||||
|
*.csv
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
secrets.py
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# .python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# poetry
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
|
#poetry.lock
|
||||||
|
|
||||||
|
# pdm
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
|
#pdm.lock
|
||||||
|
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||||
|
# in version control.
|
||||||
|
# https://pdm.fming.dev/#use-with-ide
|
||||||
|
.pdm.toml
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
#.idea/
|
105
mdh.py
Normal file
105
mdh.py
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
from playwright.sync_api import Playwright, sync_playwright, expect
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
from secrets import PASSWORD, EMAIL, LOCATION
|
||||||
|
|
||||||
|
def start_shift(playwright: Playwright, end_hour: str, end_minute: str) -> None:
|
||||||
|
before_noon = int(end_hour) < 12
|
||||||
|
if int(end_hour) > 12:
|
||||||
|
end_hour = str(int(end_hour) - 12)
|
||||||
|
|
||||||
|
browser = playwright.chromium.launch(headless=True)
|
||||||
|
context = browser.new_context()
|
||||||
|
page = context.new_page()
|
||||||
|
page.goto("https://beta.mydigitalhand.org/")
|
||||||
|
page.locator("input[name=\"email\"]").click()
|
||||||
|
page.locator("input[name=\"email\"]").fill(EMAIL)
|
||||||
|
page.locator("input[name=\"password\"]").click()
|
||||||
|
page.locator("input[name=\"password\"]").fill(PASSWORD)
|
||||||
|
page.get_by_role("button", name="Sign in").click()
|
||||||
|
page.get_by_role("link", name="University of North Carolina").click()
|
||||||
|
page.get_by_role("button", name="Waitlist").click()
|
||||||
|
|
||||||
|
if page.get_by_text("Start shift").is_visible() is False:
|
||||||
|
print("already running!")
|
||||||
|
context.close()
|
||||||
|
browser.close()
|
||||||
|
return
|
||||||
|
|
||||||
|
page.get_by_role("button", name="Start shift").click()
|
||||||
|
|
||||||
|
page.locator("input[name=\"endMoment\"]").click()
|
||||||
|
|
||||||
|
page.get_by_text("AM" if before_noon else "PM").click()
|
||||||
|
|
||||||
|
hrButton = page.locator("//div[@class=\"MuiPickersTimePickerToolbar-hourMinuteLabel\"]//button[1]")
|
||||||
|
minButton = page.locator("//div[@class=\"MuiPickersTimePickerToolbar-hourMinuteLabel\"]//button[2]")
|
||||||
|
|
||||||
|
hrButton.click()
|
||||||
|
|
||||||
|
box = page.get_by_text(str(end_hour)).last().bounding_box()
|
||||||
|
page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
|
||||||
|
|
||||||
|
minButton.click()
|
||||||
|
|
||||||
|
box = page.get_by_text(str(end_minute)).last().bounding_box()
|
||||||
|
page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
|
||||||
|
|
||||||
|
page.get_by_role("button", name="OK").click()
|
||||||
|
page.locator("input[name=\"location\"]").click()
|
||||||
|
page.locator("input[name=\"location\"]").fill(LOCATION)
|
||||||
|
page.get_by_role("button", name="Done").click()
|
||||||
|
|
||||||
|
print("started shift")
|
||||||
|
|
||||||
|
context.close()
|
||||||
|
browser.close()
|
||||||
|
|
||||||
|
def end_shift(playwright: Playwright) -> None:
|
||||||
|
browser = playwright.chromium.launch(headless=True)
|
||||||
|
context = browser.new_context()
|
||||||
|
page = context.new_page()
|
||||||
|
page.goto("https://beta.mydigitalhand.org/")
|
||||||
|
page.locator("input[name=\"email\"]").click()
|
||||||
|
page.locator("input[name=\"email\"]").fill(EMAIL)
|
||||||
|
page.locator("input[name=\"password\"]").click()
|
||||||
|
page.locator("input[name=\"password\"]").fill(PASSWORD)
|
||||||
|
page.get_by_role("button", name="Sign in").click()
|
||||||
|
page.get_by_role("link", name="University of North Carolina").click()
|
||||||
|
page.get_by_role("button", name="Waitlist").click()
|
||||||
|
|
||||||
|
page.get_by_role("button", name="End now").click()
|
||||||
|
page.get_by_role("button", name="End shift now").click()
|
||||||
|
|
||||||
|
print("ended shift")
|
||||||
|
|
||||||
|
context.close()
|
||||||
|
browser.close()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
times = []
|
||||||
|
|
||||||
|
with open("/rushil/auto-mdh/schedule.csv") as f:
|
||||||
|
for line in f:
|
||||||
|
if line.startswith("Day"):
|
||||||
|
continue
|
||||||
|
day, start, end = line.split(",")
|
||||||
|
start_hour, start_minute = start.split(":")
|
||||||
|
end_hour, end_minute = end.split(":")
|
||||||
|
day = int(day)
|
||||||
|
|
||||||
|
start_minute, end_minute = start_minute.strip(), end_minute.strip()
|
||||||
|
|
||||||
|
times.append((day, start_hour, start_minute, end_hour, end_minute))
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
now = datetime.now()
|
||||||
|
|
||||||
|
with sync_playwright() as playwright:
|
||||||
|
for day, start_hour, start_minute, end_hour, end_minute in times:
|
||||||
|
start_minutes = int(start_hour) * 60 + int(start_minute)
|
||||||
|
end_minutes = int(end_hour) * 60 + int(end_minute)
|
||||||
|
|
||||||
|
if day == now.weekday() and start_minutes <= now.hour * 60 + now.minute <= end_minutes:
|
||||||
|
start_shift(playwright, end_hour, end_minute)
|
3
secrets.sample
Normal file
3
secrets.sample
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
EMAIL=
|
||||||
|
PASSWORD=
|
||||||
|
LOCATION=
|
Loading…
Reference in New Issue
Block a user