ソースを参照

Disable CLI ui for old database format.

The user is notified he must upgrade

Fix the convertdb.py module

This has to comply with the NewNode format
oz123 11 年 前
コミット
286bd84b37
3 ファイル変更16 行追加29 行削除
  1. 7 6
      pwman/data/convertdb.py
  2. 6 2
      pwman/data/drivers/sqlite.py
  3. 3 21
      pwman/ui/ocli.py

+ 7 - 6
pwman/data/convertdb.py

@@ -89,12 +89,13 @@ class PwmanConvertDB(object):
             notes = node.get_notes()
             tags = node.get_tags()
             tags_strings = [tag.get_name() for tag in tags]
-            newNode = NewNode(username=username,
-                              password=password,
-                              url=url,
-                              notes=notes,
-                              tags=tags_strings
-                              )
+            newNode = NewNode()
+            newNode.username = username
+            newNode.password = password
+            newNode.url = url
+            newNode.notes = notes
+            tags = tags_strings
+            newNode.tags = tags
             self.NewNodes.append(newNode)
 
     def save_new_nodes_to_db(self):

+ 6 - 2
pwman/data/drivers/sqlite.py

@@ -47,12 +47,16 @@ def check_db_version():
 class SQLiteDatabaseNewForm(Database):
     """SQLite Database implementation"""
 
-    def __init__(self):
+    def __init__(self, filename=None):
         """Initialise SQLitePwmanDatabase instance."""
         Database.__init__(self)
         # error handling is implemented in config.get_value
         # so there's no need to try... except here...
-        self._filename = config.get_value('Database', 'filename')
+        if not filename:
+            self._filename = config.get_value('Database', 'filename')
+        else:
+            self._filename = filename
+
         if not self._filename:
             raise DatabaseException(("SQLite: missing config parameter:"
                                     " filename"))

+ 3 - 21
pwman/ui/ocli.py

@@ -544,31 +544,13 @@ class PwmanCliOld(cmd.Cmd, HelpUI, BaseUI):
         """
         self._dbwarning = "\n*** WARNNING: You are using the old database format" \
             + " which is unsecure." \
-            + " Please upgrade to the new database " \
-            + "format. Do note: support for this DB format will be dropped in"\
-            + " v0.5. This  database format is in hold. No bugs are fixed. Please " \
+            + " This  database format is in hold. No bugs are fixed. Please " \
             + " upgrade your database." \
             + " Check the help (pwman3 -h) or look at the manpage which" \
             + " explains how to proceed. ***"
 
-        cmd.Cmd.__init__(self)
-        self.intro = "%s %s (c) visit: %s %s" % (pwman.appname, pwman.version,
-                                                 pwman.website, self._dbwarning)
-        self._historyfile = config.get_value("Readline", "history")
-        self.hasxsel = hasxsel
-        try:
-            enc = CryptoEngine.get()
-            enc.set_callback(CLICallback())
-            self._db = db
-            #  self._db.open()
-        except Exception, e:
-            self.error(e)
-            sys.exit(1)
-        try:
-            readline.read_history_file(self._historyfile)
-        except IOError, e:
-            pass
-        self.prompt = "!pwman> "
+        print (_dbwarning)
+        sys.exit(1)
 
 
 class BaseCommands(PwmanCliOld):