123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- from __future__ import print_function
- from pwman.util.crypto_engine import CryptoEngine, zerome
- import re
- import sys
- import os
- import time
- import select as uselect
- import ast
- from pwman.util.config import get_pass_conf
- from pwman.ui import tools
- from pwman.ui.tools import CliMenuItem
- from colorama import Fore
- from pwman.data.nodes import NewNode, Node
- from pwman.ui.tools import CMDLoop
- import getpass
- from pwman.data.tags import TagNew
- import csv
- if sys.version_info.major > 2:
- raw_input = input
- from .base import HelpUI
- class BaseCommands(HelpUI):
- def do_copy(self, args):
- """copy item to clipboard"""
- pass
- def do_exit(self, args):
- """close the text console"""
- pass
- def do_export(self, args):
- """export the database to a given format"""
- pass
- def do_forget(self, args):
- """drop saved key forcing the user to re-enter the master
- password"""
- pass
- def do_cls(self, args):
- """clear the screen"""
- os.system("clear")
- def do_edit(self, args):
- """edit a node"""
- pass
- def do_clear(self, args):
- """remove db filter"""
- pass
- def do_passwd(self, args):
- """change the master password of the database"""
- pass
- def do_tags(self, args):
- """print all existing tags """
- pass
- def _get_tags(self, default=None, reader=raw_input):
-
-
- taglist = tools.getinput("Tags: ", '', reader=reader)
- tagstrings = taglist.split()
- tags = [tn for tn in tagstrings]
- return tags
- def do_listn(self, args):
- """list all existing nodes in database"""
- self.do_cls('')
- self.do_filter(args)
- nodeids = self._db.listnodes()
- nodes = self._db.getnodes(nodeids)
- _nodes_inst = []
-
- for node in nodes:
- _nodes_inst.append(Node.from_encrypted_entries(
- node[1],
- 'xxxxx',
- node[2],
- 'yyyyy',
- []))
- for node in _nodes_inst:
- print(node)
- def do_filter(self, args):
- pass
- def do_newn(self, args):
- node = {}
- node['username'] = self.get_username()
- args = {}
- node['password'] = self.get_password(argsgiven=1, **args)
- node['url'] = self.get_url()
- node['notes'] = self.get_notes()
-
- import ipdb; ipdb.set_trace()
- node['tags'] = self._get_tags()
- node = Node(clear_text=True, **node)
- self._db.add_node(node)
|