| OLD | NEW |
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # 1. Redistributions of source code must retain the above copyright | 7 # 1. Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # 2. Redistributions in binary form must reproduce the above copyright | 9 # 2. Redistributions in binary form must reproduce the above copyright |
| 10 # notice, this list of conditions and the following disclaimer in the | 10 # notice, this list of conditions and the following disclaimer in the |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 command.extend(['--results-directory', self.server.options.results_d
irectory]) | 105 command.extend(['--results-directory', self.server.options.results_d
irectory]) |
| 106 if not self.server.options.optimize: | 106 if not self.server.options.optimize: |
| 107 command.append('--no-optimize') | 107 command.append('--no-optimize') |
| 108 if self.server.options.verbose: | 108 if self.server.options.verbose: |
| 109 command.append('--verbose') | 109 command.append('--verbose') |
| 110 json_input = self.read_entity_body() | 110 json_input = self.read_entity_body() |
| 111 | 111 |
| 112 _log.debug("calling %s, input='%s'", command, json_input) | 112 _log.debug("calling %s, input='%s'", command, json_input) |
| 113 return_code, output, error = self._run_webkit_patch(command, json_input) | 113 return_code, output, error = self._run_webkit_patch(command, json_input) |
| 114 print >> sys.stderr, error | 114 print >> sys.stderr, error |
| 115 json_result = {"return_code": return_code} |
| 115 if return_code: | 116 if return_code: |
| 116 _log.error("rebaseline-json failed: %d, output='%s'" % (return_code,
output)) | 117 _log.error("rebaseline-json failed: %d, output='%s'" % (return_code,
output)) |
| 118 json_result["output"] = output |
| 117 else: | 119 else: |
| 118 _log.debug("rebaseline-json succeeded") | 120 _log.debug("rebaseline-json succeeded") |
| 119 | 121 |
| 120 # FIXME: propagate error and/or log messages back to the UI. | 122 self._serve_text(json.dumps(json_result)) |
| 121 self._serve_text('success') | |
| 122 | 123 |
| 123 def localresult(self): | 124 def localresult(self): |
| 124 path = self.query['path'][0] | 125 path = self.query['path'][0] |
| 125 filesystem = self.server.tool.filesystem | 126 filesystem = self.server.tool.filesystem |
| 126 | 127 |
| 127 # Ensure that we're only serving files from inside the results directory
. | 128 # Ensure that we're only serving files from inside the results directory
. |
| 128 if not filesystem.isabs(path) and self.server.options.results_directory: | 129 if not filesystem.isabs(path) and self.server.options.results_directory: |
| 129 fullpath = filesystem.abspath(filesystem.join(self.server.options.re
sults_directory, path)) | 130 fullpath = filesystem.abspath(filesystem.join(self.server.options.re
sults_directory, path)) |
| 130 if fullpath.startswith(filesystem.abspath(self.server.options.result
s_directory)): | 131 if fullpath.startswith(filesystem.abspath(self.server.options.result
s_directory)): |
| 131 self._serve_file(fullpath, headers_only=(self.command == 'HEAD')
) | 132 self._serve_file(fullpath, headers_only=(self.command == 'HEAD')
) |
| 132 return | 133 return |
| 133 | 134 |
| 134 self.send_response(403) | 135 self.send_response(403) |
| OLD | NEW |