OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client 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 """Class capturing a command invocation as data.""" | 6 """Class capturing a command invocation as data.""" |
7 | 7 |
8 | 8 |
9 # Done first to setup python module path. | 9 # Done first to setup python module path. |
10 import toolchain_env | 10 import toolchain_env |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 # TODO(bradnelson): Replace with something less hacky. | 120 # TODO(bradnelson): Replace with something less hacky. |
121 return Command([ | 121 return Command([ |
122 sys.executable, '-c', | 122 sys.executable, '-c', |
123 'import sys,shutil; shutil.copyfile(sys.argv[1], sys.argv[2])', src, dst]) | 123 'import sys,shutil; shutil.copyfile(sys.argv[1], sys.argv[2])', src, dst]) |
124 | 124 |
125 | 125 |
126 def RemoveDirectory(path): | 126 def RemoveDirectory(path): |
127 """Convenience method for generating a command to remove a directory tree.""" | 127 """Convenience method for generating a command to remove a directory tree.""" |
128 # TODO(mcgrathr): Windows | 128 # TODO(mcgrathr): Windows |
129 return Command(['rm', '-rf', path]) | 129 return Command(['rm', '-rf', path]) |
| 130 |
| 131 |
| 132 def Remove(path): |
| 133 """Convenience method for generating a command to remove a file.""" |
| 134 # TODO(mcgrathr): Replace with something less hacky. |
| 135 return Command([ |
| 136 sys.executable, '-c', |
| 137 'import sys, os; os.remove(sys.argv[1])', path |
| 138 ]) |
| 139 |
| 140 |
| 141 def Rename(src, dst): |
| 142 """Convenience method for generating a command to rename a file.""" |
| 143 # TODO(mcgrathr): Replace with something less hacky. |
| 144 return Command([ |
| 145 sys.executable, '-c', |
| 146 'import sys, os; os.rename(sys.argv[1], sys.argv[2])', src, dst |
| 147 ]) |
| 148 |
| 149 |
| 150 def WriteData(data, dst): |
| 151 """Convenience method to write a file with fixed contents.""" |
| 152 # TODO(mcgrathr): Replace with something less hacky. |
| 153 return Command([ |
| 154 sys.executable, '-c', |
| 155 'import sys; open(sys.argv[1], "wb").write(%r)' % data, dst |
| 156 ]) |
OLD | NEW |