| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/test/python_utils.h" | 5 #include "net/test/python_utils.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/command_line.h" |
| 8 #include "base/environment.h" | 9 #include "base/environment.h" |
| 9 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 15 | 16 |
| 16 const char kPythonPathEnv[] = "PYTHONPATH"; | 17 const char kPythonPathEnv[] = "PYTHONPATH"; |
| 17 | 18 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return false; | 97 return false; |
| 97 } | 98 } |
| 98 } | 99 } |
| 99 generated_code_dir = *dir; | 100 generated_code_dir = *dir; |
| 100 #endif | 101 #endif |
| 101 *dir = generated_code_dir.Append(kPyProto); | 102 *dir = generated_code_dir.Append(kPyProto); |
| 102 VLOG(2) << "Found " << kPyProto.value() << " in " << dir->value(); | 103 VLOG(2) << "Found " << kPyProto.value() << " in " << dir->value(); |
| 103 return true; | 104 return true; |
| 104 } | 105 } |
| 105 | 106 |
| 106 bool GetPythonRunTime(FilePath* dir) { | 107 bool GetPythonCommand(CommandLine* python_cmd) { |
| 108 DCHECK(python_cmd); |
| 109 FilePath dir; |
| 107 #if defined(OS_WIN) | 110 #if defined(OS_WIN) |
| 108 if (!PathService::Get(base::DIR_SOURCE_ROOT, dir)) | 111 if (!PathService::Get(base::DIR_SOURCE_ROOT, &dir)) |
| 109 return false; | 112 return false; |
| 110 *dir = dir->Append(FILE_PATH_LITERAL("third_party")) | 113 dir = dir.Append(FILE_PATH_LITERAL("third_party")) |
| 111 .Append(FILE_PATH_LITERAL("python_26")) | 114 .Append(FILE_PATH_LITERAL("python_26")) |
| 112 .Append(FILE_PATH_LITERAL("python.exe")); | 115 .Append(FILE_PATH_LITERAL("python.exe")); |
| 113 #elif defined(OS_POSIX) | 116 #elif defined(OS_POSIX) |
| 114 *dir = FilePath("python"); | 117 dir = FilePath("python"); |
| 115 #endif | 118 #endif |
| 119 |
| 120 python_cmd->SetProgram(dir); |
| 121 |
| 122 #if defined(OS_POSIX) |
| 123 // Launch python in unbuffered mode, so that python output doesn't mix with |
| 124 // gtest output in buildbot log files. See http://crbug.com/147368. |
| 125 python_cmd->AppendArg("-u"); |
| 126 #endif |
| 127 |
| 116 return true; | 128 return true; |
| 117 } | 129 } |
| OLD | NEW |