Skip to content

Commit

Permalink
Merge pull request #63 from srisco/master
Browse files Browse the repository at this point in the history
Support Python 2 and 3 input
  • Loading branch information
micafer authored Oct 22, 2018
2 parents 4fadb51 + 2893a7f commit 2246dee
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ec3
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ class CmdLaunch:
if not options.restapi: raise Exception("option is not set")
if not options.dry_run and options.restapi[0].startswith("http:") and not options.restapi[0].startswith("http://localhost"):
CLI.display("WARNING: you are not using a secure connection and this can compromise the secrecy of the passwords and private keys available in the authorization file.")
if not options.yes and input("Continue [y/N]? ")[0:1].lower() != "y":
if not options.yes and get_input("Continue [y/N]? ")[0:1].lower() != "y":
sys.exit(1)
except Exception as e:
CLI.display("Error in -u/--restapi-url: %s" % str(e), level=logging.ERROR)
Expand Down Expand Up @@ -1068,7 +1068,7 @@ class CmdDestroy:
try:
r = ClusterStore.load(options.clustername)
CLI.display("WARNING: you are going to delete the infrastructure (including frontend and nodes).")
if not options.yes and input("Continue [y/N]? ")[0:1].lower() != "y":
if not options.yes and get_input("Continue [y/N]? ")[0:1].lower() != "y":
sys.exit(1)
new_im_server_url, infrId, _, auth = ClusterStore.get_im_server_infrId_and_vmId_and_auth(r)
if options.auth_file:
Expand Down Expand Up @@ -1641,7 +1641,7 @@ class CmdStop:
try:
r = ClusterStore.load(options.clustername)
CLI.display("WARNING: you are going to stop the infrastructure (including frontend and nodes).")
if not options.yes and input("Continue [y/N]? ")[0:1].lower() != "y":
if not options.yes and get_input("Continue [y/N]? ")[0:1].lower() != "y":
sys.exit(1)
cluster_im_server_url, infrId, _, auth = ClusterStore.get_im_server_infrId_and_vmId_and_auth(r)

Expand Down Expand Up @@ -1758,6 +1758,11 @@ def run_command(command, shell=False):
return output

if __name__ == "__main__":
# Support Python 2 and 3 input
get_input = input
if sys.version_info[:2] <= (2, 7):
get_input = raw_input

commands = [CmdLaunch, CmdList, CmdShow, CmdTemplates, CmdSsh, CmdReconfigure, CmdDestroy, CmdClone, CmdMigrate, CmdStop, CmdRestart]
try:
CLI.run(commands)
Expand Down

0 comments on commit 2246dee

Please sign in to comment.