فهرست منبع

add xsel to copy passwords to X clipboard

oz123 12 سال پیش
والد
کامیت
67c6a789f8

+ 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

+ 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>
 #============================================================================
 

+ 8 - 1
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,11 @@ 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
+try:
+    from pysqlite2 import dbapi2 as sqlite
+except ImportError:
+    raise DatabaseException("python-sqlite2 not installed")
+
 import pwman.util.config as config
 import cPickle
 

+ 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>
 #============================================================================
 

+ 49 - 3
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>
 #============================================================================
 
@@ -36,6 +38,7 @@ import cmd
 import traceback
 import time
 import select as uselect
+import subprocess as sp
 
 if sys.platform != 'win32':
     import tty
@@ -83,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)
@@ -211,7 +215,7 @@ class PwmanCli(cmd.Cmd):
         
         if sys.platform != 'win32':
             print "Type Enter to flush screen (autoflash in 5 sec.)"
-            waituntil_enter(heardEnter(), 5)
+            waituntil_enter(heardEnter, 5)
         else:
             print "Press any key to flush screen (autoflash in 5 sec.)"
             waituntil_enter(heardEnterWin, 5) 
@@ -402,6 +406,7 @@ 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)
@@ -442,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)
 
@@ -501,12 +507,40 @@ class PwmanCli(cmd.Cmd):
     
     def do_cls(self,args):
         os.system('clear')
+
+    def do_copy(self,args):
+        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)
+
+
+    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."
@@ -733,7 +767,19 @@ 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":
+    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) 
+
 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>
 #============================================================================
 

+ 3 - 0
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>
 #============================================================================
 

+ 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>
 #============================================================================
 

+ 2 - 2
scripts/pwman3

@@ -39,7 +39,7 @@ 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])
     
 try:
@@ -49,7 +49,7 @@ try:
     
     config_file = os.path.join(config_dir, "config")
     
-    default_config = {'Global': {'umask': '0077', 'colors' : 'yes'},
+    default_config = {'Global': {'umask': '0100', 'colors' : 'yes', 'xclip': 'yes'},
                       'Database':{'type':'SQLite',
                                   'filename':os.path.join(config_dir, "pwman.db")},
                       'Encryption':{'algorithm': 'Blowfish'},