Преглед изворни кода

Added patches that usually go in debian package. Removed echo on password input

Ivan Kelly пре 16 година
родитељ
комит
9ade926668
4 измењених фајлова са 23 додато и 10 уклоњено
  1. 5 1
      pwman/exchange/exporter.py
  2. 5 1
      pwman/exchange/importer.py
  3. 12 7
      pwman/ui/cli.py
  4. 1 1
      scripts/pwman3

+ 5 - 1
pwman/exchange/exporter.py

@@ -17,7 +17,11 @@
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 #============================================================================
 
 
-from cElementTree import Element, SubElement, dump, ElementTree
+try:
+    from xml.etree.cElementTree import Element, SubElement, dump, ElementTree
+except ImportError:
+    from cElementTree import Element, SubElement, dump, ElementTree
+
 from pwman.data.nodes import Node
 from pwman.data.nodes import Node
 from pwman.data.tags import Tag
 from pwman.data.tags import Tag
 
 

+ 5 - 1
pwman/exchange/importer.py

@@ -17,7 +17,11 @@
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
 #============================================================================
 
 
-import cElementTree as ET
+try:
+    import xml.etree.cElementTree as ET
+except ImportError:
+    import cElementTree as ET
+
 from pwman.data.nodes import Node
 from pwman.data.nodes import Node
 from pwman.data.tags import Tag
 from pwman.data.tags import Tag
 
 

+ 12 - 7
pwman/ui/cli.py

@@ -103,7 +103,7 @@ class PwmanCli(cmd.Cmd):
         return getinput("Username: ", default)
         return getinput("Username: ", default)
 
 
     def get_password(self, default=""):
     def get_password(self, default=""):
-        password = getpassword("Password (Blank to generate): ", _defaultwidth, True)
+        password = getpassword("Password (Blank to generate): ", _defaultwidth, False)
         if len(password) == 0:
         if len(password) == 0:
             length = getinput("Password length (default 7): ", "7")
             length = getinput("Password length (default 7): ", "7")
             length = int(length)
             length = int(length)
@@ -438,7 +438,7 @@ class PwmanCli(cmd.Cmd):
         print "List nodes that match current filter. ls is an alias."
         print "List nodes that match current filter. ls is an alias."
 
 
     def help_EOF(self):
     def help_EOF(self):
-        self.help_quit()
+        self.help_exit()
 
 
     def help_delete(self):
     def help_delete(self):
         self.usage("delete <ID> ...")
         self.usage("delete <ID> ...")
@@ -538,14 +538,11 @@ class PwmanCli(cmd.Cmd):
             readline.read_history_file(self._historyfile)
             readline.read_history_file(self._historyfile)
         except Exception, e:
         except Exception, e:
             pass
             pass
-        
-        _colors = True
 
 
         self.prompt = "pwman> "
         self.prompt = "pwman> "
 
 
 
 
 _defaultwidth = 10
 _defaultwidth = 10
-_colors = True
 
 
 def getonechar(question, width=_defaultwidth):
 def getonechar(question, width=_defaultwidth):
     question = "%s " % (question)
     question = "%s " % (question)
@@ -601,10 +598,18 @@ def getpassword(question, width=_defaultwidth, echo=False):
         print question.ljust(width),
         print question.ljust(width),
         return sys.stdin.readline().rstrip()
         return sys.stdin.readline().rstrip()
     else:
     else:
-        return getpass.getpass(question.ljust(width))
+        
+        while 1:
+            a1 = getpass.getpass(question.ljust(width))
+            a2 = getpass.getpass("[Repeat] %s" % (question.ljust(width)))
+            if a1 == a2:
+                return a1
+            else:
+                print "Passwords don't match. Try again."
+        
         
         
 def typeset(text, color, bold=False, underline=False):
 def typeset(text, color, bold=False, underline=False):
-    if (not _colors):
+    if not config.get_value("Global", "colors") == 'yes':
         return text
         return text
     if (bold):
     if (bold):
         bold = "%d;" %(ANSI.Bold)
         bold = "%d;" %(ANSI.Bold)

+ 1 - 1
scripts/pwman3

@@ -49,7 +49,7 @@ try:
     
     
     config_file = os.path.join(config_dir, "config")
     config_file = os.path.join(config_dir, "config")
     
     
-    default_config = {'Global': {'umask': '0077'},
+    default_config = {'Global': {'umask': '0077', 'colors' : 'yes'},
                       'Database':{'type':'SQLite',
                       'Database':{'type':'SQLite',
                                   'filename':os.path.join(config_dir, "pwman.db")},
                                   'filename':os.path.join(config_dir, "pwman.db")},
                       'Encryption':{'algorithm': 'Blowfish'},
                       'Encryption':{'algorithm': 'Blowfish'},