Skip to content

Commit

Permalink
Prompt for username/password if missing from .pepperrc
Browse files Browse the repository at this point in the history
  • Loading branch information
buchanan committed Dec 30, 2015
1 parent 53a0d04 commit f64aae8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
8 changes: 8 additions & 0 deletions files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/usr/lib/python3.5/site-packages/pepper/__init__.py
/usr/lib/python3.5/site-packages/pepper/libpepper.py
/usr/lib/python3.5/site-packages/pepper/cli.py
/usr/lib/python3.5/site-packages/pepper/__pycache__/__init__.cpython-35.pyc
/usr/lib/python3.5/site-packages/pepper/__pycache__/libpepper.cpython-35.pyc
/usr/lib/python3.5/site-packages/pepper/__pycache__/cli.cpython-35.pyc
/usr/bin/pepper
/usr/lib/python3.5/site-packages/salt_pepper-0.4.0.dev21-py3.5.egg-info
2 changes: 1 addition & 1 deletion pepper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# First try to grab the version from the version.json build file.
vfile = os.path.join(os.path.dirname(__file__), 'version.json')

with open(vfile, 'r') as f:
with open(vfile, 'rb') as f:
ret = json.load(f)
version = ret.get('version')
sha = ret.get('sha')
Expand Down
29 changes: 11 additions & 18 deletions pepper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def get_login_details(self):
# setting default values
results = {
'SALTAPI_URL': 'https://localhost:8000/',
'SALTAPI_USER': 'saltdev',
'SALTAPI_USER': None,
'SALTAPI_PASS': None,
'SALTAPI_EAUTH': 'auto',
}
Expand Down Expand Up @@ -227,29 +227,22 @@ def get_login_details(self):

if self.options.eauth:
results['SALTAPI_EAUTH'] = self.options.eauth
if self.options.username is None:
if self.options.interactive:
results['SALTAPI_USER'] = input('Username: ')
else:
logger.error("SALTAPI_USER required")
raise SystemExit(1)
else:
results['SALTAPI_USER'] = self.options.username
if self.options.password is None:
if self.options.interactive:
results['SALTAPI_PASS'] = getpass.getpass(prompt='Password: ')
else:
logger.error("SALTAPI_PASS required")
raise SystemExit(1)
if self.options.username is None and results['SALTAPI_USER'] is None:
if self.options.interactive:
results['SALTAPI_USER'] = input('Username: ')
else:
results['SALTAPI_PASS'] = self.options.password

if results['SALTAPI_PASS'] is None:
logger.error("SALTAPI_USER required")
raise SystemExit(1)
else:
if self.options.username is not None: results['SALTAPI_USER'] = self.options.username
if self.options.password is None and results['SALTAPI_PASS'] is None:
if self.options.interactive:
results['SALTAPI_PASS'] = getpass.getpass(prompt='Password: ')
else:
logger.error("SALTAPI_PASS required")
raise SystemExit(1)
else:
if self.options.password is not None: results['SALTAPI_PASS'] = self.options.password

return results

Expand Down
1 change: 0 additions & 1 deletion pepper/libpepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import functools
import json
import logging
import ssl
import os
try:
import ssl
Expand Down

0 comments on commit f64aae8

Please sign in to comment.