| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 # A script which makes it easy to execute common DOM-related tasks | 7 # A script which makes it easy to execute common DOM-related tasks |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import subprocess | 10 import subprocess |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if argv: | 149 if argv: |
| 150 cmd.append(argv.pop(0)) | 150 cmd.append(argv.pop(0)) |
| 151 else: | 151 else: |
| 152 print( | 152 print( |
| 153 'Test commands should be followed by tests to run. Defaulting to html') | 153 'Test commands should be followed by tests to run. Defaulting to html') |
| 154 cmd.append('html') | 154 cmd.append('html') |
| 155 return call(cmd) | 155 return call(cmd) |
| 156 | 156 |
| 157 def call(args): | 157 def call(args): |
| 158 print ' '.join(args) | 158 print ' '.join(args) |
| 159 return subprocess.call(args, | 159 pipe = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 160 stdout=subprocess.STDOUT, | 160 output, error = pipe.communicate() |
| 161 stderr=subprocess.STDERR) | 161 if output: |
| 162 print output |
| 163 if error: |
| 164 print error |
| 165 return pipe.returncode |
| 162 | 166 |
| 163 def init_dir(): | 167 def init_dir(): |
| 164 ''' Makes sure that we're always rooted in the dart root folder.''' | 168 ''' Makes sure that we're always rooted in the dart root folder.''' |
| 165 dart_dir = os.path.abspath(os.path.join( | 169 dart_dir = os.path.abspath(os.path.join( |
| 166 os.path.dirname(os.path.realpath(__file__)), | 170 os.path.dirname(os.path.realpath(__file__)), |
| 167 os.path.pardir, os.path.pardir)) | 171 os.path.pardir, os.path.pardir)) |
| 168 os.chdir(dart_dir) | 172 os.chdir(dart_dir) |
| 169 | 173 |
| 170 commands = { | 174 commands = { |
| 171 'analyze': [analyze, 'Run the dart analyzer'], | 175 'analyze': [analyze, 'Run the dart analyzer'], |
| (...skipping 23 matching lines...) Expand all Loading... |
| 195 success = False | 199 success = False |
| 196 | 200 |
| 197 while (argv): | 201 while (argv): |
| 198 init_dir() | 202 init_dir() |
| 199 command = argv.pop(0) | 203 command = argv.pop(0) |
| 200 | 204 |
| 201 if not command in commands: | 205 if not command in commands: |
| 202 help(); | 206 help(); |
| 203 success = False | 207 success = False |
| 204 break | 208 break |
| 205 success = success and bool(commands[command][0]()) | 209 returncode = commands[command][0]() |
| 210 success = success and not bool(returncode) |
| 206 | 211 |
| 207 sys.exit(not success) | 212 sys.exit(not success) |
| 208 | 213 |
| 209 if __name__ == '__main__': | 214 if __name__ == '__main__': |
| 210 main(sys.argv) | 215 main(sys.argv) |
| OLD | NEW |