Replace raw_input with input to make PY3 compatible

The raw_input() raises NameError: name 'raw_input' is not defined in
python3. This patch fixes it by replacing raw_input with input to make
PY3 compatible.

Change-Id: I2f2f28cfd212bc3787833f4d61e38c74a4659261
Closes-Bug: #1595827
This commit is contained in:
yuyafei
2016-07-04 19:55:53 +08:00
parent b588b647cd
commit 4d4c85d9fb
3 changed files with 30 additions and 25 deletions

5
contrib/setup-tools/solum-app-setup.py Executable file → Normal file
View File

@@ -28,6 +28,7 @@ import string
import tempfile
import httplib2
import six
import yaml
from solumclient import client as solum_client
@@ -73,8 +74,8 @@ def _get_token(git_url):
exit(1)
full_repo_name = '/'.join([user_org_name, repo])
username = raw_input("Username for repo '%s' [%s]: " % (full_repo_name,
user_org_name))
username = six.moves.input("Username for repo '%s' [%s]: " %
(full_repo_name, user_org_name))
if not username:
username = user_org_name
password = getpass.getpass("Password: ")

View File

@@ -23,6 +23,7 @@ import re
import string
import httplib2
import six
class GitHubException(Exception):
@@ -66,7 +67,7 @@ class GitHubAuth(object):
if self._username is None:
prompt = ("Username for repo '%s' [%s]:" %
(self.full_repo_name, self.user_org_name))
self._username = raw_input(prompt) or self.user_org_name
self._username = six.moves.input(prompt) or self.user_org_name
return self._username
@property

View File

@@ -45,6 +45,7 @@ import sys
import httplib2
import jsonschema
from keystoneclient.v2_0 import client as keystoneclient
import six
import solumclient
from solumclient.common import cli_utils
@@ -555,7 +556,7 @@ Available commands:
app_name = args.name
elif app_data.get('name') is None:
while True:
app_name = raw_input("Please name the application.\n> ")
app_name = six.moves.input("Please name the application.\n> ")
if name_is_valid(app_name):
break
print(error_message)
@@ -602,11 +603,12 @@ Available commands:
fields = ['uuid', 'name', 'description',
'status', 'source_uri']
self._print_list(filtered_list, fields)
languagepack = raw_input("Please choose a languagepack from "
"the above list.\n> ")
languagepack = six.moves.input("Please choose a languagepack "
"from the above list.\n> ")
while languagepack not in lpnames + lp_uuids:
languagepack = raw_input("You must choose one of the named"
" language packs.\n> ")
languagepack = six.moves.input("You must choose one of "
"the named language "
"packs.\n> ")
app_data['languagepack'] = languagepack
else:
raise exc.CommandError("No languagepack in READY state. "
@@ -634,10 +636,10 @@ Available commands:
elif (app_data.get('source') is None or
app_data['source'].get('repository') is None or
app_data['source']['repository'] is ''):
git_url = raw_input("Please specify a git repository URL for "
"your application.\n> ")
git_rev_i = raw_input("Please specify revision"
" (default is master).\n> ")
git_url = six.moves.input("Please specify a git repository URL "
"for your application.\n> ")
git_rev_i = six.moves.input("Please specify revision"
"(default is master).\n> ")
if git_rev_i is '':
git_rev = 'master'
else:
@@ -654,8 +656,8 @@ Available commands:
private_sshkey = app_data['source'].get('private_ssh_key', '')
if is_private and not private_sshkey:
sshkey_file = raw_input("Please specify private sshkey file full "
"path: ")
sshkey_file = six.moves.input("Please specify private sshkey file "
"full path: ")
sshkey_file = sshkey_file.strip()
private_sshkey = read_private_sshkey(sshkey_file)
@@ -678,8 +680,8 @@ Available commands:
elif (app_data.get('workflow_config') is None or
app_data['workflow_config'].get('run_cmd') is '' or
app_data['workflow_config'].get('run_cmd') is None):
run_cmd = raw_input("Please specify start/run command for your "
"application.\n> ")
run_cmd = six.moves.input("Please specify start/run command for "
"your application.\n> ")
if app_data.get('workflow_config') is None:
run_cmd_dict = dict()
@@ -1493,7 +1495,7 @@ Available commands:
# Just ask.
else:
while True:
app_name = raw_input("Please name the application.\n> ")
app_name = six.moves.input("Please name the application.\n> ")
if name_is_valid(app_name):
break
print(error_message)
@@ -1518,11 +1520,12 @@ Available commands:
fields = ['uuid', 'name', 'description',
'status', 'source_uri']
self._print_list(filtered_list, fields)
languagepack = raw_input("Please choose a languagepack from "
"the above list.\n> ")
languagepack = six.moves.input("Please choose a languagepack "
"from the above list.\n> ")
while languagepack not in lpnames + lp_uuids:
languagepack = raw_input("You must choose one of the named"
" language packs.\n> ")
languagepack = six.moves.input("You must choose one of "
"the named language "
"packs.\n> ")
plan_definition['artifacts'][0]['language_pack'] = languagepack
else:
raise exc.CommandError("No languagepack in READY state. "
@@ -1536,8 +1539,8 @@ Available commands:
if args.git_url is not None:
plan_definition['artifacts'][0]['content']['href'] = args.git_url
if plan_definition['artifacts'][0]['content'].get('href') is None:
git_url = raw_input("Please specify a git repository URL for "
"your application.\n> ")
git_url = six.moves.input("Please specify a git repository URL "
"for your application.\n> ")
plan_definition['artifacts'][0]['content']['href'] = git_url
git_url = plan_definition['artifacts'][0]['content']['href']
@@ -1569,8 +1572,8 @@ Available commands:
if args.run_cmd is not None:
plan_definition['artifacts'][0]['run_cmd'] = args.run_cmd
if plan_definition['artifacts'][0].get('run_cmd') is None:
run_cmd = raw_input("Please specify start/run command for your "
"application.\n> ")
run_cmd = six.moves.input("Please specify start/run command for "
"your application.\n> ")
plan_definition['artifacts'][0]['run_cmd'] = run_cmd
# Check for unit test command