Browse Source

Better logic when copying nodes

oz123 10 years ago
parent
commit
20ab4b15a3
3 changed files with 12 additions and 11 deletions
  1. 2 1
      pwman/ui/baseui.py
  2. 5 5
      pwman/ui/mac.py
  3. 5 5
      pwman/ui/win.py

+ 2 - 1
pwman/ui/baseui.py

@@ -221,9 +221,10 @@ class BaseCommands(HelpUIMixin, AliasesMixin):
             print("Can copy only 1 password at a time...")
             return
 
+        ce = CryptoEngine.get()
         nodes = self._db.getnodes(ids)
+
         for node in nodes:
-            ce = CryptoEngine.get()
             password = ce.decrypt(node[2])
             tools.text_to_clipboards(password)
             print("erasing in 10 sec...")

+ 5 - 5
pwman/ui/mac.py

@@ -39,16 +39,16 @@ class PwmanCliMac(PwmanCli):
         if len(ids) > 1:
             print("Can only 1 password at a time...")
             return None
-        try:
-            node = self._db.getnodes(ids)
-            ce = CryptoEngine.get()
+
+        nodes = self._db.getnodes(ids)
+        ce = CryptoEngine.get()
+
+        for node in nodes:
             password = ce.decrypt(node[2])
             tools.text_to_clipboards(password)
             print("erasing in 10 sec...")
             time.sleep(10)  # TODO: this should be configurable!
             tools.text_to_clipboards("")
-        except Exception as e:
-            self.error(e)
 
     def do_cp(self, args):
         self.do_copy(args)

+ 5 - 5
pwman/ui/win.py

@@ -170,16 +170,16 @@ class PwmanCliWin(PwmanCli):
         if len(ids) > 1:
             print ("Can copy only 1 password at a time...")
             return None
-        try:
-            node = self._db.getnodes(ids)
-            ce = CryptoEngine.get()
+
+        ce = CryptoEngine.get()
+        nodes = self._db.getnodes(ids)
+
+        for node in nodes:
             password = ce.decrypt(node[2])
             winSetClipboard(password)
             print("erasing in 10 sec...")
             time.sleep(10)
             winSetClipboard("")
-        except Exception as e:
-            self.error(e)
 
     def do_open(self, args):
         ids = self._get_ids(args)