From: <Z3...@us...> - 2010-12-11 00:40:26
|
Revision: 321 http://spd.svn.sourceforge.net/spd/?rev=321&view=rev Author: Z3po Date: 2010-12-11 00:40:20 +0000 (Sat, 11 Dec 2010) Log Message: ----------- added ErrorHandler to Interface Class, added spd-cli to call interface, fixed function to add entries Modified Paths: -------------- branches/spd-ng/src/spdCLI.py branches/spd-ng/src/spdConfig.py branches/spd-ng/src/spdCore.py branches/spd-ng/src/spdInterface.py branches/spd-ng/src/test.db Modified: branches/spd-ng/src/spdCLI.py =================================================================== --- branches/spd-ng/src/spdCLI.py 2010-11-29 09:38:31 UTC (rev 320) +++ branches/spd-ng/src/spdCLI.py 2010-12-11 00:40:20 UTC (rev 321) @@ -6,14 +6,14 @@ """This is the Cli Module. Resistance is futile""" - output = "normal" + __outmode = None def printPasswords(self,passdict): # {{{ """Print the passwords out of a dictionary. # passdict: the dictionary full of passwords""" if type(passdict).__name__ != 'NoneType' and len(passdict) != 0: - if self.output == 'normal': + if self.__outmode == 'lines': length = 0 for key in passdict.keys(): if length < len(key): @@ -29,6 +29,8 @@ else: print key.ljust(length) + ': ' print "" + elif self.__outmode == 'wide': + print 'NOT YET IMPLEMENTED...SORRY' else: print "No Results found" # }}} @@ -42,7 +44,8 @@ return Entry # }}} - def parseArgs(self,version,columns): # {{{ + def parseArgs(self,version): # {{{ + __ouput="lines" parser = OptionParser( "%prog [Options] [Keywords]", description = "SPD - Simple Password Displayer - CLI", version = "SPD " + version, @@ -88,12 +91,12 @@ # default=False, # help = "print Password only of first match, usefull for piping (e.g. in rdesktop)") # - #parser.add_option( "-w", "--wide", - # action="store_true", - # dest = "widemode", - # default=False, - # help = "print output in wide mode (means as a table)") - # + parser.add_option( "-w", "--wide", + action="store_true", + dest = "widemode", + default=False, + help = "print output in wide mode (means as a table)") + #parser.add_option( "-l", "--local", # action="store_true", # dest = "localStore", @@ -107,13 +110,17 @@ (options, args) = parser.parse_args() if options.add: - Entry = self.createEntry(columns) - return ["addEntry", Entry] + return ["addEntry", args] elif options.delete: return ["deleteEntry", args] elif options.deleteID: return ["deleteID", args] + elif options.widemode: + self.__outmode = 'wide' + else: + self.__outmode = 'lines' + return ["printPasswords", args] # }}} Modified: branches/spd-ng/src/spdConfig.py =================================================================== --- branches/spd-ng/src/spdConfig.py 2010-11-29 09:38:31 UTC (rev 320) +++ branches/spd-ng/src/spdConfig.py 2010-12-11 00:40:20 UTC (rev 321) @@ -15,8 +15,9 @@ 32 : 'Section not found', 64 : 'Option not found' } - def __init__(self, conffile='~/.spd/config'): + def __init__(self, conffile='~/.spd/config'): # {{{ self.configfile = os.path.expanduser(conffile) + # }}} def __ErrorHandler(self,message): # {{{ """ErrorHandler of the Config Module. Modified: branches/spd-ng/src/spdCore.py =================================================================== --- branches/spd-ng/src/spdCore.py 2010-11-29 09:38:31 UTC (rev 320) +++ branches/spd-ng/src/spdCore.py 2010-12-11 00:40:20 UTC (rev 321) @@ -81,13 +81,15 @@ # }}} - def getColumns(self): # {{{ - + def getColumns(self,__showid=True): # {{{ + query = "pragma Table_info('" + self.ConfigSection + "')" self.dbc.execute(query) result = [] for i in self.dbc: + if not __showid and i['name'] == "__ID": + continue if i['name'] not in self.deletedColumns: result.append(i['name']) Modified: branches/spd-ng/src/spdInterface.py =================================================================== --- branches/spd-ng/src/spdInterface.py 2010-11-29 09:38:31 UTC (rev 320) +++ branches/spd-ng/src/spdInterface.py 2010-12-11 00:40:20 UTC (rev 321) @@ -34,6 +34,17 @@ self.core = spdCore.Core() # }}} + def __ErrorHandler(self,function,message): # {{{ + """ErrorHandler of the Interface Module. + # message: means the \'Exception\' to throw""" + print "################################################" + print "spdInterface ErrorHandler." + print "ERRORFUNCTION: " + function + print "ERRORMESSAGE: " + message + print "################################################" + exit(2) + # }}} + def findPasswords(self,searchString='%'): # {{{ """Find the passwords by searchlist/searchstring handed. print the results in CLIENTMODE. @@ -56,6 +67,8 @@ # }}} def deleteID(self,ids): # {{{ + if not ids: + self.__ErrorHandler('deleteID()','No ID to delete given') if type(ids).__name__ != 'list': if type(ids).__name__ == 'int': ids = str(ids) @@ -71,20 +84,18 @@ self.core.delEntry(id) # }}} - def addEntry(self,Entry): # {{{ + def addEntry(self, args): # {{{ + Entry = self.client.createEntry(self.core.getColumns(id=False)) self.core.addEntry(Entry) # }}} def main(self): # {{{ - function, value = self.client.parseArgs(self.version,self.core.getColumns()) + function, value = self.client.parseArgs(self.version) getattr(self, function)(value) # }}} # }}} -interface = Interface() -interface.main() - # EOF # vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3 Modified: branches/spd-ng/src/test.db =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |