baseui.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # ===========================================================================
  2. # This file is part of Pwman3.
  3. #
  4. # Pwman3 is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License, version 2
  6. # as published by the Free Software Foundation;
  7. #
  8. # Pwman3 is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Pwman3; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. # ============================================================================
  17. # Copyright (C) 2013, 2014 Oz Nahum Tiram <nahumoz@gmail.com>
  18. # ============================================================================
  19. from __future__ import print_function
  20. from pwman.util.crypto_engine import CryptoEngine, zerome
  21. import re
  22. import sys
  23. import os
  24. import time
  25. import select as uselect
  26. import ast
  27. from pwman.util.config import get_pass_conf
  28. from pwman.ui import tools
  29. from pwman.ui.tools import CliMenuItem
  30. from colorama import Fore
  31. from pwman.data.nodes import NewNode, Node
  32. from pwman.ui.tools import CMDLoop
  33. import getpass
  34. from pwman.data.tags import TagNew
  35. import csv
  36. if sys.version_info.major > 2:
  37. raw_input = input
  38. from .base import HelpUI
  39. class BaseCommands(HelpUI):
  40. def do_copy(self, args):
  41. """copy item to clipboard"""
  42. pass
  43. def do_exit(self, args):
  44. """close the text console"""
  45. pass
  46. def do_export(self, args):
  47. """export the database to a given format"""
  48. pass
  49. def do_forget(self, args):
  50. """drop saved key forcing the user to re-enter the master
  51. password"""
  52. pass
  53. def do_cls(self, args): # pragma: no cover
  54. """clear the screen"""
  55. os.system("clear")
  56. def do_edit(self, args):
  57. """edit a node"""
  58. pass
  59. def do_clear(self, args):
  60. """remove db filter"""
  61. pass
  62. def do_passwd(self, args):
  63. """change the master password of the database"""
  64. pass
  65. def do_tags(self, args):
  66. """print all existing tags """
  67. pass
  68. def do_listn(self, args):
  69. """list all existing nodes in database"""
  70. self.do_cls('')
  71. self.do_filter(args)
  72. nodeids = self._db.listnodes()
  73. nodes = self._db.getnodes(nodeids)
  74. _nodes_inst = []
  75. # user, pass, url, notes
  76. for node in nodes:
  77. _nodes_inst.append(Node.from_encrypted_entries(
  78. node[1],
  79. 'xxxxx',
  80. node[2],
  81. 'yyyyy',
  82. []))
  83. for node in _nodes_inst:
  84. print(node)
  85. def do_filter(args):
  86. pass