|
From: <Z3...@us...> - 2011-06-28 21:24:42
|
Revision: 338
http://spd.svn.sourceforge.net/spd/?rev=338&view=rev
Author: Z3po
Date: 2011-06-28 21:24:35 +0000 (Tue, 28 Jun 2011)
Log Message:
-----------
minor cleanup
Modified Paths:
--------------
branches/spd-ng/src/Interfaces/cli.py
branches/spd-ng/src/spdConfig.py
branches/spd-ng/src/spdCore.py
branches/spd-ng/src/spdInterface.py
branches/spd-ng/src/spdStore/__init__.py
Modified: branches/spd-ng/src/Interfaces/cli.py
===================================================================
--- branches/spd-ng/src/Interfaces/cli.py 2011-06-28 20:24:22 UTC (rev 337)
+++ branches/spd-ng/src/Interfaces/cli.py 2011-06-28 21:24:35 UTC (rev 338)
@@ -9,7 +9,7 @@
from re import sub, search
__version__ = '0.3-alpha'
-_passwordfield = 'Password'
+passwordfield = 'Password'
def __ErrorHandler(function,message): # {{{
"""ErrorHandler of the Client Module.
@@ -40,7 +40,7 @@
if len(passdict['__ID']) > 1:
__ErrorHandler('printPasswords', 'pwonly selected but more than one result returned')
else:
- print passdict[_passwordfield][0]
+ print passdict[passwordfield][0]
elif __outmode == 'line':
length = 0
@@ -153,13 +153,17 @@
return Entry
# }}}
-def parseArgs(version): # {{{
+def parseArgs(versions): # {{{
__optionsdict = {}
parser = OptionParser( "%prog [Options] [Keywords]",
description = "SPD - Simple Password Displayer - CLI",
- version = """spdCore """ + version +
- """\nspdCLI """ + __version__,
+ version = """spdCore """ + versions['spdCore'] +
+ """\nspdInterface """ + versions['spdInterface'] +
+ """\nspdConfig """ + versions['spdConfig'] +
+ """\nspdDefaults """ + versions['spdDefaults'] +
+ """\nConfigFile """ + versions['ConfigFile'] +
+ """\nCLI """ + __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-06-28 20:24:22 UTC (rev 337)
+++ branches/spd-ng/src/spdConfig.py 2011-06-28 21:24:35 UTC (rev 338)
@@ -10,6 +10,7 @@
'''This is the Configuration Module
You can read or set config options'''
__configfile = None
+ ConfigSection = 'Main'
ReturnCodes = { 2 : 'Missing ConfigFile',
4 : 'ConfigFile not Readable',
@@ -323,4 +324,4 @@
# }}}
# EOF
-# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3
+# vim:foldmethod=marker:tabstop=3:autoindent:noexpandtab:shiftwidth=3
Modified: branches/spd-ng/src/spdCore.py
===================================================================
--- branches/spd-ng/src/spdCore.py 2011-06-28 20:24:22 UTC (rev 337)
+++ branches/spd-ng/src/spdCore.py 2011-06-28 21:24:35 UTC (rev 338)
@@ -17,9 +17,9 @@
class Core(object):
# create the database from the stuff out of the store
- def __init__(self,ConfigSection='Main',PasswordColumn='Password'): # {{{
- self.ConfigSection = ConfigSection
- self.PasswordColumn = PasswordColumn
+ def __init__(self,ConfigObject): # {{{
+ self.ConfigSection = ConfigObject.ConfigSection
+ self.PasswordColumn = ConfigObject.getPasswordfield()
self.db = sqlite3.connect('test.db')
self.db.row_factory = self.__sql2dict
self.dbc = self.db.cursor()
Modified: branches/spd-ng/src/spdInterface.py
===================================================================
--- branches/spd-ng/src/spdInterface.py 2011-06-28 20:24:22 UTC (rev 337)
+++ branches/spd-ng/src/spdInterface.py 2011-06-28 21:24:35 UTC (rev 338)
@@ -9,8 +9,8 @@
or force a clientmode with:
Interface = spdInterface.Interface('CLI')
-if building your own interface, name it spd"whatever" and pass "whatever"
-to the Interface Class. The Module must be in pythons include path.'''
+if building your own interface, name it "whatever" and pass "whatever"
+to the Interface Class. The Module must be in spds Interfaces path.'''
from sys import exit
import os
@@ -31,17 +31,46 @@
"""The Interface Module.
Interface between client and Core."""
__spddir = os.path.expanduser('~/.spd/')
- __version = None
__client = None
__core = None
def __init__(self,clientmode=False): # {{{
"""init procedure"""
+ initcheck = {}
- initcheck = self.__startupCheck()
+ if not os.access(self.__spddir, os.F_OK):
+ try:
+ os.mkdir(self.__spddir)
+ except Exception, e:
+ self.__ErrorHandler('__init__','Could not create ' + self.__spddir + ' Exception: ' + str(e))
+
+ __config = spdConfig.Config()
- self.__version = initcheck['version']
+ reval, initcheck['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')
+ initcheck.update({ 'version' : __config.getConfigVersion() })
+ reval, initcheck['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')
+ initcheck.update({ 'clientmode' : __config.getClientmode() })
+
+ reval, __passwordfield = __config.getPasswordfield(raw=True)
+
+ if reval == 0:
+ initcheck.update({ 'passwordfield' : __passwordfield })
+
+
if not clientmode:
clientmode = initcheck['clientmode']
@@ -56,9 +85,16 @@
if 'passwordfield' in initcheck:
self.__client._passwordfield = initcheck['passwordfield']
+
+ self.__core = spdCore.Core(__config)
+
+ self.__version = { 'ConfigFile' : initcheck['version'],
+ 'spdCore' : spdCore.__version__,
+ 'spdInterface' : __version__,
+ 'spdDefaults' : spdDefaults.__version__,
+ 'spdConfig' : spdConfig.__version__ }
+
del initcheck
-
- self.__core = spdCore.Core(ConfigSection='Main')
# }}}
def __ErrorHandler(self,function,message): # {{{
@@ -72,45 +108,6 @@
exit(2)
# }}}
- def __startupCheck(self): # {{{
- """Do initial checks"""
- __initargs = {}
-
- if not os.access(self.__spddir, os.F_OK):
- try:
- os.mkdir(self.__spddir)
- except Exception, e:
- self.__ErrorHandler('__startupCheck','Could not create ' + self.__spddir + ' Exception: ' + str(e))
-
- __config = spdConfig.Config()
-
- 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')
- __initargs.update({ 'version' : __config.getConfigVersion() })
-
- 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')
- __initargs.update({ 'clientmode' : __config.getClientmode() })
-
- reval, __passwordfield = __config.getPasswordfield(raw=True)
-
- if reval == 0:
- __initargs.update({ 'passwordfield' : __passwordfield })
-
- return(__initargs)
- # }}}
-
def __findPasswords(self,args): # {{{
"""Find the passwords by searchlist/searchstring handed.
print the results in CLIENTMODE.
@@ -196,6 +193,10 @@
# }}}
+if __name__ == '__main__':
+ Iface = Interface()
+ Iface.main()
+
# EOF
# vim:foldmethod=marker:tabstop=3:autoindent:noexpandtab:shiftwidth=3
Modified: branches/spd-ng/src/spdStore/__init__.py
===================================================================
--- branches/spd-ng/src/spdStore/__init__.py 2011-06-28 20:24:22 UTC (rev 337)
+++ branches/spd-ng/src/spdStore/__init__.py 2011-06-28 21:24:35 UTC (rev 338)
@@ -1,10 +1,9 @@
'''spdStore Module
-This Module takes Care of the storage Engine used by SPD.
+This Modules takes Care of the storage Engine used by SPD.
Currently Implemented Storage Types are
- plain
-- gpg
-Call the Store() Class with supplying the used storage type'''
+- gpg'''
# EOF
# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|