예제 #1
0
파일: s3.py 프로젝트: AdRoll/s3-keyring
    def delete_password(self, service, username):
        """Delete the password for the username of the service.
        """
        service = _escape_for_s3(service)
        username = _escape_for_s3(username)
        prefix = self._get_s3_key(service, username)
        try:
            objects = list(self.bucket.objects.filter(Prefix=prefix))
            if len(objects) == 0:
                msg = ("Password for {service}/{username} not found"
                       ).format(service=service, username=username)
                raise PasswordDeleteError(msg)
            elif len(objects) > 1:
                msg = ("Multiple objects in bucket {bucket} match the prefix "
                       "{prefix}.").format(bucket=self.bucket.name,
                                           prefix=prefix)
            else:
                objects[0].delete()
        except EndpointConnectionError:
            if self.use_local_keyring:
                # Can't connect to S3: fallback to OS keyring
                print("WARNING: can't connect to S3, deleting from OS keyring",
                      file=sys.stderr)
            else:
                raise

        # Delete also in the local keyring
        try:
            keyring.delete_password(service, username)
        except PasswordDeleteError:
            # It's OK: the password was not available in the local keyring
            print("WARNING: {}/{} not found in OS keyring".format(
                service, username))
예제 #2
0
파일: umma.py 프로젝트: mankoff/umma
    def get_user_pass(self, _, reset=False):

        if reset is True:
            with app.open('user', 'r') as f:
                user = f.read()
            keyring.delete_password("umma", user) # delete password
            with app.open('user','w') as f:
                os.remove(f.name)
        
        try:
            with app.open('user', 'r') as f:
                user = f.read()
        except IOError:
            w = rumps.Window(message='US Mobile login name/email',
                             title='Login',
                             dimensions=(250,24),
                             default_text="*****@*****.**")
            r = w.run()
            user = r.text

        passwd = keyring.get_password("umma", user)
        if passwd is None:
            w = rumps.Window(message='US Mobile login password',
                             title='Login',
                             dimensions=(250, 24),
                             default_text="Your password")
            r = w.run()
            passwd = r.text
            keyring.set_password("umma", user, passwd)
        with app.open('user', 'w') as f:
            f.write(user)
        return user, passwd
예제 #3
0
	def run(self, nodes, args):
		for node in nodes:
			if not keyring.get_password(node.host, node.username):
				continue
			
			if args.yes or ask_confirm(u"Log out from {cluster} / {name} ({host})?".format(cluster=node.cluster.name, name=node.name, host=node.host)):
				keyring.delete_password(node.host, node.username)
예제 #4
0
 def login(self):
     ''' Return 502 if connection error '''
     loginHTML = requests.get(self.loginUrl)
     etmSearch = re.search(r'<input type="hidden" name="etm" id="etm" value="(.*?)".*?/>', loginHTML.text)
     etm = etmSearch.group(1)
     pieSearch = re.search(r'<input type="hidden" name="pie" id="pie" value="(.*?)".*?/>', loginHTML.text)
     pie = pieSearch.group(1)
     data = {'username': self.username,
        'password': self.password,
        'pie': pie,
        'etm': etm
     }
     headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:40.0) Gecko/20100101 Firefox/40.0'}
     try:
         loginHTML = requests.post(self.loginUrl, data=data, headers=headers)
     except:
         return "502"
     #print loginHTML.text
     tokenSearch = re.search(r'<input type="hidden" name="skypetoken" value="(.*?)".*?/>', loginHTML.text)
     self.token = tokenSearch.group(2)
     prefix = "%s_" % self.username
     keyring.set_password('messagesReceiver', prefix + 'skypeToken', self.token)
     #reset registrationToken if existed
     if keyring.get_password('messagesReceiver', prefix + 'skypeRegistrationToken') != None:
         keyring.delete_password('messagesReceiver', prefix + 'skypeRegistrationToken')
     print self.token
예제 #5
0
def clear_auth(appname=None, authfile=None, cookiejar=None):
    '''Clear all authentication data and delete related files'''

    appname   = appname   or APPNAME
    authfile  = authfile  or AUTHFILE
    cookiejar = cookiejar or COOKIEJAR

    authfiles = [cookiejar]

    log.info("Clearing all authentication data")

    if keyring:
        try:
            log.debug("Removing credentials from keyring")
            keyring.delete_password(appname, appname)
        except AttributeError as e:
            log.warning("Error removing keyring credentials. Outdated library? (%s)", e)
    else:
        authfiles.append(authfile)

    for auth in authfiles:
        try:
            log.debug("Deleting '%s'", auth)
            os.remove(auth)
        except OSError as e:
            log.debug(e)

    log.info("Finished clearing authentication")
예제 #6
0
파일: efst_utils.py 프로젝트: akpw/efst
 def delete_pwd(pwd_entry_name):
     ''' Deletes password from an OS-specific keyring
     '''
     if pwd_entry_name:
         pwd = keyring.get_password(pwd_entry_name, getpass.getuser())
         if pwd:
             keyring.delete_password(pwd_entry_name, getpass.getuser())
def unlink():
	print 'Unlinking account info...'
	try:
		delete_password('dropbox', app_key)
		print '...Done'
	except errors.PasswordDeleteError:
		print 'There is no account info to unlink'
예제 #8
0
 def __delete_password(self, username):
     """
     Delete the password associated to this username in keyring
     :param username: Username for the password
     :type username: str
     """
     keyring.delete_password(self.keyring, username)
예제 #9
0
def remove_credentials(service, username):
    try:
        keyring.delete_password(service, username)
        logger.info("Credentials of user [%s] for service [%s] removed", username, service)
    except PasswordDeleteError as e:
        logger.error("Failed to remove credentials: %s", e)
        sys.exit(1)
예제 #10
0
    def get_password(self, realm, username=None, interact=True, reset=False):
        section = self._find_section(realm)
        config_user_name = self._get_username(section)
        if not config_user_name or username != config_user_name:
                return Noner
        if not username:
            username = config_user_name

        try:
            if self.reset or reset:
                if username not in self.already_reset or reset:
                    keyring.delete_password(make_realm(section), username)
                    self.already_reset.append(username)
            password = keyring.get_password(make_realm(section), username)
        except:
            password = None

        if password is None and interact:
            prompt = "{}@{} Password: ".format(username, realm)
            password = self.password_cb(prompt)
            self.set_password(
                make_realm(section),
                username,
                password)

        return password
예제 #11
0
 def forget(self):
     try:                
         keyring.delete_password("kotnetcli", "gebruikersnaam")
         keyring.delete_password("kotnetcli", "wachtwoord")
         print "You have succesfully removed your kotnetcli credentials."
     except keyring.errors.PasswordDeleteError:
         print "You have already removed your kotnetcli credentials."
예제 #12
0
	def delete_username(self, username):
		try:
			keyring.delete_password(self.KEYRING_ID, username)
		except:
			print("The username/password doesn't exist")
			return False

		return True
예제 #13
0
    def storeCred(self, username, passw):
        self.setConf("username", username)

        if not passw:
            if keyring.get_password("jira", username):
                keyring.delete_password("jira", username)
        else:
            keyring.set_password("jira", username, passw)
예제 #14
0
파일: enauth.py 프로젝트: MikeyG/enauth
def change_auth_token( ):
    if get_password('geverpad', 'oauth_token'):
        delete_password('geverpad', 'oauth_token')
        print "Found and deleted"
    else:
        oauth_token = _get_evernote_token(True)
        if oauth_token != "None":
            set_password('geverpad', 'oauth_token', oauth_token)
예제 #15
0
    def clear_password_store(self):
        try:
            keyring.delete_password(self.KEYRING_APP_ID, self.USERNAME)
            print("Password removed from Keyring")
        except PasswordDeleteError:
            logging.error("Password cannot be deleted or already has been removed")

        sys.exit(0)
예제 #16
0
파일: util.py 프로젝트: alapolloni/jrnl
def set_keychain(journal_name, password):
    if password is None:
        try:
            keyring.delete_password('jrnl', journal_name)
        except:
            pass
    elif not TEST:
        keyring.set_password('jrnl', journal_name, password)
예제 #17
0
def read_config(args, appname=None, authfile=None):
    appname   = appname   or APPNAME
    authfile  = authfile  or AUTHFILE

    username = ""
    password = ""

    # read
    if keyring:
        log.debug("Reading credentials from keyring")
        try:
            username, password = (
                keyring.get_password(appname, appname).split('\n') +
                ['\n']
            )[:2]
        except AttributeError as e:
            # Check for old keyring format and migrate before throwing warning
            data = keyring.get_password(appname, '')
            if data:
                log.info("Migrating credentials to new keyring format")
                keyring.set_password(appname, appname, data)
                try:
                    keyring.delete_password(appname, '')
                except AttributeError as e:
                    log.warning("Error deleting old keyring. Outdated library? (%s)", e)
            else:
                log.warning("Credentials not found in keyring. First time usage?")
        except IOError as e:  # keyring sometimes raises this
            log.error(e)
    else:
        log.debug("Reading credentials from '%s'" % authfile)
        try:
            with open(authfile, 'r') as fd:
                username, password = (fd.read().splitlines() + ['\n'])[:2]
        except IOError as e:
            if e.errno == 2:  # No such file or directory
                log.warning("Credentials file not found. First time usage?")
            else:
                log.error(e)

    # save
    if args.username or args.password:
        log.info("Saving credentials")
        if keyring:
            keyring.set_password(appname, appname,
                                 '%s\n%s' % (args.username or username,
                                             args.password or password,))
        else:
            try:
                with open(authfile, 'w') as fd:
                    fd.write("%s\n%s\n" % (args.username or username,
                                           args.password or password,))
                os.chmod(authfile, 0o600)
            except IOError as e:
                log.error(e)

    return dict(username=username,
                password=password,)
def clear_passwords(config, args, *extra, **kwargs):
    keyring.delete_password(
        'taskwarrior_inthe.am',
        'api_key',
    )
    keyring.delete_password(
        'taskwarrior_inthe.am',
        'api_v2_key',
    )
예제 #19
0
파일: command.py 프로젝트: koobs/bugwarrior
def clear(target, username):
    target_list = lst(targets())
    if target not in target_list:
        raise ValueError("%s must be one of %r" % (target, target_list))

    if keyring.get_password(target, username):
        keyring.delete_password(target, username)
        print "Password cleared for %s, %s" % (target, username)
    else:
        print "No password found for %s, %s" % (target, username)
예제 #20
0
 def password_delete(self, username, parameter):
     """
     Deletes a password from the keychain for a particular environment and
     configuration parameter pair.
     """
     try:
         keyring.delete_password('multistack', username)
         return True
     except:
         return False
예제 #21
0
파일: models.py 프로젝트: Werniman/client
 def on_commit(self, update):
     for key, data in update.iteritems():
         for k, v in data.iteritems():
             if k in {"action", "table", "id"}:
                 continue
             key = "{}_{}_{}".format(data["table"], data["id"], k)
             if data["action"] in {"new", "update"}:
                 keyring.set_password(settings.keyring_service, key, data["password"] or "")
             elif data["action"] == "delete":
                 keyring.delete_password(settings.keyring_service, key)
    def clear_cached_token(self):
        """Clear any stored tokens.

        :raises: KeyError if failed to clear token.
        :rtype: None
        """
        try:
            keyring.delete_password(self.cred_store, self.store_key)
        except keyring.errors.PasswordDeleteError:
            raise_with_traceback(KeyError, "Unable to clear token.")
예제 #23
0
 def test__save_password_in_keyring(self):
     """
     Test storing password in the keyring
     """
     cloud._save_password_in_keyring(
         "salt.cloud.provider.test_case_provider", "fake_username", "fake_password_c8231"
     )
     stored_pw = keyring.get_password("salt.cloud.provider.test_case_provider", "fake_username")
     keyring.delete_password("salt.cloud.provider.test_case_provider", "fake_username")
     self.assertEqual(stored_pw, "fake_password_c8231")
예제 #24
0
 def test_save_and_load(self):
     keydict = {self.session.SESSION_ARG_KEYNAME: 'mock_key'}
     self.session.save_session(**keydict)
     session = od_api_session.OneDriveAPISession.load_session(**keydict)
     self.assertEqual(self.session.token_type, session.token_type)
     self.assertEqual(self.session.scope, session.scope)
     self.assertEqual(self.session.access_token, session.access_token)
     self.assertEqual(self.session.client_id, session.client_id)
     self.assertEqual(self.session.client_secret, session.client_secret)
     self.assertEqual(self.session.refresh_token, session.refresh_token)
     keyring.delete_password(od_api_session.OneDriveAPISession.KEYRING_SERVICE_NAME, 'mock_key')
 def clear_password(self, widget):
     global webVPN
     try:
         keyring.delete_password(webVPN['url'], webVPN['realm'] + '\\' + webVPN['username'])
         # subprocess.Popen(['notify-send','-t','1000','Password cleaned.'])
         notification.update('webVPN', 'Saved password deleted.', 'edit-clear')
         notification.show()
     except keyring.errors.PasswordDeleteError:
         # subprocess.Popen(['notify-send','-t','1000','Password not saved.'])
         notification.update('webVPN', 'Password not saved.', 'emblem-unreadable')
         notification.show()
예제 #26
0
파일: emailer.py 프로젝트: spillz/picty
 def email_failed(self,data):
     print 'Email failed!'
     self['email_page'].set_sensitive(True)
     self['email_page']['error_bar'].show()
     self['email_page']['error_bar']['error'].set_text(data['error'])
     try:
         #Not available in all versions of keyring
         keyring.delete_password(KEYRING_SERVICE_NAME,data['username']) #assume that the problem was a bad password
     except:
         #TODO: Better error handling here
         pass
예제 #27
0
    def remove_user(self, user):
        del self.__users[user.alias]
        self.save()
        try:
            import keyring

            if keyring.get_password(GENESTACK_SDK, user.alias):
                keyring.delete_password(GENESTACK_SDK, user.alias)
        except ImportError:
            pass
        except Exception as e:
            print "Error while deleting user password for %s: %s" % (user.alias, e)
예제 #28
0
def expire_password(system, username):
    """
    Deletes the password corresponding to the system and username.
    This will completely remove the password from the keyring

    :param unicode system: The name of the system that the password
        is for.  Typically, this will be the cli tools name. It effectively
        acts as a namespace
    :param unicode username: The username that the password corresponds to
    :rtype: None
    """
    LOG.debug('Expiring {0} password for user {1}'.format(system, username))
    keyring.delete_password(system, username)
예제 #29
0
    def reset_credentials():
        import keyring
        from tutorlib.config.configuration import load_config, save_config
        cfg = load_config()

        try:
            keyring.delete_password(MPT_SERVICE, cfg.online.username)
        except Exception:  # PasswordDeleteError isn't defined anywhere!
            pass

        cfg.online.username = ''

        save_config(cfg)
def clear_credentials(config=None):
    """Delete username and password from configuration file and from the keyring."""
    if config is None:
        config = get_config()
    username = config.get("credentials", "username", fallback=None)
    if username:
        try:
            import keyring
            keyring.delete_password(_SCRIPT_NAME, username)
        except ImportError:
            pass
    config.remove_section("credentials")
    config.save()
예제 #31
0
def clean_token():
    keyring.delete_password("trood/em", "active")
예제 #32
0
def delete_from_vault(application, user):
    try:
        keyring.delete_password(application, user)
    except PasswordDeleteError:
        pass
예제 #33
0
 def delete_password(self, account):
     try:
         keyring.delete_password(self.identifier, account)
     except:
         pass	# don't care - silently fail
예제 #34
0
def delete_mail_password(mail):
    try:
        keyring.delete_password(keyring_service(), mail_hash(mail))
    except:
        pass
예제 #35
0
    if save == "y" or save == "Y":
        keyring.set_password("system", "gradescope-email", email)
        keyring.set_password("system", "gradescope", password)
    else:
        pass
    br.form['session[email]'] = keyring.get_password("system",
                                                     "gradescope-email")
    br.form['session[password]'] = keyring.get_password("system", "gradescope")

req = br.submit()
soup = BeautifulSoup(br.response().read(), features="html5lib")
error = soup.find("div", class_="alert alert-flashMessage alert-error")

if error is not None:
    print("Invalid email/password combination. Please try again")
    keyring.delete_password("system", "gradescope")
    keyring.delete_password("system", "gradescope-email")
else:
    names = soup.find_all("h3", class_="courseBox--shortname")
    clases = dict()
    grades = {}
    missingAssignments = []
    data = []
    dataAssignments = []
    testAssignments = []
    file1 = open("report.txt", "w")
    jsFile = open("data.js", "w")

    for a in soup.find_all('a', href=True):
        h3 = a.find_all('h3', class_="courseBox--shortname")
        if len(h3) == 1:
예제 #36
0
 def delete(self):
     keyring.delete_password(self.service, test_alias)
     keyring.delete_password(test_uid, 'pwd')
예제 #37
0
def test_other_platform(apikey_method):
    """Tests that the lib can connect to a different ODS platform with api key and custom url"""

    # shared info
    dataset_id = "employment-by-sector-in-france-and-the-united-states-1800-2012"
    base_url = "https://data.exchange.se.com/"
    test_apikey = os.environ['EXCH_AKEY']  # <-- travis

    # various methods to get the api key
    if apikey_method == 'direct':
        csv_str = get_whole_dataset(dataset_id=dataset_id,
                                    base_url=base_url,
                                    apikey=test_apikey)

    elif apikey_method == 'file_default':
        f_name = 'ods.apikey'
        assert not os.path.exists(f_name)
        with open(f_name, 'w+') as f:
            f.write(test_apikey)

        assert get_apikey(base_url=base_url) == test_apikey
        try:
            csv_str = get_whole_dataset(dataset_id=dataset_id,
                                        base_url=base_url)
        finally:
            os.remove(f_name)

    elif apikey_method == 'file_custom':
        f_name = 'tmp.tmp'
        assert not os.path.exists(
            f_name
        ), "File '%s' already exists, please delete it first" % f_name
        with open(f_name, 'w+') as f:
            f.write(test_apikey)
        assert get_apikey(base_url=base_url,
                          apikey_filepath=f_name) == test_apikey
        try:
            csv_str = get_whole_dataset(dataset_id=dataset_id,
                                        base_url=base_url,
                                        apikey_filepath=f_name)
        finally:
            os.remove(f_name)

    elif apikey_method == 'single_env':
        os.environ['ODS_APIKEY'] = test_apikey
        assert get_apikey(base_url=base_url) == test_apikey
        csv_str = get_whole_dataset(dataset_id=dataset_id, base_url=base_url)
        del os.environ['ODS_APIKEY']

    elif apikey_method == 'multi_env_baseurl':
        os.environ['ODS_APIKEY'] = "{'default': 'blah', '%s': '%s'}" % (
            base_url, test_apikey)
        assert get_apikey(base_url=base_url) == test_apikey
        csv_str = get_whole_dataset(dataset_id=dataset_id, base_url=base_url)
        del os.environ['ODS_APIKEY']

    elif apikey_method == 'multi_env_default':
        os.environ['ODS_APIKEY'] = "{'default': '%s', 'other_id': 'blah'}" % (
            test_apikey)
        assert get_apikey(base_url=base_url) == test_apikey
        csv_str = get_whole_dataset(dataset_id=dataset_id, base_url=base_url)
        del os.environ['ODS_APIKEY']

    elif apikey_method == 'keyring1':
        # if 'TRAVIS_PYTHON_VERSION' in os.environ:
        #     pytest.skip("Does not work yet on travis")
        keyring.set_password(base_url, 'apikey', test_apikey)
        assert get_apikey(base_url=base_url,
                          keyring_entries_username='******') == test_apikey
        csv_str = get_whole_dataset(dataset_id=dataset_id,
                                    base_url=base_url,
                                    keyring_entries_username='******')
        keyring.delete_password(base_url, 'apikey')
        assert keyring.get_password(base_url, 'apikey') is None

    elif apikey_method == 'keyring2':
        # if 'TRAVIS_PYTHON_VERSION' in os.environ:
        #     pytest.skip("Does not work yet on travis")
        store_apikey_in_keyring(base_url=base_url,
                                keyring_entries_username='******',
                                apikey=test_apikey)
        assert get_apikey(base_url=base_url,
                          keyring_entries_username='******') == test_apikey
        csv_str = get_whole_dataset(dataset_id=dataset_id,
                                    base_url=base_url,
                                    keyring_entries_username='******')
        remove_apikey_from_keyring(base_url=base_url,
                                   keyring_entries_username='******')
        assert keyring.get_password(base_url, 'apikey') is None

    else:
        raise ValueError('wrong apikey_method: %s' % apikey_method)

    ref_csv = """Year;France: Agriculture;France: Manufacturing;France: Services;USA: Agriculture;USA: Manufacturing;USA: Services
1950-12-31;31.5;33.3;35.2;13.5;33.2;50.3
1800-12-31;64.03737;21.58231;14.38032;68.42105;18.42105;13.15789
2012-12-31;2.9;20.9;76.2;1.6;18.3;80.1
1900-12-31;43.2;29.0;27.8;40.5;28.2;31.3
"""

    # move to pandas
    df = pd.read_csv(create_reading_buffer(csv_str, is_literal=False), sep=';')

    # compare with ref
    ref_df = pd.read_csv(create_reading_buffer(ref_csv, is_literal=True),
                         sep=';')
    df = df.set_index('Year').sort_index()
    ref_df = ref_df.set_index('Year').sort_index()
    pd.testing.assert_frame_equal(df, ref_df)
    assert df.shape == (4, 6)
예제 #38
0
 def log_out(self):
     keyring.delete_password('photini', self.name)
     self.close_connection()
예제 #39
0
def delete_password_in_keyring(username):
    return keyring.delete_password(
        KEYRING_SYSTEM,
        username,
    )
예제 #40
0
 def deletePassword(self):
     keyring.delete_password(Constants.SERVICE_ID, self.username)
예제 #41
0
def on_delete_handler_account(model_class, instance):
    keyring.delete_password("PyMail", instance.address)
예제 #42
0
 def delete_all_data(self):
     if (keyring.get_password(self._keyring_service, self._keyring_username)
             is not None):
         keyring.delete_password(self._keyring_service,
                                 self._keyring_username)
     self._load()
예제 #43
0
def delete_password_by_key(key):
    try:
        return keyring.delete_password('MavensMate: ' + key, key)
    except:
        #TODO: this has not been implemented in keyring yet :-(
        pass
예제 #44
0
파일: ghe.py 프로젝트: ppouliot/ghe
def unset_key(key):
    keyring.delete_password(__title__, key)
예제 #45
0
 def delete(self, key):
     keyring.delete_password(self.app.name, key)
예제 #46
0
def delete_password(section, host, username) -> bool:
    name = _make_password_name(section, host)
    return keyring.delete_password(name, username)
예제 #47
0
def remove_api_key(username):
        try:
            keyring.delete_password(SYNAPSE_CACHED_SESSION_APLICATION_NAME, username)
        except keyring_errors.PasswordDeleteError:
            # The API key does not exist, but that is fine
            pass
예제 #48
0
    def delete(self, username: str) -> None:
        assert self.exists(username), 'Account does not exist'

        self._accounts.pop(username)
        keyring.delete_password(self.KEYRING_SERVICE_NAME, username)
예제 #49
0
 def forget_password(self):
     if self.username is None:
         raise ValueError("forget_password: username is None")
     keyring.delete_password("fetch.py WAYF", self.username)
예제 #50
0
 def deleteToken(self):
     try:
         keyring.delete_password(self._serviceName, 'token')
     except keyring.errors.PasswordDeleteError:
         pass
 def __delattr__(self, item):
     try:
         keyring.delete_password(self.service_name, item)
     except Exception:
         log.exception("Failed to delete secret '%s' of '%r'.", item,
                       self.service_name)
예제 #52
0
파일: safe.py 프로젝트: vipervit/keysafe
 def __delete_secure__(self):
     keyring.delete_password(self.service, self.alias)
예제 #53
0
                                .format(user, Style.RESET_ALL))
                            exi = input('\n Enter any Key to Exit : ')

                    elif (choice == 3):
                        print()
                        print('Please Enter the New Password')
                        orig, p = get_pasword()
                        vault_dict[server][user] = p
                        sub_string = server + ',' + user
                        for ele in range(len(server_details)):
                            if sub_string in server_details[ele]:

                                server_details[ele] = sub_string + ',' + p
                        try:
                            update_server_file(server_details)
                            keyring.delete_password(server, user)
                            keyring.set_password(server, user, orig)
                            print(Fore.GREEN +
                                  "\n\t\t Password Updated Successfully " +
                                  Style.RESET_ALL)
                            exi = input('\n Enter any Key to Exit : ')
                            break
                        except Exception:
                            print()
                            print(
                                Fore.RED +
                                ' Failed to Update the Password , Please try Again '
                                + Style.RESET_ALL)
                            exi = input('\n Enter any Key to Exit : ')

                    elif (choice == 4):
예제 #54
0
def delete_bgp_peer_password(bgp_peer_id):
    try:
        keyring.delete_password(NEUTRON_KEYRING_SERVICE, bgp_peer_id)
    except keyring.errors.PasswordDeleteError:
        pass  # password likely not set
예제 #55
0
 def delete_credentials(self):
     keyring.delete_password('plenty-identity', 'user')
     keyring.delete_password('plenty-identity', 'password')
예제 #56
0
def delete_key():
    keyring.delete_password("pushbullet", "cli")
예제 #57
0
파일: cli.py 프로젝트: pks18/acl
def attendance(roll):
    """
    Get the credentials first
    """
    password = keyring.get_password('ERP', roll)
    saved_password = True

    if password != None:
        response = attempt(roll, password)

        if not response:
            click.echo(
                click.style('Password modified, Enter new password.',
                            fg='green',
                            bold=True))
            keyring.delete_password('ERP', roll)
            password = None

    if password == None:
        password = getpass.getpass("Password : "******"Subject Code", "Subject Name", "Attended", "Percentage"
    ]
    show_table(attendance_table, attendance_header)

    # Fetch missed classes from ERP and Pretty Print it on Terminal.
    ans = input("Do you want to see the missed class(es) date-wise ? (y/N) ")
    if ans == 'y':
        input_subject = []
        specific_class_ans = input(
            "Do you want to see the missed class(es) of specific subject(s)? (y/N) "
        )
        if specific_class_ans == 'y':
            input_subject = [
                x for x in input(
                    "Enter the Subject code(s) seperated by spaces: ").split()
            ]

        attendance = None
        cached_yes = False

        try:
            with open(os.path.expanduser("~/.attendance_past.txt"), "r") as f:
                attendance = [line.split("\t") for line in f]
            cached_yes = input(
                "Unless your past attendance was updated recently, would you like us to use cached data? (y/N) "
            )
        except Exception:
            pass

        print("Please wait, it may take a while to fetch the information...")

        if attendance is not None and cached_yes == 'y':
            missed_class_response = MissedClassDates(roll, password,
                                                     attendance[0][0])
        else:
            missed_class_response = MissedClassDates(roll, password)
        if specific_class_ans != 'y':
            missed_class_table = make_missed_class_table(
                missed_class_response, attendance, cached_yes)
        else:
            missed_class_table = make_specific_sub_missed_class_table(
                missed_class_response, input_subject, attendance, cached_yes)
        Missed_class_headers = [
            "Subject Code", "Date", "Subject Name", "Attended"
        ]
        show_table(missed_class_table, Missed_class_headers)

    # Store password locally if not saved already
    if not saved_password:
        ans = input("Do you want to store your password locally? (y/N) ")
        if ans == 'y':
            keyring.set_password('ERP', roll, password)
예제 #58
0
def read_config(args, appname=None, authfile=None):
    appname = appname or APPNAME
    authfile = authfile or AUTHFILE

    username = ""
    password = ""

    # read
    if keyring:
        log.debug("Reading credentials from keyring")
        try:
            username, password = (
                keyring.get_password(appname, appname).split('\n') +
                ['\n'])[:2]
        except AttributeError as e:
            # Check for old keyring format and migrate before throwing warning
            data = keyring.get_password(appname, '')
            if data:
                log.info("Migrating credentials to new keyring format")
                keyring.set_password(appname, appname, data)
                try:
                    keyring.delete_password(appname, '')
                except AttributeError as e:
                    log.warning(
                        "Error deleting old keyring. Outdated library? (%s)",
                        e)
            else:
                log.warning(
                    "Credentials not found in keyring. First time usage?")
        except IOError as e:  # keyring sometimes raises this
            log.error(e)
    else:
        log.debug("Reading credentials from '%s'" % authfile)
        try:
            with open(authfile, 'r') as fd:
                username, password = (fd.read().splitlines() + ['\n'])[:2]
        except IOError as e:
            if e.errno == 2:  # No such file or directory
                log.warning("Credentials file not found. First time usage?")
            else:
                log.error(e)

    # save
    if args.username or args.password:
        log.info("Saving credentials")
        if keyring:
            keyring.set_password(
                appname, appname, '%s\n%s' % (
                    args.username or username,
                    args.password or password,
                ))
        else:
            try:
                with open(authfile, 'w') as fd:
                    fd.write("%s\n%s\n" % (
                        args.username or username,
                        args.password or password,
                    ))
                os.chmod(authfile, 0o600)
            except IOError as e:
                log.error(e)

    return dict(
        username=username,
        password=password,
    )
예제 #59
0
from gi.repository import GdkPixbuf
from gi.repository import Gtk
from gi.repository import GLib

from bcloud import Config
from bcloud.log import logger
from bcloud import net
from bcloud import pcs
from bcloud import util
try:
    import keyring
    keyring_available = True
    try:
        keyring.set_password("test", "utest", "ptest")
        keyring.get_password("test", "utest")
        keyring.delete_password("test", "utest")
    except:
        keyring_available = False
except (ImportError, ValueError):
    logger.warn(traceback.format_exc())
    keyring_available = False

DEFAULT_PROFILE = {
    'window-size': (960, 680),
    'use-status-icon': True,
    'use-dark-theme': False, # 默认禁用深色主题
    'display-avatar': True,  # 是否显示用户头像
    'use-notify': True,
    'first-run': True,
    'save-dir': Config.HOME_DIR,
    'sync-dir': Config.HOME_DIR,
예제 #60
0
파일: cli.py 프로젝트: yefei14131/mfa
def delete(key):
    """Delete the key."""
    try:
        keyring.delete_password(__name__, key)
    except Exception as e:
        click.echo((Exception, e))