Fix raw_input to be input for py3, set input = raw_input for py2 compat

Fixes arthepsy/pan-globalprotect-okta#8
This commit is contained in:
Tyler Christiansen
2019-01-10 18:20:09 -05:00
parent 1f8db7d309
commit bc77639d3a
+3 -2
View File
@@ -34,6 +34,7 @@ if sys.version_info >= (3,):
else: else:
text_type = unicode text_type = unicode
binary_type = str binary_type = str
input = raw_input
to_b = lambda v: v if isinstance(v, binary_type) else v.encode('utf-8') to_b = lambda v: v if isinstance(v, binary_type) else v.encode('utf-8')
to_u = lambda v: v if isinstance(v, text_type) else v.decode('utf-8') to_u = lambda v: v if isinstance(v, text_type) else v.decode('utf-8')
@@ -116,7 +117,7 @@ def load_conf(cf):
continue continue
conf[k] = v.strip() conf[k] = v.strip()
if len(conf.get('username', '').strip()) == 0: if len(conf.get('username', '').strip()) == 0:
conf['username'] = raw_input('username: ').strip() conf['username'] = input('username: ').strip()
if len(conf.get('password', '').strip()) == 0: if len(conf.get('password', '').strip()) == 0:
conf['password'] = getpass.getpass('password: ').strip() conf['password'] = getpass.getpass('password: ').strip()
for k in keys: for k in keys:
@@ -244,7 +245,7 @@ def okta_mfa_totp(conf, s, factors, state_token):
secret = conf.get('totp.{0}'.format(provider), '') or '' secret = conf.get('totp.{0}'.format(provider), '') or ''
code = None code = None
if len(secret) == 0: if len(secret) == 0:
code = raw_input('{0} TOTP: '.format(provider)).strip() code = input('{0} TOTP: '.format(provider)).strip()
else: else:
import pyotp import pyotp
totp = pyotp.TOTP(secret) totp = pyotp.TOTP(secret)