Skip to content

Commit

Permalink
Fixed global variable error than did incorrent clocking
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaun-Regenbaum committed Dec 20, 2020
1 parent 0d263d7 commit 774e419
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions clock_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# Global Variables:
minutes = hours_to_clock * 60
time_blocks = round(minutes / 15)
blocks_done = 0
driver = webdriver.Chrome(path_to_driver)
wait = WebDriverWait(driver, 25)

Expand Down Expand Up @@ -101,7 +102,7 @@ def clockHoursIn(status):

print("You Have Clocked In, Be Careful That Your Computer Does Not Turn Off")

return 0
return 1
except:
print("Error, Unable to Clock In")
return 0
Expand Down Expand Up @@ -134,10 +135,11 @@ def clockHoursOut(status):
print("Error, Unable to Clock Out")
return 0

def goBackToMenu(status, blocks_done):
def goBackToMenu(status):
if not status:
return 0

global blocks_done
blocks_done = blocks_done + 1

try:
Expand All @@ -161,11 +163,11 @@ def goBackToMenu(status, blocks_done):
b = login(a)
c = goToClock(b)

blocks_done = clockHoursIn(c)
d = clockHoursIn(c)

# This is to prevent timing out:
while blocks_done < time_blocks:
c = goToClock(goBackToMenu(c, blocks_done))
d = goToClock(goBackToMenu(d))
# Run through every 15 minutes, the timeout happens at 20 minutes
time.sleep(900)

Expand Down

0 comments on commit 774e419

Please sign in to comment.