Example #1
0
def getpass2():
    passwd = _getpass('Enter your wallet password (utf-8): ')
    rpasswd = _getpass('Repeat the password: '******'utf-8')
Example #2
0
 def getpass(s):
     try:
         return _getpass(str(s))
     except UnicodeEncodeError:
         from locale import getpreferredencoding
         try:
             return _getpass(s.encode(getpreferredencoding()))
         except UnicodeEncodeError:
             return _getpass(b'Password: ')
Example #3
0
    def __init__(self,
                 createSqliteInMemory=True,
                 configFilePath=None,
                 configDict={}):
        """fields in configDict or in configFile:
            keePassFilePath
            keePassNotesSeparator
            driversTypes
            password (not recommended)

            the configFile is first imported and its value is override by the configDict parameter
            each field must be given in the config file or the configDict parameter with the exception of password
            if password is not set, a prompt will ask you for it
        """
        from pykeepass import PyKeePass as _PyKeePass
        from pykeepass.exceptions import CredentialsIntegrityError as _CredentialsIntegrityError

        self.config = {}

        if configFilePath is None:
            if _system() == "Windows":
                configFilePath = _environ["USERPROFILE"]
            elif _system() in ("Linux", "Darwin"):
                configFilePath = _environ["HOME"]
            configFilePath = _join(configFilePath, ".connectionManagerpy",
                                   "config.py")

        if _isfile(configFilePath):
            configDictInFile = _utils.importFromPath(configFilePath).configDict
            self.config.update(configDictInFile)
            self.config.update(configDict)
        else:
            self.config.update(configDict)

        self.keePassFilePath = self.config["keePassFilePath"]
        self.keePassNotesSeparator = self.config["keePassNotesSeparator"]
        self.driversTypes = self.config["driversTypes"]

        try:
            pwd = self.config.get("password")
            if pwd is None:
                from getpass import getpass as _getpass
                pwd = _getpass("mdp: ")
            self.keyPassFile = _PyKeePass(self.keePassFilePath, pwd)
        except FileNotFoundError:
            raise FileNotFoundError(self.keePassFilePath + " inexistant")
        except _CredentialsIntegrityError:
            raise ValueError("mot de passe incorrect pour " +
                             self.keePassFilePath)
        if createSqliteInMemory:
            self.inMemory = self.getDriver("sql", "sqlite")
            self.inMemory = self.inMemory()
            self.inMemory.connect(self.inMemory.inmemory)
Example #4
0
def _get_api(opts_dict):
    session = _get_option(opts_dict, "session")
    try:
        return api.load(session)
    except (IOError, ValueError, api.AuthError) as e:
        logging.debug("loading session failed: %s", e)
        logging.debug("I'll ask instead")
        user = _get_option(opts_dict, 'username')
        if not user:
            user   = raw_input('Username: ')

        passwd = _getpass()
        
        return api.Api(user, passwd)
Example #5
0
 def getDefaultElogInstance(self, url, **kwargs):
     from pathlib import Path
     home = str(Path.home())
     if not ("user" in kwargs.keys()):
         kwargs.update(dict(user=_getuser()))
     if not ("password" in kwargs.keys()):
         try:
             with open(os.path.join(home, ".elog_psi"), "r") as f:
                 _pw = f.read().strip()
         except:
             print("Enter elog password for user: %s" % kwargs["user"])
             _pw = _getpass()
     kwargs.update(dict(password=_pw))
     return _elog_ha.open(url, **kwargs), kwargs["user"]
 def __init__(self,
              filePath,
              variousInfosFieldSeparator="=",
              variousInfosLineSeparator="\n",
              commentChar="#",
              pathDict={},
              pwd=None):
     if pwd is None:
         from getpass import getpass as _getpass
         pwd = _getpass("password for {}: ".format(filePath))
     self._keyPassFile = _PyKeePass(filePath, pwd)
     self.variousInfosFieldSeparator = variousInfosFieldSeparator
     self.variousInfosLineSeparator = variousInfosLineSeparator
     self.commentChar = commentChar
     self.pathDict = pathDict  # dict witch map a connection name to a location in the keepass file
Example #7
0
def getDefaultElogInstance(url, **kwargs):
    from pathlib import Path
    home = str(Path.home())
    if not ('user' in kwargs.keys()):
        kwargs.update(dict(user=_getuser()))

    if not ('password' in kwargs.keys()):
        try:
            with open(os.path.join(home, '.elog_psi'), 'r') as f:
                _pw = f.read().strip()
        except:
            print('Enter elog password for user: %s' % kwargs['user'])
            _pw = _getpass()
        kwargs.update(dict(password=_pw))

    return _elog_ha.open(url, **kwargs), kwargs['user']
Example #8
0
def getpass(prompt):
    if sys.stdin.isatty():
        return _getpass(prompt)
    else:
        return sys.stdin.readline()
Example #9
0
def getseed():
    passwd = _getpass('Enter some arbitrary seed (utf-8): ')
    return passwd.encode('utf-8')
Example #10
0
def getpass():
    return _getpass().encode('utf-8')
Example #11
0
 def getpass(s):
     return _getpass(s.encode('utf8'))
Example #12
0
 def getpass(s):
     return _getpass(s.encode('utf8'))
Example #13
0
File: utils.py Project: epcim/sshx
def read_password():
    return _getpass()