Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """Code to find swarming_client.""" | 6 """Code to find swarming_client.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import sys | |
| 10 | |
| 11 from common import find_depot_tools # pylint: disable=W0611 | |
| 12 | |
| 13 # From depot_tools/ | |
| 14 import subprocess2 | |
| 9 | 15 |
| 10 | 16 |
| 11 def find_client(base_dir): | 17 def find_client(base_dir): |
| 12 """Returns the path to swarming_client if found. | 18 """Returns the path to swarming_client if found. |
| 13 | 19 |
| 14 |base_dir| will be in general os.getcwd(), so the script is very dependent on | 20 |base_dir| will be in general os.getcwd(), so the script is very dependent on |
| 15 CWD. CWD should be the base directory of the checkout. It has always been the | 21 CWD. CWD should be the base directory of the checkout. It has always been the |
| 16 case. | 22 case. |
| 17 """ | 23 """ |
| 18 src_swarming_client = os.path.join( | 24 src_swarming_client = os.path.join( |
| 19 base_dir, 'src', 'tools', 'swarming_client') | 25 base_dir, 'src', 'tools', 'swarming_client') |
| 20 if os.path.isdir(src_swarming_client): | 26 if os.path.isdir(src_swarming_client): |
| 21 return src_swarming_client | 27 return src_swarming_client |
| 22 | 28 |
| 23 # This is the previous path. This can be removed around 2013-12-01. | 29 # This is the previous path. This can be removed around 2013-12-01. |
| 24 src_swarm_client = os.path.join(base_dir, 'src', 'tools', 'swarm_client') | 30 src_swarm_client = os.path.join(base_dir, 'src', 'tools', 'swarm_client') |
| 25 if os.path.isdir(src_swarm_client): | 31 if os.path.isdir(src_swarm_client): |
| 26 return src_swarm_client | 32 return src_swarm_client |
| 33 | |
| 34 | |
| 35 def get_version(client): | |
| 36 """Returns the version of swarming.py client tool, if available.""" | |
| 37 try: | |
| 38 version = subprocess2.check_output( | |
| 39 [ | |
| 40 sys.executable, | |
| 41 os.path.join(client, 'swarming.py'), | |
| 42 '--version', | |
| 43 ]) | |
| 44 except (subprocess2.CalledProcessError, OSError): | |
| 45 return None | |
| 46 return map(int, version.split('.')) | |
|
Isaac (away)
2013/08/27 01:35:20
This returns a generator -- convert to a list?
M-A Ruel
2013/08/27 12:23:37
http://docs.python.org/2/library/functions.html#ma
Isaac (use chromium)
2013/08/27 17:43:00
Hmm, I must be remembering correctly. Weird.
I u
| |
| OLD | NEW |