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