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
if encryption is True: | |
print("***PYPER TIMESHEET UTILITY***") | |
print("\nEnter encryption password below:") | |
key = str(getpass.getpass()) | |
DB_NAME = ".timesheet.db" | |
engine = create_engine( | |
'sqlite+pysqlcipher://:{0}@/{1}?' | |
'cipher=aes-256-cfb&kdf_iter=64000'.format(key, DB_NAME)) | |
DBSession = sessionmaker(bind=engine) |
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
if encryption is True: | |
print("***PYPER TIMESHEET UTILITY***") | |
print("\nEnter encryption password below:") | |
key = getpass.getpass() | |
DB_NAME = ".timesheet.db?cipher=aes-256-cfb&kdf_iter=64000" | |
engine = create_engine('sqlite:///{}'.format(DB_NAME), module=sqlite) | |
else: | |
print("WARNING: Unencrypted session. Install pysqlcipher3 to enable encryption\n") | |
engine = create_engine('sqlite:///{}'.format(DB_NAME)) |
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
class WindowClass(QtGui.QMainWindow, form_class): | |
def __init__(self, parent=None): | |
QtGui.QMainWindow.__init__(self, parent) | |
self.setupUi(self) | |
self.run_button.clicked.connect(self.run_button_clicked) # Bind the event handlers | |
def run_button_clicked(self): | |
global dms |
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") |
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
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
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
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
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] | |
) |