Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Installs deps for using SDK emulator for testing. | 6 """Installs deps for using SDK emulator for testing. |
| 7 | 7 |
| 8 The script will download the SDK and system images, if they are not present, and | 8 The script will download the SDK and system images, if they are not present, and |
| 9 install and enable KVM, if virtualization has been enabled in the BIOS. | 9 install and enable KVM, if virtualization has been enabled in the BIOS. |
| 10 """ | 10 """ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 'android_tools', 'sdk', 'system-images', | 52 'android_tools', 'sdk', 'system-images', |
| 53 API_TARGET, 'x86')) | 53 API_TARGET, 'x86')) |
| 54 | 54 |
| 55 | 55 |
| 56 def CheckKVM(): | 56 def CheckKVM(): |
| 57 """Check if KVM is enabled. | 57 """Check if KVM is enabled. |
| 58 | 58 |
| 59 Returns: | 59 Returns: |
| 60 True if kvm-ok returns 0 (already enabled) | 60 True if kvm-ok returns 0 (already enabled) |
| 61 """ | 61 """ |
| 62 rc = cmd_helper.RunCmd(['kvm-ok']) | 62 try: |
| 63 return not rc | 63 return not cmd_helper.RunCmd(['kvm-ok']) |
| 64 except OSError: | |
| 65 return False | |
|
navabi
2013/04/08 20:11:48
Nice. I have this fix in this patch:
https://coder
| |
| 64 | 66 |
| 65 | 67 |
| 66 def GetSDK(): | 68 def GetSDK(): |
| 67 """Download the SDK and unzip in android_tools directory.""" | 69 """Download the SDK and unzip in android_tools directory.""" |
| 68 logging.info('Download Android SDK.') | 70 logging.info('Download Android SDK.') |
| 69 sdk_url = '%s/%s' % (SDK_BASE_URL, SDK_ZIP) | 71 sdk_url = '%s/%s' % (SDK_BASE_URL, SDK_ZIP) |
| 70 try: | 72 try: |
| 71 cmd_helper.RunCmd(['curl', '-o', '/tmp/sdk.zip', sdk_url]) | 73 cmd_helper.RunCmd(['curl', '-o', '/tmp/sdk.zip', sdk_url]) |
| 72 print 'curled unzipping...' | 74 print 'curled unzipping...' |
| 73 rc = cmd_helper.RunCmd(['unzip', '-o', '/tmp/sdk.zip', '-d', '/tmp/']) | 75 rc = cmd_helper.RunCmd(['unzip', '-o', '/tmp/sdk.zip', '-d', '/tmp/']) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 | 140 |
| 139 # Make sure KVM packages are installed and enabled. | 141 # Make sure KVM packages are installed and enabled. |
| 140 if CheckKVM(): | 142 if CheckKVM(): |
| 141 logging.info('KVM already installed and enabled.') | 143 logging.info('KVM already installed and enabled.') |
| 142 else: | 144 else: |
| 143 InstallKVM() | 145 InstallKVM() |
| 144 | 146 |
| 145 | 147 |
| 146 if __name__ == '__main__': | 148 if __name__ == '__main__': |
| 147 sys.exit(main(sys.argv)) | 149 sys.exit(main(sys.argv)) |
| OLD | NEW |