From: <Z3...@us...> - 2010-12-24 14:33:30
|
Revision: 323 http://spd.svn.sourceforge.net/spd/?rev=323&view=rev Author: Z3po Date: 2010-12-24 14:33:23 +0000 (Fri, 24 Dec 2010) Log Message: ----------- removed spdCheck and added spdDefaults module. bugfix for --add function in spd. changed loading of clientmode to be more dynamic. Checks are now done in the module itself. Modified Paths: -------------- branches/spd-ng/src/spdCore.py branches/spd-ng/src/spdInterface.py branches/spd-ng/src/test.db Added Paths: ----------- branches/spd-ng/src/spdDefaults.py Removed Paths: ------------- branches/spd-ng/src/spdCheck.py Deleted: branches/spd-ng/src/spdCheck.py =================================================================== --- branches/spd-ng/src/spdCheck.py 2010-12-24 00:16:30 UTC (rev 322) +++ branches/spd-ng/src/spdCheck.py 2010-12-24 14:33:23 UTC (rev 323) @@ -1,85 +0,0 @@ -#!/usr/bin/python - -import spdConfig -import os - -class Check(object): # {{{ - """This is the initcheck Configuration Module - Checks if everything is there to perform :)""" - - spddir = os.path.expanduser('~/.spd/') - config = spdConfig.Config() - - def __init__(self,module): # {{{ - """Do the initial checks. - # module: which module called me??""" - - self.module = 'spdInterface' - # }}} - - def __ErrorHandler(self, message): # {{{ - '''ErrorHandler of the Check Module. - # message: means the \'Exception\' to throw''' - print '################################################' - print 'spdCheck ErrorHandler.' - print 'ERRORMESSAGE: ' + message - print '################################################' - sys.exit(2) - # }}} - - def __oldSPDCheck(self): # {{{ - __oldspdconfig = '~/.spd/spd.conf' - if os.access(os.path.expanduser(__oldspdconfig), os.R_OK): - print 'old config found' - - # }}} - - def __createDefaultConfig(self,config): # {{{ - """Create the default config here. - # config: the configparser to use""" - - config.addConfigSection('Main') - config.setConfigVersion('0.3-alpha') - config.setClientmode('CLI') - # }}} - - - def startupCheck(self): # {{{ - """Do initial checks""" - - if self.module == 'spdInterface': - - if not os.access(self.spddir, os.F_OK): - os.mkdir(spddir) - - config = self.config - - reval, version = config.getConfigVersion(raw=True) - - if reval > 0 and reval < 64: - self.__oldSPDCheck() - self.__createDefaultConfig(config) - return self.startupCheck() - - elif reval == 64: - print 'ConfigVersion not found...setting Default one\n' - config.setConfigVersion('0.3-alpha') - version = config.getConfigVersion() - - reval, clientmode = config.getClientmode(raw=True) - - if reval > 0: - config.setClientmode('CLI') - clientmode = config.getClientmode() - - return({ 'version' : version, - 'clientmode' : clientmode }) - else: - return True - - # }}} - -# }}} - -# EOF -# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3 Modified: branches/spd-ng/src/spdCore.py =================================================================== --- branches/spd-ng/src/spdCore.py 2010-12-24 00:16:30 UTC (rev 322) +++ branches/spd-ng/src/spdCore.py 2010-12-24 14:33:23 UTC (rev 323) @@ -81,14 +81,14 @@ # }}} - def getColumns(self,__showid=True): # {{{ + 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": + if not showid and i['name'] == "__ID": continue if i['name'] not in self.deletedColumns: result.append(i['name']) Copied: branches/spd-ng/src/spdDefaults.py (from rev 322, branches/spd-ng/src/spdCheck.py) =================================================================== --- branches/spd-ng/src/spdDefaults.py (rev 0) +++ branches/spd-ng/src/spdDefaults.py 2010-12-24 14:33:23 UTC (rev 323) @@ -0,0 +1,43 @@ +#!/usr/bin/python + +import spdConfig +import os + +class Defaults(object): # {{{ + """This is the Defaults Configuration Module + Trying to create the defaults""" + + spddir = os.path.expanduser('~/.spd/') + + def __ErrorHandler(self, function, message): # {{{ + '''ErrorHandler of the Defaults Module. + # function: the function who called the ErrorHandler + # message: means the \'Exception\' to throw''' + print '################################################' + print 'spdDefaults ErrorHandler.' + print 'ERRORFUNCTION: ' + function + print 'ERRORMESSAGE: ' + message + print '################################################' + sys.exit(2) + # }}} + + def __oldSPDCheck(self): # {{{ + __oldspdconfig = '~/.spd/spd.conf' + if os.access(os.path.expanduser(__oldspdconfig), os.R_OK): + print 'old config found' + # }}} + + def createDefaultConfig(self,config): # {{{ + """Create the default config here. + # config: the configparser to use""" + + self.__oldSPDCheck() + config.addConfigSection('Main') + config.setConfigVersion('0.3-alpha') + config.setClientmode('CLI') + # }}} + +# }}} + +# EOF +# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3 Modified: branches/spd-ng/src/spdInterface.py =================================================================== --- branches/spd-ng/src/spdInterface.py 2010-12-24 00:16:30 UTC (rev 322) +++ branches/spd-ng/src/spdInterface.py 2010-12-24 14:33:23 UTC (rev 323) @@ -1,6 +1,8 @@ #!/usr/bin/python -import spdCheck +import spdConfig +import spdDefaults +import os import spdCore import string from sys import exit @@ -8,6 +10,8 @@ class Interface(object): # {{{ """The Interface Module. Connection between Output and Core.""" + spddir = os.path.expanduser('~/.spd/') + config = spdConfig.Config() version = None client = None core = None @@ -15,8 +19,7 @@ def __init__(self,clientmode=False): # {{{ """init procedure""" - check = spdCheck.Check("spdInterface") - initcheck = check.startupCheck() + initcheck = self.__startupCheck() self.version = initcheck['version'] if not clientmode: @@ -24,12 +27,14 @@ del initcheck - if clientmode == 'CLI': - import spdCLI - self.client = spdCLI.Cli() + try: + __client = __import__('spd' + clientmode) + except ImportError: + print 'clientmode \"' + clientmode + '\" not available' + exit(2) else: - print 'CLIENTMODE \'not yet\' available' - exit(2) + self.client = __client.Cli() + del __client self.core = spdCore.Core() # }}} @@ -45,6 +50,37 @@ exit(2) # }}} + def __startupCheck(self): # {{{ + """Do initial checks""" + + if not os.access(self.spddir, os.F_OK): + os.mkdir(spddir) + + config = self.config + + reval, version = config.getConfigVersion(raw=True) + + if reval > 0 and reval < 64: + Defaults = spdDefaults.Defaults() + Defaults.createDefaultConfig(config) + return self.__startupCheck() + + elif reval == 64: + print 'ConfigVersion not found...setting Default one\n' + config.setConfigVersion('0.3-alpha') + version = config.getConfigVersion() + + reval, clientmode = config.getClientmode(raw=True) + + if reval > 0: + print 'Clientmode not found...setting it to CLI\n' + config.setClientmode('CLI') + clientmode = config.getClientmode() + + return({ 'version' : version, + 'clientmode' : clientmode }) + # }}} + def findPasswords(self,searchString='%'): # {{{ """Find the passwords by searchlist/searchstring handed. print the results in CLIENTMODE. @@ -85,7 +121,7 @@ # }}} def addEntry(self, args): # {{{ - Entry = self.client.createEntry(self.core.getColumns(id=False)) + Entry = self.client.createEntry(self.core.getColumns(showid=False)) self.core.addEntry(Entry) # }}} 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. |