aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-02-04 04:16:39 +0100
committerTeddy Wing2018-02-04 04:16:39 +0100
commit4e1c150d18a85fe386615489ebaa6a327ec23cf3 (patch)
tree1af52c4bde1c0fb1fdf171753e0b8d5ce872c478
parent0d46ecb4ebb7e7fd74576ac84675b40a6e7918ec (diff)
downloadharvester-submit-week-for-approval-4e1c150d18a85fe386615489ebaa6a327ec23cf3.tar.bz2
Pass command line arguments to WebDriver functions
Get rid of our header variables as these are now replaced with our command line arguments. Add function arguments to `login` and `submit_week_for_approval` to take the values they need from the command line arguments.
-rw-r--r--harvester_submit_week_for_approval.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/harvester_submit_week_for_approval.py b/harvester_submit_week_for_approval.py
index 77e0665..a0c937e 100644
--- a/harvester_submit_week_for_approval.py
+++ b/harvester_submit_week_for_approval.py
@@ -11,12 +11,8 @@ from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support import expected_conditions as expected
from selenium.webdriver.support.wait import WebDriverWait
-email = ''
-password = ''
-subdomain = ''
-
-def login(driver, wait):
+def login(driver, wait, email, password):
driver.get('https://id.getharvest.com/harvest/sign_in')
wait.until(
@@ -39,7 +35,7 @@ def most_recent_friday():
else:
return now - timedelta(weeks=1) + timedelta(days=friday - now.weekday())
-def submit_week_for_approval(driver, wait):
+def submit_week_for_approval(driver, wait, subdomain):
# friday = most_recent_friday()
friday = datetime(2018, 1, 15)
@@ -114,7 +110,11 @@ if __name__ == "__main__":
wait = WebDriverWait(driver, timeout=10)
- driver = login(driver, wait)
- driver = submit_week_for_approval(driver, wait)
+ driver = login(
+ driver,
+ wait,
+ args.email,
+ get_password(args.password_command))
+ driver = submit_week_for_approval(driver, wait, args.subdomain)
driver.quit()