From 43f7da39c15bf3928ad93f7571c4b02b62d343e4 Mon Sep 17 00:00:00 2001 From: Rushil Umaretiya Date: Wed, 24 Jan 2024 14:58:21 -0500 Subject: [PATCH] fix: .gitignore is now working --- .gitignore | 163 ------------------------------------------------- README.md | 2 - mdh.py | 105 ------------------------------- schedule.csv | 5 -- secrets.sample | 3 - 5 files changed, 278 deletions(-) delete mode 100644 .gitignore delete mode 100644 README.md delete mode 100644 mdh.py delete mode 100644 schedule.csv delete mode 100644 secrets.sample diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 7c3f88f..0000000 --- a/.gitignore +++ /dev/null @@ -1,163 +0,0 @@ -*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/ diff --git a/README.md b/README.md deleted file mode 100644 index c87d89d..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# auto-mdh -Automated script for MyDigitalHand diff --git a/mdh.py b/mdh.py deleted file mode 100644 index 95c7183..0000000 --- a/mdh.py +++ /dev/null @@ -1,105 +0,0 @@ -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) \ No newline at end of file diff --git a/schedule.csv b/schedule.csv deleted file mode 100644 index 9ac05c1..0000000 --- a/schedule.csv +++ /dev/null @@ -1,5 +0,0 @@ -Day,Start Time,End Time -1,17:00,19:00 -2,11:00,14:00 -3,17:00,19:00 -4,14:00,17:00 diff --git a/secrets.sample b/secrets.sample deleted file mode 100644 index 9c8d03b..0000000 --- a/secrets.sample +++ /dev/null @@ -1,3 +0,0 @@ -EMAIL= -PASSWORD= -LOCATION= \ No newline at end of file