From: <Z3...@us...> - 2009-09-08 20:42:44
|
Revision: 273 http://spd.svn.sourceforge.net/spd/?rev=273&view=rev Author: Z3po Date: 2009-09-08 20:42:34 +0000 (Tue, 08 Sep 2009) Log Message: ----------- added possibility to not give any keywords (backwards compatible?) Modified Paths: -------------- trunk/src/spdCLI.py trunk/src/spdCore.py Added Paths: ----------- trunk/src/spd-cli Removed Paths: ------------- trunk/src/spd Deleted: trunk/src/spd =================================================================== --- trunk/src/spd 2009-09-07 18:43:16 UTC (rev 272) +++ trunk/src/spd 2009-09-08 20:42:34 UTC (rev 273) @@ -1,80 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2009 Klaus Umbach {{{ -# <tre...@us...> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# }}} - -import sys -import spdCore -import spdCLI -from optparse import OptionParser - -# {{{ OptionParser stuff -parser = OptionParser( "%prog [Optionen] Search", - description = "SPD - Simple Password Displayer", - version = "0.3-alpha", - epilog = "With no parameters it will print out nothing!") - -parser.add_option( "-d", "--delete", - dest ="delete", - help ="Entry to delete") - -parser.add_option( "-a", "--add", - action="store_true", - dest = "add", - default=False, - help = "Add an Entry") - -parser.add_option( "-p", "--password-only", - dest = "pwonly", - help = "print Password only of first match, usefull for piping (e.g. in rdesktop)") - - - -(options, args) = parser.parse_args() -# }}} - -pc = spdCore.PasswordContainer('~/.spd/config') - -interface = spdCLI.cli() - -# check if it is a search or not. - -if options.add: - pc.addEntry(interface.newEntry(pc.getCollumns())) - pc.exportPasswordsPlain() - -elif options.delete: - searchPatterns = sys.argv - del searchPatterns[0] - del searchPatterns[0] - pc.delEntry(searchPatterns) - pc.exportPasswordsPlain() - -elif options.pwonly: - searchPatterns = sys.argv - del searchPatterns[0] - del searchPatterns[0] - print pc.findPassword(searchPatterns)[pc.passwordField][0] - -else: # regular search - searchPatterns = sys.argv - del searchPatterns[0] - interface.listOutput(pc.findPassword(searchPatterns)) - - -# EOF -# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3 Copied: trunk/src/spd-cli (from rev 272, trunk/src/spd) =================================================================== --- trunk/src/spd-cli (rev 0) +++ trunk/src/spd-cli 2009-09-08 20:42:34 UTC (rev 273) @@ -0,0 +1,94 @@ +#!/usr/bin/python +# Copyright (C) 2009 Klaus Umbach {{{ +# <tre...@us...> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# }}} + +import sys +import spdCore +import spdCLI +from optparse import OptionParser + +# {{{ OptionParser stuff +parser = OptionParser( "%prog [Optionen] Search", + description = "SPD - Simple Password Displayer", + version = "0.3-alpha", + epilog = "With no parameters it will print out nothing!") + +parser.add_option( "-d", "--delete", + dest ="delete", + help ="Entry to delete") + +parser.add_option( "-a", "--add", + action="store_true", + dest = "add", + default=False, + help = "Add an Entry") + +parser.add_option( "-p", "--password-only", + action="store_true", + dest = "pwonly", + 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)") + + + +(options, args) = parser.parse_args() +# }}} + +pc = spdCore.PasswordContainer('~/.spd/config') + +interface = spdCLI.cli() + +# check if it is a search or not. + +if options.add: + pc.addEntry(interface.newEntry(pc.getCollumns())) + pc.exportPasswordsPlain() + +elif options.delete: + searchPatterns = sys.argv + del searchPatterns[0] + del searchPatterns[0] + pc.delEntry(searchPatterns) + pc.exportPasswordsPlain() + +elif options.pwonly: + searchPatterns = sys.argv + del searchPatterns[0] + del searchPatterns[0] + print pc.findPassword(searchPatterns)[pc.passwordField][0] + +#elif options.widemode: +# searchPatterns = sys.argv +# del searchPatterns[0] +# interface.tableOutput(pc.findPassword(searchPatterns)) + + +else: # regular search + searchPatterns = sys.argv + del searchPatterns[0] + interface.listOutput(pc.findPassword(searchPatterns)) + + +# EOF +# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3 Modified: trunk/src/spdCLI.py =================================================================== --- trunk/src/spdCLI.py 2009-09-07 18:43:16 UTC (rev 272) +++ trunk/src/spdCLI.py 2009-09-08 20:42:34 UTC (rev 273) @@ -1,29 +1,6 @@ import sys import platform -from optparse import OptionParser -# {{{ OptionParser stuff -def CreateParser(): - - parser = OptionParser( "%prog [Optionen] Search", - description = "SPD - Simple Password Displayer", - version = "0.3-alpha", - epilog = "With no parameters it will print out nothing!") - - parser.add_option( "-d", "--delete", - dest ="delete", - help ="Entry to delete") - - parser.add_option( "-a", "--add", - action="store_true", - dest = "add", - default=False, - help = "Add an Entry") - - return parser -# }}} - - class cli(object): def __init__(self): # {{{ Modified: trunk/src/spdCore.py =================================================================== --- trunk/src/spdCore.py 2009-09-07 18:43:16 UTC (rev 272) +++ trunk/src/spdCore.py 2009-09-08 20:42:34 UTC (rev 273) @@ -149,7 +149,7 @@ for j in collumns: try: self.__table[j].append(line[collumnCount]) - + except IndexError: # Debug print j print collumnCount @@ -269,6 +269,9 @@ # patterns: list of strings (filter) def findPassword(self,patterns,output='table'): #{{{ cursor = self.__sql.cursor() + + if not patterns: + patterns='%' # create the query count = 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |