2
from distutils.command import upload as orig
5
class upload(orig.upload):
7
Override default upload behavior to obtain password
8
in a variety of different ways.
11
def finalize_options(self):
12
orig.upload.finalize_options(self)
17
# Attempt to obtain password. Short circuit evaluation at the first
21
self._load_password_from_keyring() or
22
self._prompt_for_password()
25
def _load_password_from_keyring(self):
27
Attempt to load password from keyring. Suppress Exceptions.
30
keyring = __import__('keyring')
31
return keyring.get_password(self.repository, self.username)
35
def _prompt_for_password(self):
37
Prompt for a password on the tty. Suppress Exceptions.
40
return getpass.getpass()
41
except (Exception, KeyboardInterrupt):