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/cli.py b/pepper/cli.py index af846ef..3682a34 100644 --- a/pepper/cli.py +++ b/pepper/cli.py @@ -17,6 +17,11 @@ # Python 2 import ConfigParser +try: + input = raw_input +except NameError: + pass + import pepper try: @@ -25,6 +30,11 @@ class NullHandler(logging.Handler): def emit(self, record): pass +try: + import configparser +except ImportError: + import ConfigParser as configparser + logging.basicConfig(format='%(levelname)s %(asctime)s %(module)s: %(message)s') logger = logging.getLogger('pepper') logger.addHandler(NullHandler()) @@ -191,8 +201,8 @@ def get_login_details(self): # setting default values results = { 'SALTAPI_URL': 'https://localhost:8000/', - 'SALTAPI_USER': 'saltdev', - 'SALTAPI_PASS': 'saltdev', + 'SALTAPI_USER': None, + 'SALTAPI_PASS': None, 'SALTAPI_EAUTH': 'auto', } @@ -210,7 +220,7 @@ def get_login_details(self): results[key] = config.get(profile, key) # get environment values - for key, value in results.items(): + for key, value in list(results.items()): results[key] = os.environ.get(key, results[key]) # get eauth prompt options @@ -222,22 +232,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'] = raw_input('Username: ') - else: - logger.error("SALTAPI_USER 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_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) + 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: - results['SALTAPI_PASS'] = self.options.password + logger.error("SALTAPI_PASS required") + raise SystemExit(1) + else: + if self.options.password is not None: results['SALTAPI_PASS'] = self.options.password return results @@ -305,7 +315,7 @@ def poll_for_returns(self, api, load): break jid_ret = api.lookup_jid(jid) - ret_nodes = jid_ret['return'][0].keys() + ret_nodes = list(jid_ret['return'][0].keys()) if set(ret_nodes) == set(nodes): ret = jid_ret diff --git a/pepper/libpepper.py b/pepper/libpepper.py index 1faafcb..e188ebf 100644 --- a/pepper/libpepper.py +++ b/pepper/libpepper.py @@ -7,8 +7,13 @@ import functools import json import logging -import ssl import os +import ssl +try: + ssl._create_default_https_context = ssl._create_stdlib_context +except: + pass + try: from urllib.request import HTTPHandler, Request, urlopen, \ install_opener, build_opener