Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
3070dd76
Commit
3070dd76
authored
Apr 24, 2016
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #555 from brookskindle/dev_prompt_password
password prompt on upload command
parents
89509b57
6c9c3c7e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
+26
-6
setuptools/command/upload.py
setuptools/command/upload.py
+26
-6
No files found.
setuptools/command/upload.py
View file @
3070dd76
...
@@ -3,13 +3,18 @@ from distutils.command import upload as orig
...
@@ -3,13 +3,18 @@ from distutils.command import upload as orig
class
upload
(
orig
.
upload
):
class
upload
(
orig
.
upload
):
"""
"""
Override default upload behavior to
look up
password
Override default upload behavior to
obtain
password
in
the keyring if available
.
in
a variety of different ways
.
"""
"""
def
finalize_options
(
self
):
def
finalize_options
(
self
):
orig
.
upload
.
finalize_options
(
self
)
orig
.
upload
.
finalize_options
(
self
)
self
.
password
or
self
.
_load_password_from_keyring
()
# Attempt to obtain password. Short circuit evaluation at the first
# sign of success.
self
.
password
=
(
self
.
password
or
self
.
_load_password_from_keyring
()
or
self
.
_prompt_for_password
()
)
def
_load_password_from_keyring
(
self
):
def
_load_password_from_keyring
(
self
):
"""
"""
...
@@ -17,7 +22,22 @@ class upload(orig.upload):
...
@@ -17,7 +22,22 @@ class upload(orig.upload):
"""
"""
try
:
try
:
keyring
=
__import__
(
'keyring'
)
keyring
=
__import__
(
'keyring'
)
self
.
password
=
keyring
.
get_password
(
self
.
repository
,
password
=
keyring
.
get_password
(
self
.
repository
,
self
.
username
)
self
.
username
)
except
Exception
:
except
Exception
:
pass
password
=
None
finally
:
return
password
def
_prompt_for_password
(
self
):
"""
Prompt for a password on the tty. Suppress Exceptions.
"""
password
=
None
try
:
import
getpass
while
not
password
:
password
=
getpass
.
getpass
()
except
(
Exception
,
KeyboardInterrupt
):
password
=
None
finally
:
return
password
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment