Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: third_party/google-endpoints/setuptools/command/upload.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 import getpass
2 from distutils.command import upload as orig
3
4
5 class upload(orig.upload):
6 """
7 Override default upload behavior to obtain password
8 in a variety of different ways.
9 """
10
11 def finalize_options(self):
12 orig.upload.finalize_options(self)
13 # Attempt to obtain password. Short circuit evaluation at the first
14 # sign of success.
15 self.password = (
16 self.password or
17 self._load_password_from_keyring() or
18 self._prompt_for_password()
19 )
20
21 def _load_password_from_keyring(self):
22 """
23 Attempt to load password from keyring. Suppress Exceptions.
24 """
25 try:
26 keyring = __import__('keyring')
27 return keyring.get_password(self.repository, self.username)
28 except Exception:
29 pass
30
31 def _prompt_for_password(self):
32 """
33 Prompt for a password on the tty. Suppress Exceptions.
34 """
35 try:
36 return getpass.getpass()
37 except (Exception, KeyboardInterrupt):
38 pass
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698