Browse Source

Merge pull request #2 from oz123/master

I addeded a little function to clear the screen
Oz 12 years ago
parent
commit
e3f2437434

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2012-10-06 Oz Nahum <nahumoz@gmail.com>
+	* pwman/__init__.py: Version 0.1.0
+	* pwman/ui/cli.py: Added copy of password to clipboard.
+    * pwman/ui/cli.py: Added autoflushing of printed output.
+
 2009-09-06 Ivan Kelly <ivan@ivankelly.net>
 	* pwman/__init__.py: Version 0.0.8
 	

+ 3 - 3
PKG-INFO

@@ -1,9 +1,9 @@
 Metadata-Version: 1.0
 Name: Pwman3
 Summary: Pwman is a password management application.
-Home-page: http://pwman.bleurgh.com/
-Author: Ivan Kelly
-Author-email: pwman@bleurgh.com
+Home-page: https://github.com/oz123/pwman3
+Author: Oz Nahum
+Author-email: nahumoz@gmail.com
 License: GNU GPL
 Description: UNKNOWN
 Platform: UNKNOWN

+ 1 - 1
README

@@ -4,7 +4,7 @@ Pwman3 requires the following debian packages:
 	python-pysqlite2
 	python-celementtree
 	python-crypto
-
+    xsel - to copy password to clipboard on Linux
 To install:
 
 $ python setup.py install

+ 13 - 0
debian/README.source

@@ -0,0 +1,13 @@
+incron for Debian
+-----------------
+
+This package uses quilt to manage all modifications to the upstream
+source. Changes are stored in the source package as diffs in
+debian/patches and applied during the build. Please see:
+
+    /usr/share/doc/quilt/README.source
+
+for more information on how to apply the patches, modify patches, or
+remove a patch.
+
+ -- Emmanuel Bouthenot <kolter@openics.org>, Wed, 23 Sep 2009 21:08:26 +0000

+ 103 - 0
debian/changelog

@@ -0,0 +1,103 @@
+pwman3 (0.1.0-1) UNRELEASED; urgency=low
+  
+  * Bump version Number.
+  * Incorporate many new patched.
+  * Add copying to clipboard.
+  * Update git urls.
+            
+ -- Oz Nahum <nahumoz@gmail.com>  Sun, 07 Oct 2012 07:09:57 +0200
+
+pwman3 (0.0.8-1) unstable; urgency=low
+
+  * New upstream release:
+    - a patch for a better output in list mode (detection of the
+    number of columns and rows used by the terminal) has been merged
+    upstream. Thanks to Dominic Hargreaves for the suggestion (Closes: #594928).
+  * Remove uselsess build dependency on python-dev.
+  * Update Standards-Version to 3.9.1.
+  * Update uploader email.
+  * Update Vcs-Browser and Vcs-Git fields.
+  * Switch to dpkg-source 3.0 (quilt) format.
+  * Remove unneeded DMUA field.
+  * Update copyright file (new year changes, new copyright holders).
+  * Add a patch to fix the filter command when used with the sqlite backend.
+    Thanks to Guillaume L. for the patch (Closes: #605513).
+  * Remove unused lintian override.
+
+ -- Emmanuel Bouthenot <kolter@debian.org>  Sun, 05 Sep 2010 17:09:52 +0200
+
+pwman3 (0.0.7-2) unstable; urgency=low
+
+  * Add a patch to drop dependency on python-pysqlite2 and use internal
+    sqlite provided by python >= 2.5. Thanks to Éric Araujo for his
+    suggestion (Closes: #546693).
+  * Add Recommends and Suggests regarding the others storage drivers
+    available.
+  * Clean and minify debian/rules.
+  * Add file README.source.
+  * Bump Standards-Version to 3.8.3.
+  * Add a lintian override about missing upstream changelog.
+
+ -- Emmanuel Bouthenot <kolter@openics.org>  Thu, 24 Sep 2009 20:20:11 +0000
+
+pwman3 (0.0.7-1) unstable; urgency=low
+
+  * New upstream release (Closes: #512766, #512768)
+  * Remove patches fix_celementtree_python25, fix_help_eof and
+    fix_disable_node_password_echo (fixed upstream).
+  * Update watch file: the source code is now hosted on github.
+  * Remove quilt from Build-Depends.
+  * Add Vcs-Browser and Vcs-Git fields in debian/control.
+  * Bump Standards-Version to 3.8.0.
+  * Update debian packaging to debhelper 7 and add debian/manpages.
+  * Update debian/control, add ${misc:Depends} and Build-Depends-Indep.
+  * Update debian/copyright about debian packaging.
+  * Add DM-Upload-Allowed field.
+
+ -- Emmanuel Bouthenot <kolter@openics.org>  Sat, 21 Feb 2009 12:07:47 +0100
+
+pwman3 (0.0.6-2) unstable; urgency=low
+
+  * Setting me as maintainer with previous maintainer agreement.
+  * Add quilt to Build-Depends.
+  * Remove the binary-arch target from debian/rules (arch all package).
+  * Add a patch to make pwman3 working with python 2.5 (Closes: #478684)
+  * Add dependency on python2.5-celementtree (provided by python2.5).
+  * Add a patch to fix a bug on 'help EOF'.
+  * Fix debian/copyright to point GPL-2 rather than just GPL, which
+    now points to GPL-3.
+  * Update Standards-Version to 3.7.3.
+  * Add a Homepage field.
+
+ -- Emmanuel Bouthenot <kolter@openics.org>  Sat, 31 May 2008 00:50:34 +0200
+
+pwman3 (0.0.6-1) unstable; urgency=low
+
+  * New Upstream Version
+  * Remove quilt from Build-Depends
+  * Drop mask_passwd_input patch. A little different fixe for
+    #407985 has been included upstream.
+
+ -- Julien Louis <ptitlouis@sysif.net>  Sat, 17 Feb 2007 16:00:02 +0100
+
+pwman3 (0.0.5-3) unstable; urgency=low 
+
+  * Fix typo in short description (Closes: #400577).
+  * Added quilt to Build-Depends.
+  * Added mask_password_input patch (Closes: #407985).
+
+ -- Julien Louis <ptitlouis@sysif.net>  Mon, 29 Jan 2007 10:39:18 +0100
+
+pwman3 (0.0.5-2) unstable; urgency=low
+
+  * Description improvement (Closes: #400577)
+  * Added missing manpage.
+
+ -- Julien Louis <ptitlouis@sysif.net>  Thu, 30 Nov 2006 10:33:40 +0100
+
+pwman3 (0.0.5-1) unstable; urgency=low
+
+  * Initial release (closes: #388673).
+
+ -- Julien Louis <ptitlouis@sysif.net>  Thu, 21 Sep 2006 09:00:23 +0200
+

+ 1 - 0
debian/compat

@@ -0,0 +1 @@
+7

+ 24 - 0
debian/control

@@ -0,0 +1,24 @@
+Source: pwman3
+Section: utils
+Priority: optional
+Maintainer: Oz Nahum <nahumoz@gmail.com>
+Build-Depends-Indep: python-support (>= 0.4)
+Build-Depends: debhelper (>= 7.0.50)
+Standards-Version: 3.9.3
+Homepage: http://pwman.bleurgh.com
+Vcs-Git: https://github.com/oz123/pwman3.git
+Vcs-Browser: https://github.com/oz123/pwman3.git
+
+Package: pwman3
+Architecture: all
+Depends: ${python:Depends}, ${misc:Depends}, python-crypto
+Recommends: python-mysqldb, python-pygresql, xsel
+Suggests: mysql-server | postgresql
+Description: console password management application
+ Pwman3 aims to provide a simple but powerful command line interface for
+ password management. It allows one to store passwords in a sqlite database
+ locked by a master password which can be encrypted with different algorithms
+ (e.g Blowfish, AES, DES3).
+ .
+ It is also possible to tag them to ease searches in a large amount of
+ passwords

+ 38 - 0
debian/copyright

@@ -0,0 +1,38 @@
+This package was debianized by Julien Louis <ptitlouis@sysif.net> on
+Wed, 20 Sep 2006 01:48:22 +0200.
+
+It was downloaded from http://github.com/ivankelly/pwman3/
+
+Upstream Author: Ivan Kelly <ivan@ivankelly.net>
+
+  Copyright (C) 2006-2011 Ivan Kelly <ivan@ivankelly.net>
+    - main developer
+  Copyright (C) 2009 Tero Tilus <tero@tilus.net>
+    - CLI improvements
+  Copyright (C) 2009 IKEGAMI Hiroyuki <ikegam@mixallow.net>
+    - new password generation options
+  Copyright (C) 2010 Emmanuel Bouthenot <kolter@openics.org>
+    - display improvements
+
+License:
+
+   This package 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 package 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 package; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+On Debian systems, the complete text of the GNU General
+Public License version 2 can be found in `/usr/share/common-licenses/GPL-2'.
+
+Debian packaging (licenced under the GPLv2) :
+  Copyright(C) 2006-2007 Julien Louis <ptitlouis@sysif.net>
+  Copyright(C) 2008-2011 Emmanuel Bouthenot <kolter@openics.org>

+ 1 - 0
debian/docs

@@ -0,0 +1 @@
+README

+ 1 - 0
debian/files

@@ -0,0 +1 @@
+pwman3_0.1.0-1_all.deb utils optional

+ 1 - 0
debian/manpages

@@ -0,0 +1 @@
+debian/pwman3.1

+ 32 - 0
debian/pwman3.1

@@ -0,0 +1,32 @@
+.TH PWMAN3 1 "30 November 2006"
+.SH NAME
+pwman3 \- command line password manager
+.SH SYNOPSIS
+
+\fBpwman3\fP [\fIoptions\fP]
+
+.SH DESCRIPTION
+
+.TP
+\fB\-c, \-\-config\fP FILE
+Read the configuration from \fBFILE\fP instead of the default
+\fB~/.pwman3/config\fP.
+
+.TP
+\fB\-d, \-\-database\fP FILE
+When using the default sqlite backend, use \fBFILE\fP to read/store passwords.
+
+.TP
+\fB\-e, \-\-encryption\fP ALGO
+Use \fBALGO\fP to encrypt data. Possible values are: AES, ARC2, ARC4, Blowfish,
+CAST, DES, DES3, IDEA, RC5
+The default encryption algorithm used is Blowfish.
+
+.TP
+\fB\-h, \-\-help\fP
+Display help and exit.
+
+.SH AUTHOR
+
+This manpage has been written by Julien Louis <ptitlouis@sysif.net> for the Debian
+GNU/Linux system but may be used by the others.

+ 1 - 0
debian/pyversions

@@ -0,0 +1 @@
+2.5-

+ 18 - 0
debian/rules

@@ -0,0 +1,18 @@
+#!/usr/bin/make -f
+
+dh_auto_build:
+	python setup.py build
+	dh_build
+
+dh_auto_install:
+	python setup.py install --root=$(CURDIR)/debian/pwman3
+	dh_install
+
+dh_auto_clean:
+	-rm -rf build
+	python setup.py clean
+	find . -name *.pyc | xargs rm -f
+	dh_clean
+
+%:
+	dh $@

+ 1 - 0
debian/source/format

@@ -0,0 +1 @@
+3.0 (quilt)

+ 2 - 0
debian/watch

@@ -0,0 +1,2 @@
+version=3
+http://githubredir.debian.net/github/ivankelly/pwman3/v(.*).tar.gz

+ 6 - 4
pwman/__init__.py

@@ -14,14 +14,16 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 
 appname = "Pwman3"
-version = "0.0.8"
-website = "http://github.com/ivankelly/pwman3"
-author = "Ivan Kelly"
-authoremail = "pwman@bleurgh.com"
+version = "0.1.0"
+website = "http://github.com/oz123/pwman3"
+author = "Oz Nahum"
+authoremail = "nahumoz@gmail.com"
 description = "Pwman is a password management application."
 keywords = "password management sqlite crypto"
 

+ 3 - 0
pwman/data/database.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 3 - 0
pwman/data/drivers/mysql.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 3 - 0
pwman/data/drivers/postgresql.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 14 - 3
pwman/data/drivers/sqlite.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 
@@ -22,7 +25,15 @@ from pwman.data.database import Database, DatabaseException
 from pwman.data.nodes import Node
 from pwman.data.tags import Tag
 
-from pysqlite2 import dbapi2 as sqlite
+import sys
+if sys.version_info > (2, 5):
+    import sqlite3 as sqlite
+else:
+    try:
+        from pysqlite2 import dbapi2 as sqlite
+    except ImportError:
+        raise DatabaseException("python-sqlite2 not installed")
+
 import pwman.util.config as config
 import cPickle
 
@@ -67,7 +78,7 @@ class SQLiteDatabase(Database):
                 else:
                     first = False
                     
-                sql += ("SELECT NODE FROM LOOKUP OUTER JOIN TAGS ON TAG = TAGS.ID "
+                sql += ("SELECT NODE FROM LOOKUP LEFT JOIN TAGS ON TAG = TAGS.ID "
                         + " WHERE TAGS.DATA = ?")
                 params.append(cPickle.dumps(t))
             sql += ") EXCEPT SELECT DATA FROM TAGS WHERE "
@@ -164,7 +175,7 @@ class SQLiteDatabase(Database):
                     sql += " INTERSECT "
                 else:
                     first = False
-                sql += ("SELECT NODE FROM LOOKUP OUTER JOIN TAGS ON TAG = TAGS.ID"
+                sql += ("SELECT NODE FROM LOOKUP LEFT JOIN TAGS ON TAG = TAGS.ID"
                         + " WHERE TAGS.DATA = ? ")
 
                 params.append(cPickle.dumps(t))

+ 3 - 0
pwman/data/factory.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 3 - 0
pwman/data/nodes.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 3 - 0
pwman/data/tags.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 3 - 0
pwman/exchange/exporter.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 3 - 0
pwman/exchange/importer.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 122 - 23
pwman/ui/cli.py

@@ -14,6 +14,8 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 
@@ -23,22 +25,25 @@ import pwman.exchange.exporter as exporter
 import pwman.util.generator as generator
 from pwman.data.nodes import Node
 from pwman.data.tags import Tag
-
 from pwman.util.crypto import CryptoEngine, CryptoBadKeyException, \
      CryptoPasswordMismatchException
 from pwman.util.callback import Callback
 import pwman.util.config as config
-
 import re
 import sys
-import tty
 import os
 import struct
-import termios
-import fcntl
 import getpass
 import cmd
 import traceback
+import time
+import select as uselect
+import subprocess as sp
+
+if sys.platform != 'win32':
+    import tty
+    import termios
+    import fcntl
 
 try:
     import readline
@@ -81,6 +86,7 @@ class PwmanCli(cmd.Cmd):
     def do_exit(self, args):
         print
         try:
+            print "goodbye"
             self._db.close()
         except Exception, e:
             self.error(e)
@@ -111,14 +117,16 @@ class PwmanCli(cmd.Cmd):
         return getinput("Username: ", default)
 
     def get_password(self, default=""):
-        password = getpassword("Password (Blank to generate): ", _defaultwidth, False)
+        password = getpassword("Password (Blank to generate): ", _defaultwidth,\
+            False)
         if len(password) == 0:
             length = getinput("Password length (default 7): ", "7")
             length = int(length)
 
-            numerics = config.get_value("Generator", "numerics") == 'true';
-            leetify = config.get_value("Generator", "leetify") == 'true';
-            (password, dumpme) = generator.generate_password(length, length, True, leetify, numerics)
+            numerics = config.get_value("Generator", "numerics") == 'true'
+            leetify = config.get_value("Generator", "leetify") == 'true'
+            (password, dumpme) = generator.generate_password(length, length, \
+                True, leetify, numerics)
 
             print "New password: %s" % (password)
             return password
@@ -179,6 +187,39 @@ class PwmanCli(cmd.Cmd):
             print "%s " % t.get_name(),
         print
 
+        def heardEnter():
+            i,o,e = uselect.select([sys.stdin],[],[],0.0001)
+            for s in i:
+                if s == sys.stdin:
+                    input = sys.stdin.readline()
+                    return True
+                return False
+
+        def heardEnterWin():
+            import msvcrt
+            c = msvcrt.kbhit()
+            if c == 1:
+                ret = msvcrt.getch()
+                if ret is not None:
+                    return True
+            return False
+        
+        def waituntil_enter(somepredicate,timeout, period=0.25):
+            mustend = time.time() + timeout
+            while time.time() < mustend:
+                cond = somepredicate()
+                if cond:
+                    break
+                time.sleep(period)
+            self.do_cls('')
+        
+        if sys.platform != 'win32':
+            print "Type Enter to flush screen (autoflash in 5 sec.)"
+            waituntil_enter(heardEnter, 5)
+        else:
+            print "Press any key to flush screen (autoflash in 5 sec.)"
+            waituntil_enter(heardEnterWin, 5) 
+
     def do_tags(self, arg):
         tags = self._db.listtags()
         if len(tags) > 0:
@@ -190,6 +231,7 @@ class PwmanCli(cmd.Cmd):
             print "%s " % (t.get_name()),
         print
 
+
     def complete_filter(self, text, line, begidx, endidx):
         strings = []
         enc = CryptoEngine.get()
@@ -345,17 +387,17 @@ class PwmanCli(cmd.Cmd):
         self.do_delete(arg)
         
     def do_delete(self, arg):
-         ids = self.get_ids(arg)
-         try:
-             nodes = self._db.getnodes(ids)
-             for n in nodes:
-                 b = getyesno("Are you sure you want to delete '%s@%s'?"
+        ids = self.get_ids(arg)
+        try:
+            nodes = self._db.getnodes(ids)
+            for n in nodes:
+                b = getyesno("Are you sure you want to delete '%s@%s'?"
                               % (n.get_username(), n.get_url()), False)
-                 if b == True:
-                     self._db.removenodes([n])
-                     print "%s@%s deleted" % (n.get_username(), n.get_url())
-         except Exception, e:
-             self.error(e)
+                if b == True:
+                    self._db.removenodes([n])
+                    print "%s@%s deleted" % (n.get_username(), n.get_url())
+        except Exception, e:
+            self.error(e)
 
     def do_l(self, args):
         self.do_list(args)
@@ -364,11 +406,15 @@ class PwmanCli(cmd.Cmd):
         self.do_list(args)
         
     def do_list(self, args):
+        
         if len(args.split()) > 0:
             self.do_clear('')
             self.do_filter(args)
         try:
-            rows, cols = gettermsize()
+            if sys.platform != 'win32':
+                rows, cols = gettermsize()
+            else:
+                rows,cols = 18, 80 # fix this !
             nodeids = self._db.listnodes()
             nodes = self._db.getnodes(nodeids)
             cols -= 8
@@ -401,6 +447,7 @@ class PwmanCli(cmd.Cmd):
                     c = getonechar("Press <Space> for more, or 'Q' to cancel")
                     if c == 'q':
                         break
+        
         except Exception, e:
             self.error(e)
 
@@ -458,12 +505,47 @@ class PwmanCli(cmd.Cmd):
         except Exception, e:
             self.error(e)
     
+    def do_cls(self,args):
+        os.system('clear')
+
+    def do_copy(self,args):
+        if self.hasxsel:
+            ids= self.get_ids(args)
+            if len(ids) > 1:
+                print "Can only 1 password at a time..."
+            try:
+                node = self._db.getnodes(ids)
+                node[0].get_password()
+                text_to_clipboards(node[0].get_password())
+                print """copied password for %s@%s clipboard... erasing in 10 sec...""" %\
+                (node[0].get_username(), node[0].get_url()) 
+                time.sleep(10)
+                text_to_clipboards("")
+            except Exception, e:
+                self.error(e)
+        else:
+            print "Can't copy to clipboard, no xsel found in the system!"
+
+    def do_cp(self,args):
+        self.do_copy(args)
+        
     ##
     ## Help functions
     ##
     def usage(self, string):
         print "Usage: %s" % (string)
-        
+   
+    def help_copy(self):
+        self.usage("copy <ID>")
+        print "Copy password to X clipboard (xsel required)"
+
+    def help_cp(self):
+        self.help_copy()
+
+    def help_cls(self):
+        self.usage("cls")
+        print "Clear the Screen from information."
+
     def help_ls(self):
         self.help_list()
         
@@ -568,12 +650,12 @@ class PwmanCli(cmd.Cmd):
         except Exception, e:
             pass
     
-    def __init__(self, db):
+    def __init__(self, db, hasxsel):
         cmd.Cmd.__init__(self)
         self.intro = "%s %s (c) %s <%s>" % (pwman.appname, pwman.version,
                                             pwman.author, pwman.authoremail)
         self._historyfile = config.get_value("Readline", "history")
-
+        self.hasxsel = hasxsel
         try:
             enc = CryptoEngine.get()
             enc.set_callback(CLICallback())
@@ -686,7 +768,24 @@ def select(question, possible):
         input = getonechar(question)
         if input.isdigit() and int(input) in range(1, len(possible)+1):
             return possible[int(input)-1]
+
+def text_to_clipboards(text):
+    """
+    credit:
+    https://pythonadventures.wordpress.com/tag/xclip/
+    """
+    # "primary":
+    try:
+        xsel_proc = sp.Popen(['xsel', '-pi'], stdin=sp.PIPE)
+        xsel_proc.communicate(text)
+        # "clipboard":
+        xsel_proc = sp.Popen(['xsel', '-bi'], stdin=sp.PIPE)
+        xsel_proc.communicate(text) 
+    except OSError, e:
+        print e, "\nExecuting xsel failed, is it installed ?"
         
+        
+
 class CliMenu(object):
     def __init__(self):
         self.items = []

+ 3 - 0
pwman/util/callback.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 5 - 3
pwman/util/config.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 
@@ -58,7 +61,6 @@ def get_value(section, name):
         value = _defaults[section][name]
         set_value(section, name, value)
         return value
-    
     except KeyError, e:
         pass
     
@@ -80,13 +82,13 @@ def load(filename):
     global _conf, _file
 
     _file = filename
-    
+        
     parser = ConfigParser()
 
     fp = None
     try:
         try:
-            fp = file(filename, "r")
+            fp = open(filename, "r")
             res = parser.readfp(fp)
         except ParsingError,e:
             raise ConfigException(e)

+ 3 - 0
pwman/util/crypto.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 3 - 0
pwman/util/generator.py

@@ -14,6 +14,9 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
+# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+#============================================================================
+#============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 

+ 27 - 9
scripts/pwman3

@@ -17,7 +17,6 @@
 #============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
-
 from pwman.util.crypto import CryptoEngine
 from pwman.ui.cli import PwmanCli
 import pwman.util.config as config
@@ -25,7 +24,7 @@ import pwman.data.factory
 import getopt,sys
 import os
 import os.path
-
+import subprocess as sp
 _saveconfig = True
 
 def print_help():
@@ -39,9 +38,23 @@ def print_help():
                          CAST, DES, DES3, IDEA, RC5
  -h, --help             Display this help and exit
 
-Please report bugs at http://pwman.bleurgh.com
+Please report bugs at https://github.com/oz124/pwman3
 """ % (sys.argv[0])
-    
+
+
+def find_xsel():
+    """
+    look for xsel in the system
+    """
+    try:
+        print "inside"
+        xsel_proc = sp.Popen(['which', 'xsel'], stdin=sp.PIPE, stdout=sp.PIPE)
+        path, err = xsel_proc.communicate()
+        return path
+    except OSError, e:
+        print e, "\nExecuting xsel failed, is it installed ?"
+        return None
+
 try:
     config_dir = os.path.expanduser("~/.pwman")
     if not os.path.isdir(config_dir):
@@ -49,7 +62,7 @@ try:
     
     config_file = os.path.join(config_dir, "config")
     
-    default_config = {'Global': {'umask': '0077', 'colors' : 'yes'},
+    default_config = {'Global': {'umask': '0100', 'colors' : 'yes'},
                       'Database':{'type':'SQLite',
                                   'filename':os.path.join(config_dir, "pwman.db")},
                       'Encryption':{'algorithm': 'Blowfish'},
@@ -67,10 +80,14 @@ try:
         if o[0] == '-h' or o[0] == "--help":
             print_help()
             sys.exit(0)
-
+    # if no config exists yet, look for xsel
     if os.path.exists(config_file):
         config.load(config_file)
-        
+        xselpath=config.get_value("Global","xselpath")
+    else:
+        xselpath=find_xsel()
+        set_value("Global", "xsel", xselpath)     
+
     for o in opts:
         if o[0] == '-d' or o[0] == "--database":
             config.set_value("Database", "filename",
@@ -79,7 +96,8 @@ try:
         if o[0] == '-e' or o[0] == "--encryption":
             config.set_value("Encryption", "algorithm", o[1])
             _saveconfig=False
-
+    
+        
     # set umask before creating/opening any files
     umask = int(config.get_value("Global", "umask"))
     os.umask(umask)
@@ -88,7 +106,7 @@ try:
 
     type = config.get_value("Database", "type")
     db = pwman.data.factory.create(type)
-    cli = PwmanCli(db)
+    cli = PwmanCli(db, xselpath)
 except SystemExit, e:
     sys.exit(e)
 except Exception, e: