| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium 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 # Windows can't run .sh files, so this is a small python wrapper around | 6 # Windows can't run .sh files, so this is a small python wrapper around |
| 7 # update.sh. | 7 # update.sh. |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import subprocess | 10 import subprocess |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 if __name__ == '__main__': | 13 |
| 14 def main(): |
| 14 if sys.platform in ['win32', 'cygwin']: | 15 if sys.platform in ['win32', 'cygwin']: |
| 15 sys.exit(0) | 16 return 0 |
| 16 | 17 |
| 17 # This script is called by gclient. gclient opens its hooks subprocesses with | 18 # This script is called by gclient. gclient opens its hooks subprocesses with |
| 18 # (stdout=subprocess.PIPE, stderr=subprocess.STDOUT) and then does custom | 19 # (stdout=subprocess.PIPE, stderr=subprocess.STDOUT) and then does custom |
| 19 # output processing that breaks printing '\r' characters for single-line | 20 # output processing that breaks printing '\r' characters for single-line |
| 20 # updating status messages as printed by curl and wget. | 21 # updating status messages as printed by curl and wget. |
| 21 # Work around this by setting stderr of the update.sh process to stdin (!): | 22 # Work around this by setting stderr of the update.sh process to stdin (!): |
| 22 # gclient doesn't redirect stdin, and while stdin itself is read-only, the | 23 # gclient doesn't redirect stdin, and while stdin itself is read-only, the |
| 23 # subprocess module dup()s it in the child process - and a dup()ed sys.stdin | 24 # subprocess module dup()s it in the child process - and a dup()ed sys.stdin |
| 24 # is writable, try | 25 # is writable, try |
| 25 # fd2 = os.dup(sys.stdin.fileno()); os.write(fd2, 'hi') | 26 # fd2 = os.dup(sys.stdin.fileno()); os.write(fd2, 'hi') |
| 26 # TODO: Fix gclient instead, http://crbug.com/95350 | 27 # TODO: Fix gclient instead, http://crbug.com/95350 |
| 27 subprocess.call( | 28 return subprocess.call( |
| 28 [os.path.join(os.path.dirname(__file__), 'update.sh')] + sys.argv[1:], | 29 [os.path.join(os.path.dirname(__file__), 'update.sh')] + sys.argv[1:], |
| 29 stderr=sys.stdin) | 30 stderr=sys.stdin) |
| 31 |
| 32 |
| 33 if __name__ == '__main__': |
| 34 sys.exit(main()) |
| OLD | NEW |