oz123 11 жил өмнө
parent
commit
f78286eff1
1 өөрчлөгдсөн 24 нэмэгдсэн , 22 устгасан
  1. 24 22
      pwman/ui/cli.py

+ 24 - 22
pwman/ui/cli.py

@@ -130,7 +130,7 @@ class PwmanCli(cmd.Cmd):
         numerics -> numerics
         numerics -> numerics
         leetify -> symbols
         leetify -> symbols
         special_chars -> special_signs
         special_chars -> special_signs
-        """        
+        """
         if argsgiven == 1:
         if argsgiven == 1:
             length = getinput("Password length (default 7): ", "7")
             length = getinput("Password length (default 7): ", "7")
             length = int(length)
             length = int(length)
@@ -144,13 +144,13 @@ class PwmanCli(cmd.Cmd):
         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)
-        
+
             (password, dumpme) = generator.generate_password(length, length, \
             (password, dumpme) = generator.generate_password(length, length, \
                 True, leetify, numerics, special_signs)
                 True, leetify, numerics, special_signs)
             print "New password: %s" % (password)
             print "New password: %s" % (password)
-        
+
         return password
         return password
-        
+
     def get_url(self, default=""):
     def get_url(self, default=""):
         return getinput("Url: ", default)
         return getinput("Url: ", default)
 
 
@@ -230,7 +230,7 @@ class PwmanCli(cmd.Cmd):
                     break
                     break
                 time.sleep(period)
                 time.sleep(period)
             self.do_cls('')
             self.do_cls('')
-        
+
         flushtimeout = int(config.get_value("Global", "cls_timeout"))
         flushtimeout = int(config.get_value("Global", "cls_timeout"))
         if flushtimeout > 0:
         if flushtimeout > 0:
             if sys.platform != 'win32':
             if sys.platform != 'win32':
@@ -401,8 +401,8 @@ class PwmanCli(cmd.Cmd):
             else:
             else:
                 numerics = config.get_value("Generator", "numerics").lower() == 'true'
                 numerics = config.get_value("Generator", "numerics").lower() == 'true'
                 # TODO: allow custom leetifying through the config
                 # TODO: allow custom leetifying through the config
-                leetify = config.get_value("Generator", "leetify").lower() == 'true' 
-                special_chars = config.get_value("Generator", "special_chars").lower() == 'true' 
+                leetify = config.get_value("Generator", "leetify").lower() == 'true'
+                special_chars = config.get_value("Generator", "special_chars").lower() == 'true'
                 password = self.get_password(0,
                 password = self.get_password(0,
                                              numerics=numerics,
                                              numerics=numerics,
                                              symbols=leetify,
                                              symbols=leetify,
@@ -659,8 +659,8 @@ class PwmanCli(cmd.Cmd):
 
 
     def help_new(self):
     def help_new(self):
         self.usage("new")
         self.usage("new")
-        print """Creates a new node., 
-You can override default config settings the following way:      
+        print """Creates a new node.,
+You can override default config settings the following way:
 pwman> n {'leetify':False, 'numerics':True}"""
 pwman> n {'leetify':False, 'numerics':True}"""
 
 
     def help_rm(self):
     def help_rm(self):
@@ -717,9 +717,11 @@ pwman> n {'leetify':False, 'numerics':True}"""
         initialize CLI interface, set up the DB
         initialize CLI interface, set up the DB
         connecion, see if we have xsel ...
         connecion, see if we have xsel ...
         """
         """
+        _dbwarning = "\n*** WARNNING: You are using the old db format which" \
+                     + " uses cPickle, please upgrade your db !!! ***"
         cmd.Cmd.__init__(self)
         cmd.Cmd.__init__(self)
-        self.intro = "%s %s (c) visit: %s" % (pwman.appname, pwman.version,
-                                            pwman.website)
+        self.intro = "%s %s (c) visit: %s %s" % (pwman.appname, pwman.version,
+                                                 pwman.website, _dbwarning)
         self._historyfile = config.get_value("Readline", "history")
         self._historyfile = config.get_value("Readline", "history")
         self.hasxsel = hasxsel
         self.hasxsel = hasxsel
         try:
         try:
@@ -745,7 +747,7 @@ class PwmanCliNew(PwmanCli):
     all the methods related to tags, and
     all the methods related to tags, and
     newer Node format, so backward compatability is kept...
     newer Node format, so backward compatability is kept...
     """
     """
-    
+
     def print_node(self, node):
     def print_node(self, node):
         width = str(_defaultwidth)
         width = str(_defaultwidth)
         print "Node %d." % (node.get_id())
         print "Node %d." % (node.get_id())
@@ -796,7 +798,7 @@ class PwmanCliNew(PwmanCli):
             else:
             else:
                 print "Press any key to flush screen (autoflash in 5 sec.)"
                 print "Press any key to flush screen (autoflash in 5 sec.)"
                 waituntil_enter(heardEnterWin, flushtimeout)
                 waituntil_enter(heardEnterWin, flushtimeout)
-                
+
     def do_tags(self, arg):
     def do_tags(self, arg):
         tags = self._db.listtags()
         tags = self._db.listtags()
         if len(tags) > 0:
         if len(tags) > 0:
@@ -910,8 +912,8 @@ class PwmanCliNew(PwmanCli):
             else:
             else:
                 numerics = config.get_value("Generator", "numerics").lower() == 'true'
                 numerics = config.get_value("Generator", "numerics").lower() == 'true'
                 # TODO: allow custom leetifying through the config
                 # TODO: allow custom leetifying through the config
-                leetify = config.get_value("Generator", "leetify").lower() == 'true' 
-                special_chars = config.get_value("Generator", "special_chars").lower() == 'true' 
+                leetify = config.get_value("Generator", "leetify").lower() == 'true'
+                special_chars = config.get_value("Generator", "special_chars").lower() == 'true'
                 password = self.get_password(0,
                 password = self.get_password(0,
                                              numerics=numerics,
                                              numerics=numerics,
                                              symbols=leetify,
                                              symbols=leetify,
@@ -935,8 +937,8 @@ class PwmanCliNew(PwmanCli):
                 zerome(node[0]._password)
                 zerome(node[0]._password)
             except Exception, e:
             except Exception, e:
                 self.error(e)
                 self.error(e)
-                
-                
+
+
 class PwmanCliMac(PwmanCli):
 class PwmanCliMac(PwmanCli):
     """
     """
     inherit from PwmanCli, override the right functions...
     inherit from PwmanCli, override the right functions...
@@ -994,7 +996,7 @@ class PwmanCliMac(PwmanCli):
 
 
 class PwmanCliMacNew(PwmanCliMac):
 class PwmanCliMacNew(PwmanCliMac):
     pass
     pass
-    
+
 _defaultwidth = 10
 _defaultwidth = 10
 
 
 def getonechar(question, width=_defaultwidth):
 def getonechar(question, width=_defaultwidth):
@@ -1041,7 +1043,7 @@ def getinput(question, default="", completer=None, width=_defaultwidth):
     if (not _readline_available):
     if (not _readline_available):
         return raw_input(question.ljust(width))
         return raw_input(question.ljust(width))
     else:
     else:
-        def defaulter(): 
+        def defaulter():
             """define default behavior startup"""
             """define default behavior startup"""
             readline.insert_text(default)
             readline.insert_text(default)
 
 
@@ -1169,15 +1171,15 @@ class CliMenu(object):
                 # substract 1 because array subscripts start at 0
                 # substract 1 because array subscripts start at 0
                 selection = int(option) - 1
                 selection = int(option) - 1
                 print "selection, ", selection
                 print "selection, ", selection
-                # new value is created by calling the editor with the 
-                # previous value as a parameter 
+                # new value is created by calling the editor with the
+                # previous value as a parameter
                 # TODO: enable overriding password policy as if new node
                 # TODO: enable overriding password policy as if new node
                 # is created.
                 # is created.
                 if selection == 1: # for password
                 if selection == 1: # for password
                     value = self.items[selection].editor(0)
                     value = self.items[selection].editor(0)
                 else:
                 else:
                     value = self.items[selection].editor(self.items[selection].getter())
                     value = self.items[selection].editor(self.items[selection].getter())
-                
+
                 self.items[selection].setter(value)
                 self.items[selection].setter(value)
             except (ValueError, IndexError):
             except (ValueError, IndexError):
                 if (option.upper() == 'X'):
                 if (option.upper() == 'X'):