Skip to content

Commit

Permalink
Use keyring for password if available.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 4, 2015
1 parent a854230 commit 9355196
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

from pygithub3 import Github

try:
import keyring
except ImportError:
# keyring isn't available, so mock the interface to simulate no pw
class Keyring:
get_password = staticmethod(lambda system, username: None)

try:
import json
except ImportError:
Expand Down Expand Up @@ -292,7 +299,10 @@ def push_issue(gh_username, gh_repository, issue, body, comments):
issues = get_issues(bb_url, options.start)

# push them in GitHub (issues comments are fetched here)
github_password = getpass.getpass("Please enter your GitHub password\n")
github_password = (
keyring.get_password('Github', options.github_username) or
getpass.getpass("Please enter your GitHub password\n")
)
github = Github(login=options.github_username, password=github_password)
gh_username, gh_repository = options.github_repo.split('/')

Expand Down

0 comments on commit 9355196

Please sign in to comment.