123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- """
- Define the CLI interface for pwman3 and the helper functions
- """
- from __future__ import print_function
- import pwman
- from pwman.util.crypto import CryptoEngine
- import pwman.util.config as config
- import sys
- import cmd
- from pwman.ui.ocli import Aliases, BaseCommands
- try:
- import readline
- _readline_available = True
- except ImportError, e:
- _readline_available = False
- def get_pass_conf():
- numerics = config.get_value("Generator", "numerics").lower() == 'true'
-
- leetify = config.get_value("Generator", "leetify").lower() == 'true'
- special_chars = config.get_value("Generator", "special_chars"
- ).lower() == 'true'
- return numerics, leetify, special_chars
- class PwmanCliNew(Aliases, BaseCommands):
- """
- Inherit from the BaseCommands and Aliases
- """
- def __init__(self, db, hasxsel, callback):
- """
- initialize CLI interface, set up the DB
- connecion, see if we have xsel ...
- """
- cmd.Cmd.__init__(self)
- self.intro = "%s %s (c) visit: %s" % (pwman.appname, pwman.version,
- pwman.website)
- self._historyfile = config.get_value("Readline", "history")
- self.hasxsel = hasxsel
- try:
- enc = CryptoEngine.get()
- enc._callback = callback()
- 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> "
|