Skip to content

Instantly share code, notes, and snippets.

View minorsecond's full-sized avatar

Robert Ross Wardrup minorsecond

View GitHub Profile
@minorsecond
minorsecond / part_tc.py
Created May 21, 2015 14:57
Seg fault 'EVP_CIPHER_key_length () from /lib64/libcrypto.so.1.0.0' When running queries sel or job_sel.
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)
@minorsecond
minorsecond / tc.py
Created May 19, 2015 00:01
Sqlalchemy/Sqlcipher code
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))
@minorsecond
minorsecond / p_estimator.py
Created April 30, 2015 16:41
Broken UI (radio button doesn't work.)
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
@minorsecond
minorsecond / tc.py
Created April 30, 2015 11:16
Broken function in tc.py. It runs but does not calculate _sum_time correctly. If tworked is > .1, funky things happen.For example, in the job table.. "worked" held 0.2. When .2 was supposed to be added to it, .2 was written again.I suspect my logic is incorrect but I can't find it. Help please?
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")
@minorsecond
minorsecond / tc.py
Last active August 29, 2015 14:20
Broken function in tc.py. It runs but does not calculate _sum_time correctly. If tworked is > .1, funky things happen.For example, in the job table.. "worked" held 0.2. When .2 was supposed to be added to it, .2 was written again.I suspect my logic is incorrect but I can't find it. Help please?
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")
@minorsecond
minorsecond / time_sum.py
Created April 28, 2015 22:57
Sanity Check: Get sum of time worked (t_worked) of each row in sqlite database.
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
@minorsecond
minorsecond / key_iter
Created April 25, 2015 11:07
key_iter
for p_uuid in session.query(Clocktime.p_uuid).distinct():
times_dict = {'ID': p_uuid, 't_worked': 0}
print(times_dict)
@minorsecond
minorsecond / tc.py_traceback
Created April 22, 2015 23:55
tc.py_traceback
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
@minorsecond
minorsecond / Update ClocktimesTable
Last active August 29, 2015 14:19
Broken Sqlalchemy Code
now = datetime.datetime.now()
out = session.query(Clocktime). \
filter(Clocktime.p_uuid == p_uuid). \
update({"time_out": now}, synchronize_session='fetch')
session.commit()
@minorsecond
minorsecond / jobdb commit
Created April 18, 2015 00:14
Not creating the DB for some reason.
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]
)