Example #1
0
File: pypi.py Project: jiivan/hyde
 def prompt_for_credentials(self):
     pypirc_file = os.path.expanduser("~/.pypirc")
     if not os.path.isfile(pypirc_file):
         pypirc = None
     else:
         pypirc = configparser.Rawconfigparser()
         pypirc.read([pypirc_file])
     missing_errs = (
         configparser.NoSectionError, configparser.NoOptionError)
     #  Try to find username in .pypirc
     if self.username is None:
         if pypirc is not None:
             try:
                 self.username = pypirc.get("server-login", "username")
             except missing_errs:
                 pass
     #  Prompt for username on command-line
     if self.username is None:
         print(("Username: ",))
         self.username = input().strip()
     #  Try to find password in .pypirc
     if self.password is None:
         if pypirc is not None:
             try:
                 self.password = pypirc.get("server-login", "password")
             except missing_errs:
                 pass
     #  Prompt for username on command-line
     if self.password is None:
         self.password = getpass.getpass("Password: ")
     #  Validate the values.
     if not self.username:
         raise ValueError("PyPI requires a username")
     if not self.password:
         raise ValueError("PyPI requires a password")
Example #2
0
File: pyfs.py Project: jiivan/hyde
 def prompt_for_credentials(self):
     credentials = {}
     if "%(username)s" in self.url:
         print(("Username: ",))
         credentials["username"] = input().strip()
     if "%(password)s" in self.url:
         credentials["password"] = getpass.getpass("Password: ")
     if credentials:
         self.url = self.url % credentials