From f64aae87db97309f5fc6a9040737dace15118b25 Mon Sep 17 00:00:00 2001 From: buchanan Date: Tue, 29 Dec 2015 17:02:18 -0700 Subject: [PATCH] Prompt for username/password if missing from .pepperrc --- files.txt | 8 ++++++++ pepper/__init__.py | 2 +- pepper/cli.py | 29 +++++++++++------------------ pepper/libpepper.py | 1 - 4 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 files.txt diff --git a/files.txt b/files.txt new file mode 100644 index 0000000..f81ee07 --- /dev/null +++ b/files.txt @@ -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 diff --git a/pepper/__init__.py b/pepper/__init__.py index 5b77217..77b3af1 100644 --- a/pepper/__init__.py +++ b/pepper/__init__.py @@ -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') diff --git a/pepper/cli.py b/pepper/cli.py index 34d84e2..af7c857 100644 --- a/pepper/cli.py +++ b/pepper/cli.py @@ -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', } @@ -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 diff --git a/pepper/libpepper.py b/pepper/libpepper.py index 29310cc..1a336e9 100644 --- a/pepper/libpepper.py +++ b/pepper/libpepper.py @@ -7,7 +7,6 @@ import functools import json import logging -import ssl import os try: import ssl