From: <Z3...@us...> - 2011-02-04 16:16:54
|
Revision: 333 http://spd.svn.sourceforge.net/spd/?rev=333&view=rev Author: Z3po Date: 2011-02-04 16:16:47 +0000 (Fri, 04 Feb 2011) Log Message: ----------- Bugfixes for bugs caused by change of parameter transmission Modified Paths: -------------- branches/spd-ng/src/spdCLI.py branches/spd-ng/src/spdConfig.py branches/spd-ng/src/spdCore.py branches/spd-ng/src/spdDefaults.py branches/spd-ng/src/spdInterface.py Modified: branches/spd-ng/src/spdCLI.py =================================================================== --- branches/spd-ng/src/spdCLI.py 2011-01-17 22:35:35 UTC (rev 332) +++ branches/spd-ng/src/spdCLI.py 2011-02-04 16:16:47 UTC (rev 333) @@ -1,15 +1,18 @@ #!/usr/bin/python from optparse import OptionParser, OptionGroup -import sys -import re +from sys import stdout +from re import sub +__version__ = '0.3-alpha' + + class Cli(object): # {{{ """This is the Cli Module. Resistance is futile""" - __outmode = None - __version = '0.3-alpha' + __version__ = '0.3-alpha' + _passwordfield = 'Password' def __ErrorHandler(self,function,message): # {{{ """ErrorHandler of the Client Module. @@ -38,7 +41,7 @@ if len(passdict['__ID']) > 1: self.__ErrorHandler('printPasswords', 'pwonly selected but more than one result returned') else: - print passdict['Password'][0] # FIXME!! + print passdict[self._passwordfield][0] elif self.__outmode == 'line': length = 0 @@ -52,7 +55,7 @@ if key == '__ID': continue if type(passdict[key][i]).__name__ != 'NoneType': - print key.ljust(length) + ': ' + re.sub('\n','\n ' + ' '.ljust(length),passdict[key][i]) + print key.ljust(length) + ': ' + sub('\n','\n ' + ' '.ljust(length),passdict[key][i]) else: print key.ljust(length) + ': ' print "" @@ -68,8 +71,8 @@ __keylength[key] = len(str(value)) for key in passdict: - sys.stdout.write(key.ljust(__keylength[key]) + '|') - sys.stdout.write('\n') + stdout.write(key.ljust(__keylength[key]) + '|') + stdout.write('\n') __entries = len(passdict.values()[0]) @@ -81,11 +84,11 @@ __count = 0 for line in str(passdict[key][i]).split('\n'): if __count > 0: - sys.stdout.write('\n' + __space) - sys.stdout.write(line.ljust(__keylength[key]) + '|') + stdout.write('\n' + __space) + stdout.write(line.ljust(__keylength[key]) + '|') __count += 1 __space = __space + ''.ljust(__keylength[key]) + ' ' - sys.stdout.write('\n') + stdout.write('\n') else: self.__ErrorHandler('printPasswords', 'output mode unknown') else: @@ -134,7 +137,7 @@ parser = OptionParser( "%prog [Options] [Keywords]", description = "SPD - Simple Password Displayer - CLI", version = """spdCore """ + version + - """\nspdCLI """ + self.__version, + """\nspdCLI """ + self.__version__, epilog = """With no parameters it will print out everything! Please report Bugs or Feature Request at http://spd.sourceforge.net""") Modified: branches/spd-ng/src/spdConfig.py =================================================================== --- branches/spd-ng/src/spdConfig.py 2011-01-17 22:35:35 UTC (rev 332) +++ branches/spd-ng/src/spdConfig.py 2011-02-04 16:16:47 UTC (rev 333) @@ -2,8 +2,10 @@ from ConfigParser import RawConfigParser import os -import sys +#import sys +__version__ = '0.3-alpha' + class Config(object): # {{{ '''This is the Configuration Module You can read or set config options''' @@ -28,7 +30,7 @@ print "Configfile: " + self.__configfile print "ERRORMESSAGE: " + message print "################################################" - sys.exit(2) + exit(2) # }}} def __checkConfigFileExist(self): # {{{ @@ -124,18 +126,6 @@ return 0 # }}} - def __listSections(self): # {{{ - """Return all sections from configfile.""" - - reval, config = self.__checkConfigFileReadable() - - if reval > 0: - return reval, None - - return 0, config.sections() - - # }}} - def __delSection(self,section): # {{{ """delete a Section from configfile. # section: the section to delete.""" @@ -215,6 +205,21 @@ # }}} + def getSections(self, raw=False): # {{{ + """Return all sections from configfile.""" + + reval, config = self.__checkConfigFileReadable() + + if reval > 0: + self.__ErrorHandler(self.ReturnCodes[reval]) + + if raw: + return 0, config.sections() + + return config.sections() + + # }}} + def addConfigSection(self,section): # {{{ reval = self.__addSection(section) @@ -284,6 +289,37 @@ self.__ErrorHandler(self.ReturnCodes[reval]) # }}} + def getPasswordfield(self, raw=False): # {{{ + '''get the clientmode. + # return the Password Column''' + + reval, clientmode = self.__getOption('Main', 'passwordfield') + + if reval > 0 and reval < 64: + self.__ErrorHandler(self.ReturnCodes[reval]) + + if reval > 0: + if raw: + return reval, None + else: + self.__ErrorHandler(self.ReturnCodes[reval]) + + if raw: + return reval, clientmode + + return clientmode + # }}} + + def setPasswordfield(self,passcolumn): # {{{ + """set the Password Column. + # passcolumn: passcolumn to set.""" + + reval = self.__setOption("Main","passwordfield",passcolumn) + + if reval > 0: + self.__ErrorHandler(self.ReturnCodes[reval]) + # }}} + # }}} # EOF Modified: branches/spd-ng/src/spdCore.py =================================================================== --- branches/spd-ng/src/spdCore.py 2011-01-17 22:35:35 UTC (rev 332) +++ branches/spd-ng/src/spdCore.py 2011-02-04 16:16:47 UTC (rev 333) @@ -7,7 +7,10 @@ import sqlite3 import re +#import spdConfig +__version__ = '0.3-alpha' + class Core(object): # create the database from the stuff out of the store Modified: branches/spd-ng/src/spdDefaults.py =================================================================== --- branches/spd-ng/src/spdDefaults.py 2011-01-17 22:35:35 UTC (rev 332) +++ branches/spd-ng/src/spdDefaults.py 2011-02-04 16:16:47 UTC (rev 333) @@ -1,9 +1,11 @@ """This is the Defaults Configuration Module Trying to create the defaults""" -import spdConfig +#import spdConfig import os +__version__ = '0.3-alpha' + def __ErrorHandler(function, message): # {{{ '''ErrorHandler of the Defaults Module. # function: the function who called the ErrorHandler @@ -13,7 +15,7 @@ print 'ERRORFUNCTION: ' + function print 'ERRORMESSAGE: ' + message print '################################################' - sys.exit(2) + exit(2) # }}} def __oldSPDCheck(): # {{{ @@ -43,6 +45,7 @@ config.addConfigSection('Main') config.setConfigVersion('0.3-alpha') config.setClientmode('CLI') + config.setPasswordfield('Password') __input = raw_input('Done. Back to normal. [ENTER]') # }}} Modified: branches/spd-ng/src/spdInterface.py =================================================================== --- branches/spd-ng/src/spdInterface.py 2011-01-17 22:35:35 UTC (rev 332) +++ branches/spd-ng/src/spdInterface.py 2011-02-04 16:16:47 UTC (rev 333) @@ -23,6 +23,8 @@ print 'spd not installed. Missing Modules.' exit(2) +__version__ = '0.3-alpha' + class Interface(object): # {{{ """The Interface Module. Interface between client and Core.""" @@ -41,8 +43,6 @@ if not clientmode: clientmode = initcheck['clientmode'] - del initcheck - try: __tempclient = __import__('spd' + clientmode) except ImportError: @@ -51,6 +51,11 @@ self.__client = __tempclient.Cli() del __tempclient + if 'passwordfield' in initcheck: + self.__client._passwordfield = initcheck['passwordfield'] + + del initcheck + self.__core = spdCore.Core(ConfigSection='Main') # }}} @@ -67,6 +72,7 @@ def __startupCheck(self): # {{{ """Do initial checks""" + __initargs = {} if not os.access(self.__spddir, os.F_OK): try: @@ -76,28 +82,31 @@ __config = spdConfig.Config() - reval, __version = __config.getConfigVersion(raw=True) + reval, __initargs['version'] = __config.getConfigVersion(raw=True) if reval > 0 and reval < 64: spdDefaults.createDefaultConfig(__config) return self.__startupCheck() - elif reval == 64: print 'ConfigVersion not found...setting Default one\n' __input = raw_input('Press any key') __config.setConfigVersion('0.3-alpha') - __version = __config.getConfigVersion() + __initargs.update({ 'version' : __config.getConfigVersion() }) - reval, clientmode = __config.getClientmode(raw=True) + reval, __initargs['clientmode'] = __config.getClientmode(raw=True) if reval > 0: print 'Clientmode not found...setting it to CLI\n' __input = raw_input('Press any key') __config.setClientmode('CLI') - clientmode = __config.getClientmode() + __initargs.update({ 'clientmode' : __config.getClientmode() }) - return({ 'version' : __version, - 'clientmode' : clientmode }) + reval, __passwordfield = __config.getPasswordfield(raw=True) + + if reval == 0: + __initargs.update({ 'passwordfield' : __passwordfield }) + + return(__initargs) # }}} def __findPasswords(self,args): # {{{ @@ -148,7 +157,7 @@ __newpassdict = self.__client.editEntry(__passdict) self.__core.editEntry(__newpassdict) else: - self.__ErrorHandler('editEntry','no matches for ' + str(args[1]) + 'found') + self.__ErrorHandler('editEntry','no matches for ' + str(args["args"]) + 'found') # }}} def deleteColumn(self,args): # {{{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |