From c4edabc83e953de1ee75764c4a0c1b7eaff6c6b6 Mon Sep 17 00:00:00 2001 From: eneller Date: Fri, 16 Sep 2022 18:32:07 +0200 Subject: [PATCH] redo asq stuff --- asq/.gitignore | 2 ++ asq/README.md | 3 +++ asq/asq_rep.py | 47 +++++++++++++++++++++++++++++------------------ commands | 42 ------------------------------------------ 4 files changed, 34 insertions(+), 60 deletions(-) create mode 100644 asq/.gitignore create mode 100644 asq/README.md delete mode 100644 commands diff --git a/asq/.gitignore b/asq/.gitignore new file mode 100644 index 0000000..4006ccf --- /dev/null +++ b/asq/.gitignore @@ -0,0 +1,2 @@ +env/ +*.log diff --git a/asq/README.md b/asq/README.md new file mode 100644 index 0000000..c1e4f17 --- /dev/null +++ b/asq/README.md @@ -0,0 +1,3 @@ +# Usage +This script currently comes with a firefox linux webdriver. To install dependencies, use `python3 -m venv env` to create a new virtual environment, +activate it by running `source env/bin/activate` and install the requirements by running `pip install -r requirements.txt`. To exit the venv, run `deactivate`. \ No newline at end of file diff --git a/asq/asq_rep.py b/asq/asq_rep.py index a371ed8..c95cbda 100644 --- a/asq/asq_rep.py +++ b/asq/asq_rep.py @@ -4,6 +4,7 @@ from selenium import webdriver from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.support.ui import Select from selenium.webdriver.common.by import By +from getpass import getpass def check_exists_name(name): try: @@ -11,29 +12,39 @@ def check_exists_name(name): except NoSuchElementException: return False return True -i=.2 -driver = webdriver.Firefox(executable_path='./geckodriver') + +i=.2 # TODO replace dumb waiting with selenium waiting + +username = input("Input Username: ") +password = getpass() +button_xpath = '/html/body/div/div/div[4]/div[2]/div[1]/div/div/div[1]/div/form[1]/div/div/table/tbody/tr[3]/td/input[1]' +select_xpath = '/html/body/div/div/div[4]/div[2]/div[1]/div/div/div[1]/div/form[1]/div/div/table/tbody/tr[3]/td/select' + +driver = webdriver.Firefox(executable_path='./geckodriver') # TODO replace with service worker object +#driver.implicitly_wait(2) # seconds + + while True: driver.get('https://campusonline.uni-ulm.de/CoronaNG/user/mycorona.html') if (check_exists_name('uid')): - username = driver.find_element(By.NAME, 'uid') - password = driver.find_element(By.NAME, 'password') - username.send_keys(sys.argv[1]) - password.send_keys(sys.argv[2]) - password.submit() + username_field = driver.find_element(By.NAME, 'uid') + password_field = driver.find_element(By.NAME, 'password') + username_field.send_keys(username) + password_field.send_keys(password) + password_field.submit() time.sleep(i) driver.get('https://campusonline.uni-ulm.de/CoronaNG/user/mycorona.html') - else: - button = driver.find_element(By.XPATH, '/html/body/div/div/div[4]/div[2]/div[1]/div/div/div[1]/div/form[1]/div/div/table/tbody/tr[6]/td/select') - select = Select(driver.find_element(By.XPATH, '/html/body/div/div/div[4]/div[2]/div[1]/div/div/div[1]/div/form[1]/div/div/table/tbody/tr[6]/td/select')) - select.select_by_visible_text('Alle markieren') - button.submit() - time.sleep(i) - select = Select(driver.find_element(By.XPATH, '/html/body/div/div/div[4]/div[2]/div[1]/div/div/div[1]/div/form[1]/div/div/table/tbody/tr[6]/td/select')) - select.select_by_visible_text('An Markierten teilnehmen') - button = driver.find_element(By.XPATH, '/html/body/div/div/div[4]/div[2]/div[1]/div/div/div[1]/div/form[1]/div/div/table/tbody/tr[6]/td/select') - button.submit() - time.sleep(i) + button = driver.find_element(By.XPATH, button_xpath) + select = Select(driver.find_element(By.XPATH,select_xpath)) + select.select_by_visible_text('Alle markieren') + button.submit() + time.sleep(i) + select = Select(driver.find_element(By.XPATH,select_xpath)) + select.select_by_visible_text('An Markierten teilnehmen') + + button = driver.find_element(By.XPATH, button_xpath) + button.submit() + time.sleep(i) driver.quit() diff --git a/commands b/commands deleted file mode 100644 index f0fef2a..0000000 --- a/commands +++ /dev/null @@ -1,42 +0,0 @@ -Optimus Manager https://github.com/Askannz/optimus-manager/blob/master/README.md - optimus-manager --switch nvidia - optimus-manager --switch integrated - optimus-manager --switch hybrid - -Redshift - redshift -O 3000 - -tar - cd / -sudo tar -cvpz \ ---exclude=/backup_nofiles.tar.gz \ ---exclude=/proc \ ---exclude=/tmp \ ---exclude=/mnt \ ---exclude=/dev \ ---exclude=/sys \ ---exclude=/run \ ---exclude=/media \ ---exclude=/var/log \ ---exclude=/var/cache/apt/archives \ ---exclude=/home/*/.gvfs \ ---exclude=/home/*/.cache \ ---exclude=/home/*/Documents \ ---exclude=/home/*/Downloads \ ---exclude=/home/*/Code \ ---exclude=/home/*/Pictures \ ---exclude=/home/*/Videos \ ---exclude=/home/*/SoftMaker\ ---exclude=/home/*/Desktop \ ---exclude=/home/*/Music \ ---exclude=/home/*/Templates \ ---exclude=/home/*/.local/share/Trash \ ---exclude=/home/*/.local/share/Steam \ ---file backup.tar.gz / -mv backup_nofiles $(echo $(date +'%Y-%m%d')-backup_nofiles.tar.gz) - -extract ipv6 for duckdns -ip -6 addr show scope global | grep -o -P '(?<=inet6 ).*(?=/)' - -empty git branch -git switch --orphan