Skip to content

Commit

Permalink
Added GPLv3 licensing
Browse files Browse the repository at this point in the history
  • Loading branch information
David Fendrich committed Oct 29, 2012
1 parent 3e6075a commit c29abba
Show file tree
Hide file tree
Showing 10 changed files with 957 additions and 127 deletions.
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions activity_store.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright 2012 David Fendrich

# This file is part of Selfspy

# Selfspy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Selfspy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.

import time
from datetime import datetime
NOW = datetime.now
Expand Down
17 changes: 17 additions & 0 deletions check_password.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright 2012 David Fendrich

# This file is part of Selfspy

# Selfspy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Selfspy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.

import os

DIGEST_NAME = 'password.digest'
Expand Down
19 changes: 18 additions & 1 deletion models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
# Copyright 2012 David Fendrich

# This file is part of Selfspy

# Selfspy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Selfspy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.

import zlib
import json

import datetime

from sqlalchemy.ext.declarative import declarative_base, declared_attr
from sqlalchemy import Index, Column, Boolean, Integer, Unicode, UnicodeText, DateTime, Binary, ForeignKey, create_engine
from sqlalchemy import Index, Column, Boolean, Integer, Unicode, DateTime, Binary, ForeignKey, create_engine
from sqlalchemy.orm import sessionmaker, relationship, backref


Expand Down
32 changes: 25 additions & 7 deletions password_dialog.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
# Copyright 2012 David Fendrich

# This file is part of Selfspy

# Selfspy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Selfspy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.

import sys
import getpass

from Tkinter import *
from Tkinter import Tk
import tkSimpleDialog


def get_password(verify=None):
if sys.stdin.isatty():
for i in xrange(3):
pw = getpass.getpass()
if not verify: break
if verify(pw): break
if (not verify) or verify(pw):
break
else:
pw = get_tk_password(verify)
return pw



def get_tk_password(verify):
root = Tk()
root.withdraw()

while True:
pw = tkSimpleDialog.askstring(title='Selfspy encryption password', prompt='Password', show='*', parent=root)

if pw is None: return ""
if pw is None:
return ""

if not verify: break
if verify(pw): break
if (not verify) or verify(pw):
break
return pw


Expand Down
26 changes: 22 additions & 4 deletions period.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
# Copyright 2012 David Fendrich

# This file is part of Selfspy

# Selfspy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Selfspy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.

import bisect


class Period:
def __init__(self, cutoff):
self.times = []
self.cutoff = cutoff

def append(self, time):
ltimes = len(self.times)

def check_in(i):
if self.times[i][0] <= time <= self.times[i][1]:
self.times[i] = (self.times[i][0], max(time + self.cutoff, self.times[i][1]))
Expand All @@ -15,9 +34,9 @@ def check_in(i):

def maybe_merge(i):
if ltimes > i + 1:
if self.times[i][1] >= self.times[i+1][0]:
self.times[i] = (self.times[i][0], self.times[i+1][1])
self.times.pop(i+1)
if self.times[i][1] >= self.times[i + 1][0]:
self.times[i] = (self.times[i][0], self.times[i + 1][1])
self.times.pop(i + 1)

if ltimes == 0:
self.times.append((time, time + self.cutoff))
Expand All @@ -32,7 +51,6 @@ def maybe_merge(i):
self.times.insert(i, (time, time + self.cutoff))
maybe_merge(i)


def extend(self, times):
for time in times:
self.append(time)
Expand Down
36 changes: 19 additions & 17 deletions selfspy.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
#!/usr/bin/env python

# Copyright 2012 David Fendrich

# This file is part of Selfspy

# Selfspy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Selfspy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.

import os
import sys
import time

import argparse
import ConfigParser

import daemon
import lockfile
import signal
import grp
import pwd

import hashlib
from Crypto.Cipher import Blowfish
Expand All @@ -20,23 +34,12 @@
from password_dialog import get_password
import check_password

"""
Todo:
test keymap switch
---Later
code documentation, unittests, pychecker ;)
replay key and mouse for process and time interval (maybe store as macro)
word search
calculate personal keymap
"""

DATA_DIR = '~/.selfspy'
DBNAME = 'selfspy.sqlite'
LOCK_FILE = 'selfspy.pid'


def parse_config():
conf_parser = argparse.ArgumentParser(description=__doc__, add_help=False,
formatter_class=argparse.RawDescriptionHelpFormatter)
Expand All @@ -59,6 +62,7 @@ def parse_config():

return parser.parse_args()


def make_encrypter(password):
if password == "":
encrypter = None
Expand Down Expand Up @@ -99,7 +103,6 @@ def check_with_encrypter(password):
signal.SIGHUP: 'terminate'
}


if args['no_text']:
args['password'] = ""

Expand All @@ -112,7 +115,6 @@ def check_with_encrypter(password):
print 'Password failed'
sys.exit(1)

# with context:
astore = ActivityStore(os.path.join(args['data_dir'], DBNAME),
encrypter, store_text=(not args['no_text']))

Expand Down
Loading

0 comments on commit c29abba

Please sign in to comment.