Permalink
Browse files

GUI now re-asks password, if wrong

  • Loading branch information...
1 parent 6addf31 commit c5e8de4813d28ba1f71eac21a7bce7606ac8ab99 David Fendrich committed Apr 13, 2012
Showing with 39 additions and 24 deletions.
  1. +2 −2 README.md
  2. +1 −1 models.py
  3. +19 −5 password_dialog.py
  4. +14 −13 selfspy.py
  5. +3 −3 selfstats.py
View
4 README.md
@@ -52,7 +52,7 @@ Everything you do is stored in a Sqlite database in your DATA_DIR. Things that y
Unless you use the --no-text flag, selfspy will store everything you type in two <a href="http://en.wikipedia.org/wiki/Blowfish_(cipher)">Blowfish</a> encrypted columns in the database.
-Normally you would like Selfspy to start automatically when you launch X. The simplest way to accomplish this is to add selfspy.py to your *.xinitrc* file. When run, Selfspy will immediately spawn a daemon and exit.
+Normally you would like Selfspy to start automatically when you launch X. How to do this depends on your system, but it will normally mean editing *~/.xinitrc* or *~/.xsession*. If you run KDE, *~/.kde/Autostart*, is a good place to put startup scripts. When run, Selfspy will immediately spawn a daemon and exit.
### Example Statistics
*"OK, so now all this data will be stored, but what can I use it for?"*
@@ -255,5 +255,5 @@ See the README file or http://gurgeh.github.com/selfspy for examples.
To monitor that Selfspy works as it should and to continuously get feedback on yourself, it is good to regularly mail yourself some statistics. I think the easiest way to automate this is using [sendEmail](http://www.debianadmin.com/how-to-sendemail-from-the-command-line-using-a-gmail-account-and-others.html), which can do neat stuff like send through your Gmail account.
For example, put something like this in your weekly [cron](http://clickmojo.com/code/cron-tutorial.html) jobs:
-`/(PATH_TO_FILE)/selfstats.py --back 1 w --ratios 900 --periods 900 | sendEmail -q -u "Weekly selfstats" <etc..>`
+`/(PATH_TO_FILE)/selfstats.py --back 1 w --ratios 900 --periods 900 | /usr/bin/sendEmail -q -u "Weekly selfstats" <etc..>`
This will give you some interesting feedback on how much and when you have been active this last week and how much you have written vs moused, etc.
View
2 models.py
@@ -94,7 +94,7 @@ def __init__(self, button, press, x, y, nrmoves, process_id, window_id, geometry
self.geometry_id = geometry_id
def __repr__(self):
- return "<Click (%d, %d), (%d, %d, %d)>" % (self.xpos, self.ypos, self.button, self.press, self.nrmoves)
+ return "<Click (%d, %d), (%d, %d, %d)>" % (self.x, self.y, self.button, self.press, self.nrmoves)
def pad(s, padnum):
ls = len(s)
View
24 password_dialog.py
@@ -4,17 +4,31 @@
from Tkinter import *
import tkSimpleDialog
-def get_password():
+def get_password(verify=None):
if sys.stdin.isatty():
- return getpass.getpass()
+ for i in xrange(3):
+ pw = getpass.getpass()
+ if not verify: break
+ if verify(pw): break
else:
- return get_tk_password()
+ pw = get_tk_password(verify)
+ return pw
+
-def get_tk_password():
+def get_tk_password(verify):
root = Tk()
root.withdraw()
- return tkSimpleDialog.askstring(title='Selfspy encryption password', prompt='Password', show='*', parent=root)
+
+ while True:
+ pw = tkSimpleDialog.askstring(title='Selfspy encryption password', prompt='Password', show='*', parent=root)
+
+ if pw is None: return ""
+
+ if not verify: break
+ if verify(pw): break
+ return pw
+
if __name__ == '__main__':
print get_password()
View
27 selfspy.py
@@ -23,13 +23,6 @@
"""
Todo:
- put weekly mail in cron
-
- try rebooting with .xinitrc
-
- try all queries from README
- copy Pages to README
-
tag release in github
--
@@ -69,11 +62,22 @@ def parse_config():
return parser.parse_args()
+def make_encrypter(password):
+ if password == "":
+ encrypter = None
+ else:
+ encrypter = Blowfish.new(hashlib.md5(password).digest())
+ return encrypter
+
if __name__ == '__main__':
args = vars(parse_config())
args['data_dir'] = os.path.expanduser(args['data_dir'])
+ def check_with_encrypter(password):
+ encrypter = make_encrypter(password)
+ return check_password.check(args['data_dir'], encrypter)
+
try:
os.makedirs(args['data_dir'])
except OSError:
@@ -101,14 +105,11 @@ def parse_config():
if args['no_text']:
args['password'] = ""
-
+
if args['password'] is None:
- args['password'] = get_password()
+ args['password'] = get_password(verify=check_with_encrypter)
- if args['password'] == "":
- encrypter = None
- else:
- encrypter = Blowfish.new(hashlib.md5(args['password']).digest())
+ encrypter = make_encrypter(args['password'])
if not check_password.check(args['data_dir'], encrypter):
print 'Password failed'
View
6 selfstats.py
@@ -392,11 +392,11 @@ def show_summary(self):
print
if self.args['periods']:
- print 'Active periods (intervals are in HH:MM:SS):'
+ print 'Active periods:'
for t1,t2 in self.summary['activity'].times:
d1 = datetime.datetime.fromtimestamp(t1)
d2 = datetime.datetime.fromtimestamp(t2)
- print '%s, %s' % (d1.isoformat(' '), str(d2 - d1).split('.')[0])
+ print '%s - %s' % (d1.isoformat(' '), str(d2.time()).split('.')[0])
print
if self.args['ratios']:
@@ -408,7 +408,7 @@ def tryget(prop):
keys = tryget('keystrokes')
print 'Keys / Clicks: %.1f' % (keys / clicks)
print 'Active seconds / Keys: %.1f' % (act / keys)
-
+ print
print 'Mouse movements / Keys: %.1f' % (mousings / keys)
print 'Mouse movements / Clicks: %.1f' % (mousings / clicks)
print

0 comments on commit c5e8de4

Please sign in to comment.