Mercurial > hg > truffle
comparison mx/commands.py @ 11511:3110bea9a6b0
mx: add helper method for yes/no question
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Mon, 02 Sep 2013 11:40:24 +0200 |
parents | 94779c895aad |
children | 38acec26d535 |
comparison
equal
deleted
inserted
replaced
11510:231958c9ddf9 | 11511:3110bea9a6b0 |
---|---|
93 envPath = join(_graal_home, 'mx', 'env') | 93 envPath = join(_graal_home, 'mx', 'env') |
94 mx.log('Please select the VM to be executed from the following: ') | 94 mx.log('Please select the VM to be executed from the following: ') |
95 items = [k for k in _vmChoices.keys() if _vmChoices[k] is not None] | 95 items = [k for k in _vmChoices.keys() if _vmChoices[k] is not None] |
96 descriptions = [_vmChoices[k] for k in _vmChoices.keys() if _vmChoices[k] is not None] | 96 descriptions = [_vmChoices[k] for k in _vmChoices.keys() if _vmChoices[k] is not None] |
97 vm = mx.select_items(items, descriptions, allowMultiple=False) | 97 vm = mx.select_items(items, descriptions, allowMultiple=False) |
98 answer = raw_input('Persist this choice by adding "DEFAULT_VM=' + vm + '" to ' + envPath + '? [Yn]: ') | 98 if mx.ask_yes_no('Persist this choice by adding "DEFAULT_VM=' + vm + '" to ' + envPath, 'y'): |
99 if not answer.lower().startswith('n'): | |
100 with open(envPath, 'a') as fp: | 99 with open(envPath, 'a') as fp: |
101 print >> fp, 'DEFAULT_VM=' + vm | 100 print >> fp, 'DEFAULT_VM=' + vm |
102 _vm = vm | 101 _vm = vm |
103 return vm | 102 return vm |
104 | 103 |
279 return os.path.abspath(join(_installed_jdks if _installed_jdks else _graal_home, 'jdk' + str(mx.java().version))) | 278 return os.path.abspath(join(_installed_jdks if _installed_jdks else _graal_home, 'jdk' + str(mx.java().version))) |
280 | 279 |
281 def _handle_missing_VM(bld, vm): | 280 def _handle_missing_VM(bld, vm): |
282 mx.log('The ' + bld + ' ' + vm + ' VM has not been created') | 281 mx.log('The ' + bld + ' ' + vm + ' VM has not been created') |
283 if sys.stdout.isatty(): | 282 if sys.stdout.isatty(): |
284 answer = raw_input('Build it now? [Yn]: ') | 283 if mx.ask_yes_no('Build it now', 'y'): |
285 if not answer.lower().startswith('n'): | |
286 with VM(vm, bld): | 284 with VM(vm, bld): |
287 build([]) | 285 build([]) |
288 return | 286 return |
289 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build the selected VM') | 287 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build the selected VM') |
290 | 288 |