Răsfoiți Sursa

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 ani în urmă
părinte
comite
9c53491347
4 a modificat fișierele cu 19 adăugiri și 31 ștergeri
  1. 7 6
      pwman/data/convertdb.py
  2. 6 2
      pwman/data/drivers/sqlite.py
  3. 2 2
      pwman/data/factory.py
  4. 4 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"))

+ 2 - 2
pwman/data/factory.py

@@ -31,7 +31,7 @@ db.open()
 .....
 """
 from pwman.data.database import DatabaseException
-from pwman.data.drivers import sqlite
+from pwman.data.drivers import sqlite, osqlite
 
 
 def check_db_version(type):
@@ -54,7 +54,7 @@ def create(type, version=None, filename=None):
         elif version == 0.4:
             db = sqlite.SQLiteDatabaseNewForm()
         else:
-            db = sqlite.SQLiteDatabase()
+            db = osqlite.SQLiteDatabase()
     elif type == "Postgresql":
         try:
             from pwman.data.drivers import postgresql

+ 4 - 21
pwman/ui/ocli.py

@@ -544,30 +544,13 @@ class PwmanCliOld(cmd.Cmd, HelpUI, BaseUI):
         """
         _dbwarning = "\n*** WARNNING: You are using the old database format" \
             + " which is unsecure." \
-            + " It's highly recommended to switch 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 " \
+            + " 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, _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):