This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def time_formatter(): | |
""" | |
Takes user input as 00:00, splits those using : as seperator, | |
and prints the time formatted for timesheet in tenths of an | |
hour | |
""" | |
time_input = raw_input("\nTime Formatter\n" \ | |
"Please enter hours and minutes worked today" \ | |
"in 00:00 format: ") | |
if len(time_input.split(':')) == 2: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_time(time): | |
return datetime.datetime.strptime(time, '%I:%M %p') | |
def total_time(): | |
t_in = get_time(raw_input("Please enter your start time in 00:00 format: ")) | |
t_out = get_time(raw_input("Please enter your end time in 00:00 format: ")) | |
delta = t_out - t_in | |
HOUR = 60 * 60 | |
delta_tenths = float(delta.seconds // (HOUR / 10)) / 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with jobdb: | |
if debug == 1: | |
print("DEBUGGING") | |
print("Connected to jobdb. Data to be inserted into JOBDB Database:") | |
print ("Lead Name: {0}, Job Name: {1}, Job Abbrev: {2}, Time Worked: {3}, Date: {4}, UUID: {5}")\ | |
.format(lead_name, job_name,job_abbrev, time, date, p_uuid) | |
cur.execute( | |
"INSERT INTO jobdb(UUID, Lead_name, Job_name, Job_abbrev, Time_worked, " | |
"Date) VALUES(?, ?, ?, ?, ?, ?)", [p_uuid, lead_name, job_name, job_abbrev, time, date] | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
now = datetime.datetime.now() | |
out = session.query(Clocktime). \ | |
filter(Clocktime.p_uuid == p_uuid). \ | |
update({"time_out": now}, synchronize_session='fetch') | |
session.commit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "/home/rwardrup/Dev/Timeclock/tc.py", line 518, in <module> | |
main_menu() | |
File "/home/rwardrup/Dev/Timeclock/tc.py", line 489, in main_menu | |
breaktime() | |
File "/home/rwardrup/Dev/Timeclock/tc.py", line 207, in breaktime | |
update(Clocktime.time_out == datetime.datetime.now()) | |
File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2938, in update | |
self, synchronize_session, values, update_args) | |
File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1184, in factory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for p_uuid in session.query(Clocktime.p_uuid).distinct(): | |
times_dict = {'ID': p_uuid, 't_worked': 0} | |
print(times_dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t_worked = session.query(Clocktime).filter(Clocktime.p_uuid == p_uuid).order_by(Clocktime.id.desc()).all() | |
for i in tworked: | |
_sum_time += i.t_worked | |
eg. I want sum of time for p_uuid==1, _sum_time should equal '8'. | |
p_uuid t_worked | |
=================== | |
1 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clockout(): | |
""" | |
Clocks user out of project. Prints time_out (now) to clocktimes table for whichever row contains the same | |
p_uuid created in project_start(). | |
:rtype : object | |
:return: | |
""" | |
if status == 0: | |
raw_input("You're not currently in a job. Press enter to return to main menu") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clockout(): | |
""" | |
Clocks user out of project. Prints time_out (now) to clocktimes table for whichever row contains the same | |
p_uuid created in project_start(). | |
:rtype : object | |
:return: | |
""" | |
if status == 0: | |
raw_input("You're not currently in a job. Press enter to return to main menu") |
OlderNewer