From: <tre...@us...> - 2009-09-09 12:58:13
|
Revision: 279 http://spd.svn.sourceforge.net/spd/?rev=279&view=rev Author: treibholz Date: 2009-09-09 12:58:06 +0000 (Wed, 09 Sep 2009) Log Message: ----------- Code cleanup Modified Paths: -------------- trunk/src/spdCore.py Modified: trunk/src/spdCore.py =================================================================== --- trunk/src/spdCore.py 2009-09-09 12:13:21 UTC (rev 278) +++ trunk/src/spdCore.py 2009-09-09 12:58:06 UTC (rev 279) @@ -224,40 +224,27 @@ count = 0 query = "CREATE TABLE passwords ( __ID INTEGER PRIMARY KEY," self.__insertStatement = "INSERT into passwords ( " - #insertValues = "" for collumns in self.__table: # first create the table count += 1 query += '`' + collumns + "` TEXT" - #insertValues += ":" + collumns self.__insertStatement += '`' + collumns + '`' if (count == len(self.__table)): # write ) if last collumn query += ")" self.__insertStatement += ")" - #insertValues += ")" else: # otherwise write a , query += ", " self.__insertStatement += ", " - #insertValues += ", " cursor.execute(query) self.__insertStatement += ' VALUES (' for i in range(0,len(self.__table[collumns])): - insertValues = '' - for collumns in self.__table: - #values[collumns] = self.__table[collumns][i] - insertValues += "'" + self.__table[collumns][i] + "'," - - insertValues = re.sub(r',$',r'', insertValues) - try: - cursor.execute(self.__insertStatement + insertValues + ')') - except sqlite3.OperationalError: #DEBUG - print "fillSQLite" - print insertValues - - + entry = {} + for j in self.__table: + entry.update( { j : self.__table[j][i] } ) + self.addEntry(entry,commit=False) self.__sql.commit() # }}} @@ -330,7 +317,8 @@ try: cursor.execute(self.__insertStatement + insertValues + ')') except sqlite3.OperationalError: #DEBUG - print "fillSQLite" + print "addEntry" + print entry print insertValues if commit: @@ -341,12 +329,14 @@ # delete an entry # patterns: list of strings - def delEntry(self,patterns): #{{{ + def delEntry(self,patterns=0,id=-1): #{{{ cursor = self.__sql.cursor() + + if (id < 0 ): + query = "delete from passwords where " + self.__buildWhere(patterns) + else: + query = "delete from passwords where __ID = " + unicode(id) - # create the query - query = "delete from passwords where " + self.__buildWhere(patterns) - cursor.execute(query) #}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tre...@us...> - 2009-09-09 13:14:49
|
Revision: 278 http://spd.svn.sourceforge.net/spd/?rev=278&view=rev Author: treibholz Date: 2009-09-09 12:13:21 +0000 (Wed, 09 Sep 2009) Log Message: ----------- grrr, ci in the wrong directory.... It's now possible to have spaces in the collumns Modified Paths: -------------- trunk/src/spdCore.py Modified: trunk/src/spdCore.py =================================================================== --- trunk/src/spdCore.py 2009-09-09 12:12:41 UTC (rev 277) +++ trunk/src/spdCore.py 2009-09-09 12:13:21 UTC (rev 278) @@ -224,37 +224,40 @@ count = 0 query = "CREATE TABLE passwords ( __ID INTEGER PRIMARY KEY," self.__insertStatement = "INSERT into passwords ( " - insertValues = "" + #insertValues = "" for collumns in self.__table: # first create the table count += 1 - query += collumns + " TEXT" - insertValues += ":" + collumns - self.__insertStatement += collumns + query += '`' + collumns + "` TEXT" + #insertValues += ":" + collumns + self.__insertStatement += '`' + collumns + '`' if (count == len(self.__table)): # write ) if last collumn query += ")" self.__insertStatement += ")" - insertValues += ")" + #insertValues += ")" else: # otherwise write a , query += ", " self.__insertStatement += ", " - insertValues += ", " + #insertValues += ", " cursor.execute(query) - self.__insertStatement += ' VALUES (' + insertValues + self.__insertStatement += ' VALUES (' for i in range(0,len(self.__table[collumns])): - values = {} + insertValues = '' for collumns in self.__table: - values[collumns] = self.__table[collumns][i] + #values[collumns] = self.__table[collumns][i] + insertValues += "'" + self.__table[collumns][i] + "'," + insertValues = re.sub(r',$',r'', insertValues) try: - cursor.execute(self.__insertStatement, values) + cursor.execute(self.__insertStatement + insertValues + ')') except sqlite3.OperationalError: #DEBUG - print values + print "fillSQLite" + print insertValues - del values + self.__sql.commit() # }}} @@ -290,7 +293,7 @@ result.update(self.__table) for i in result: - searchCollumns += i + ',' + searchCollumns += '`' + i + '`,' searchCollumns = re.sub(r',$','',searchCollumns) @@ -316,11 +319,22 @@ # add a new entry # entry: dictionary like self.__table - def addEntry(self, entry): # {{{ + def addEntry(self, entry, commit=True): # {{{ cursor = self.__sql.cursor() - count = 0 - cursor.execute(self.__insertStatement, entry) - self.__sql.commit() + insertValues = '' + for collumns in entry: + insertValues += "'" + entry[collumns] + "'," + + insertValues = re.sub(r',$',r'', insertValues) + + try: + cursor.execute(self.__insertStatement + insertValues + ')') + except sqlite3.OperationalError: #DEBUG + print "fillSQLite" + print insertValues + + if commit: + self.__sql.commit() del entry # }}} @@ -343,7 +357,7 @@ for filter in patterns: for collumns in self.__table: if (collumns != self.passwordField): - query += collumns + " like '%" + filter + "%' or " + query += '`' + collumns + "` like '%" + filter + "%' or " count += 1 query = re.sub(r'or $',') and (',query) # delete the last This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Z3...@us...> - 2009-10-02 23:47:19
|
Revision: 283 http://spd.svn.sourceforge.net/spd/?rev=283&view=rev Author: Z3po Date: 2009-10-02 23:47:09 +0000 (Fri, 02 Oct 2009) Log Message: ----------- Fixed bug with single quotes inside of a value while inserting it in sqlite. The Clue is to have another single quote in front of it (to escape it) Modified Paths: -------------- trunk/src/spdCore.py Modified: trunk/src/spdCore.py =================================================================== --- trunk/src/spdCore.py 2009-09-13 17:27:49 UTC (rev 282) +++ trunk/src/spdCore.py 2009-10-02 23:47:09 UTC (rev 283) @@ -310,8 +310,10 @@ cursor = self.__sql.cursor() insertValues = '' for collumns in entry: + entry[collumns] = re.sub(r'\'','\'\'', entry[collumns]) insertValues += "'" + entry[collumns] + "'," + insertValues = re.sub(r',$',r'', insertValues) try: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Z3...@us...> - 2009-10-04 07:24:10
|
Revision: 285 http://spd.svn.sourceforge.net/spd/?rev=285&view=rev Author: Z3po Date: 2009-10-04 07:23:59 +0000 (Sun, 04 Oct 2009) Log Message: ----------- fixed Mixed Collumns bug. there have been nearly everytime a "for collumns in self.__table" but one time a "for collumns in entry" which can be sorted in another way and that broke everythinga. Do we even need the entry object when having the table object all times available? Modified Paths: -------------- trunk/src/spdCore.py Modified: trunk/src/spdCore.py =================================================================== --- trunk/src/spdCore.py 2009-10-03 14:16:10 UTC (rev 284) +++ trunk/src/spdCore.py 2009-10-04 07:23:59 UTC (rev 285) @@ -164,7 +164,7 @@ del fobj else: fobj.close() - + return True #}}} @@ -235,7 +235,7 @@ else: # otherwise write a , query += ", " self.__insertStatement += ", " - + cursor.execute(query) self.__insertStatement += ' VALUES (' @@ -245,7 +245,7 @@ for j in self.__table: entry.update( { j : self.__table[j][i] } ) self.addEntry(entry,commit=False) - + self.__sql.commit() # }}} @@ -309,7 +309,7 @@ def addEntry(self, entry, commit=True): # {{{ cursor = self.__sql.cursor() insertValues = '' - for collumns in entry: + for collumns in self.__table: entry[collumns] = re.sub(r'\'','\'\'', entry[collumns]) insertValues += "'" + entry[collumns] + "'," This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Z3...@us...> - 2010-04-11 14:53:22
|
Revision: 288 http://spd.svn.sourceforge.net/spd/?rev=288&view=rev Author: Z3po Date: 2010-04-11 14:53:16 +0000 (Sun, 11 Apr 2010) Log Message: ----------- beautified source a bit :). Added addColumn functionality Modified Paths: -------------- trunk/src/spdCore.py Modified: trunk/src/spdCore.py =================================================================== --- trunk/src/spdCore.py 2009-11-28 16:25:35 UTC (rev 287) +++ trunk/src/spdCore.py 2010-04-11 14:53:16 UTC (rev 288) @@ -22,13 +22,13 @@ import sqlite3 import re -import ConfigParser +from ConfigParser import RawConfigParser import os try: from pyme import core, callbacks from pyme.constants.sig import mode -except: +except ImportError: print "You have to install the pyme Python interface to the GPGME GnuPG encryption library." print "in Debian/Ubuntu: sudo aptitude install python-pyme" print "See also: http://pyme.sourceforge.net/" @@ -36,20 +36,20 @@ try: import pysvn -except: +except ImportError: print "You have to install the Python interface to Subversion." print "in Debian/Ubuntu: sudo aptitude install python-svn" print "See also: http://pysvn.tigris.org/" exit(-1) class PasswordContainer(object): # {{{ - - '''The Constructor + """The Constructor creates an internal memory-based SQLite database and declares a a the self.__table dictionary file: string, the config-file - debug: if set to true, the database /tmp/spd_debug.db - autoload: if set to False, the data is not loaded automatically''' + debug: if set to true, the database is /tmp/spd_debug.db + autoload: if set to False, the data is not loaded automatically""" + def __init__(self,file,debug=False,autoload=True): #{{{ if not debug: @@ -61,7 +61,7 @@ # read the config file = os.path.expanduser(file) - c = ConfigParser.RawConfigParser() + c = RawConfigParser() if os.access(file,os.F_OK): c.read(file) @@ -105,8 +105,8 @@ #}}} - # read passwordfile def importPasswordsPlain(self): #{{{ + """This function reads the password file""" vcs = self.vcs encryption = self.encryption file = self.file @@ -168,8 +168,8 @@ return True #}}} - # write passwordfile def exportPasswordsPlain(self,autoload=True): #{{{ + """Writes the password file""" if autoload: self.dumpSQLite() @@ -210,15 +210,14 @@ if (vcs == "svn"): svn = pysvn.Client() - svn.checkin([file],'lalala') + svn.checkin([file],'SPD Passfile Update') else: pass # }}} - # write self.__table in SQLite def fillSQLite(self): #{{{ - + """writes self.__table into SQLite Database""" cursor = self.__sql.cursor() count = 0 @@ -249,16 +248,16 @@ self.__sql.commit() # }}} - # dump SQLite in self.__table def dumpSQLite(self): #{{{ + """dump SQLite in self.__table""" # quite easy, eh? :-) self.__table = self.findPassword("%",output='noID') #}}} - # find a password in SQLite - # patterns: list of strings (filter) def findPassword(self,patterns,output='table'): #{{{ + """Function helps you to find a password in SQLite Database + patterns: list of strings (filter)""" cursor = self.__sql.cursor() if not patterns: @@ -298,25 +297,24 @@ return result #}}} - # clear the data in the self.__table Dictionary def flushPasswordsPlain(self): #{{{ + """Clears the data in the self.__table Dictionary""" for collumns in self.__table: self.__table[collumns] = [] #}}} - # add a new entry - # entry: dictionary like self.__table def addEntry(self, entry, commit=True): # {{{ + """adds a new entry to passfile + entry: new entry dictionary""" cursor = self.__sql.cursor() insertValues = '' for collumns in self.__table: entry[collumns] = re.sub(r'\'','\'\'', entry[collumns]) insertValues += "'" + entry[collumns] + "'," - insertValues = re.sub(r',$',r'', insertValues) - try: + try: cursor.execute(self.__insertStatement + insertValues + ')') except sqlite3.OperationalError: #DEBUG print "addEntry" @@ -329,9 +327,9 @@ # }}} - # delete an entry - # patterns: list of strings def delEntry(self,patterns=0,id=-1): #{{{ + """Deletes an Entry + patterns: list of strings""" cursor = self.__sql.cursor() if (id < 0 ): @@ -342,8 +340,8 @@ cursor.execute(query) #}}} - # internal to build the WHERE def __buildWhere(self,patterns): # {{{ + """internal function to build the SQL WHERE Statement""" count = 0 query = '(' for filter in patterns: @@ -358,26 +356,34 @@ return query #}}} - # return a list of used collumns def getCollumns(self): # {{{ + """return a list of collumns in passfile""" return self.__table.keys() # }}} - # add a collumn FIXME def addCollumn(self,name): # {{{ - pass + """add a collumn to passfile + name: name of new collumn""" + cursor = self.__sql.cursor() + + query = "ALTER TABLE passwords ADD `" + name + "` TEXT" + + cursor.execute(query) + + self.__sql.commit() + # }}} - # delete a collumn FIXME def delCollumn(self,name): # {{{ + """deletes a collumn + name: name of the collumn to delete""" pass # }}} - # rename a collumn FIXME def renameCollumn(self,oldname,newname): # {{{ pass + # }}} - # }}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tre...@us...> - 2010-05-25 17:01:36
|
Revision: 289 http://spd.svn.sourceforge.net/spd/?rev=289&view=rev Author: treibholz Date: 2010-05-25 17:01:30 +0000 (Tue, 25 May 2010) Log Message: ----------- fixed broken MultiUser-Support.... DOH!!! Modified Paths: -------------- trunk/src/spdCore.py Modified: trunk/src/spdCore.py =================================================================== --- trunk/src/spdCore.py 2010-04-11 14:53:16 UTC (rev 288) +++ trunk/src/spdCore.py 2010-05-25 17:01:30 UTC (rev 289) @@ -407,10 +407,15 @@ c = core.Context() c.set_armor(1) + # Get the first keys, it finds + RecipientKeys = [] for i in self.recipients: c.op_keylist_start(i,0) + RecipientKeys.append(c.op_keylist_next()) - c.op_encrypt([c.op_keylist_next()], 1, plain, cipher) + # encrypt with RecipientKeys + + c.op_encrypt(RecipientKeys, 1, plain, cipher) cipher.seek(0,0) f.write(cipher.read()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |