| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2009-2011 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009-2011 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Package builder for the dev server.""" | 7 """Package builder for the dev server.""" |
| 8 import os | 8 import os |
| 9 import subprocess | 9 import subprocess |
| 10 import sys |
| 10 | 11 |
| 11 import cherrypy | 12 import cherrypy |
| 12 | 13 |
| 13 | 14 |
| 14 def _OutputOf(command): | 15 def _OutputOf(command): |
| 15 """Runs command, a list of arguments beginning with an executable. | 16 """Runs command, a list of arguments beginning with an executable. |
| 16 | 17 |
| 17 If the executable begins with "scripts/", the path is adjusted to | 18 If the executable begins with "scripts/", the path is adjusted to |
| 18 the scripts directory of this chroot. | 19 the scripts directory of this chroot. |
| 19 | 20 |
| 20 Args: | 21 Args: |
| 21 command: A list of arguments, beginning with the executable | 22 command: A list of arguments, beginning with the executable |
| 22 Returns: | 23 Returns: |
| 23 The output of the command | 24 The output of the command |
| 24 Raises: | 25 Raises: |
| 25 subprocess.CalledProcessError if the command fails | 26 subprocess.CalledProcessError if the command fails |
| 26 """ | 27 """ |
| 27 scripts = 'scripts/' | 28 scripts = 'scripts/' |
| 28 if command[0].find(scripts) == 0: | 29 if command[0].find(scripts) == 0: |
| 29 command[0] = command[0].replace(scripts, '../../' + scripts) | 30 server_dir = os.path.dirname(os.path.abspath(sys.argv[0])) |
| 31 command[0] = command[0].replace(scripts, server_dir + '/../../' + scripts) |
| 30 command_name = ' '.join(command) | 32 command_name = ' '.join(command) |
| 31 cherrypy.log('Executing: ' + command_name, 'BUILD') | 33 cherrypy.log('Executing: ' + command_name, 'BUILD') |
| 32 | 34 |
| 33 p = subprocess.Popen(command, stdout=subprocess.PIPE) | 35 p = subprocess.Popen(command, stdout=subprocess.PIPE) |
| 34 output_blob = p.communicate()[0] | 36 output_blob = p.communicate()[0] |
| 35 if p.returncode != 0: | 37 if p.returncode != 0: |
| 36 raise subprocess.CalledProcessError(p.returncode, command_name) | 38 raise subprocess.CalledProcessError(p.returncode, command_name) |
| 37 return output_blob | 39 return output_blob |
| 38 | 40 |
| 39 | 41 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 rc = subprocess.call(['eclean-' + board, '-d', 'packages']) | 82 rc = subprocess.call(['eclean-' + board, '-d', 'packages']) |
| 81 if rc != 0: | 83 if rc != 0: |
| 82 return self.SetError('eclean failed') | 84 return self.SetError('eclean failed') |
| 83 | 85 |
| 84 cherrypy.log('eclean complete %s' % pkg, 'BUILD') | 86 cherrypy.log('eclean complete %s' % pkg, 'BUILD') |
| 85 return 'Success\n' | 87 return 'Success\n' |
| 86 except OSError, e: | 88 except OSError, e: |
| 87 return self.SetError('Could not execute build command: ' + str(e)) | 89 return self.SetError('Could not execute build command: ' + str(e)) |
| 88 finally: | 90 finally: |
| 89 os.environ['USE'] = original_use | 91 os.environ['USE'] = original_use |
| OLD | NEW |