| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The LUCI Authors. All rights reserved. | 2 # Copyright 2013 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """Client tool to trigger tasks or retrieve results from a Swarming server.""" | 6 """Client tool to trigger tasks or retrieve results from a Swarming server.""" |
| 7 | 7 |
| 8 __version__ = '0.8.7' | 8 __version__ = '0.8.7' |
| 9 | 9 |
| 10 import collections | 10 import collections |
| (...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 | 1143 |
| 1144 for bot in natsort.natsorted(bots, key=lambda x: x['bot_id']): | 1144 for bot in natsort.natsorted(bots, key=lambda x: x['bot_id']): |
| 1145 if options.dead_only: | 1145 if options.dead_only: |
| 1146 if not bot.get('is_dead'): | 1146 if not bot.get('is_dead'): |
| 1147 continue | 1147 continue |
| 1148 elif not options.keep_dead and bot.get('is_dead'): | 1148 elif not options.keep_dead and bot.get('is_dead'): |
| 1149 continue | 1149 continue |
| 1150 | 1150 |
| 1151 # If the user requested to filter on dimensions, ensure the bot has all the | 1151 # If the user requested to filter on dimensions, ensure the bot has all the |
| 1152 # dimensions requested. | 1152 # dimensions requested. |
| 1153 dimensions = {i['key']: i.get('value') for i in bot['dimensions']} | 1153 dimensions = {i['key']: i.get('value') for i in bot.get('dimensions', {})} |
| 1154 for key, value in options.dimensions: | 1154 for key, value in options.dimensions: |
| 1155 if key not in dimensions: | 1155 if key not in dimensions: |
| 1156 break | 1156 break |
| 1157 # A bot can have multiple value for a key, for example, | 1157 # A bot can have multiple value for a key, for example, |
| 1158 # {'os': ['Windows', 'Windows-6.1']}, so that --dimension os=Windows will | 1158 # {'os': ['Windows', 'Windows-6.1']}, so that --dimension os=Windows will |
| 1159 # be accepted. | 1159 # be accepted. |
| 1160 if isinstance(dimensions[key], list): | 1160 if isinstance(dimensions[key], list): |
| 1161 if value not in dimensions[key]: | 1161 if value not in dimensions[key]: |
| 1162 break | 1162 break |
| 1163 else: | 1163 else: |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 dispatcher = subcommand.CommandDispatcher(__name__) | 1635 dispatcher = subcommand.CommandDispatcher(__name__) |
| 1636 return dispatcher.execute(OptionParserSwarming(version=__version__), args) | 1636 return dispatcher.execute(OptionParserSwarming(version=__version__), args) |
| 1637 | 1637 |
| 1638 | 1638 |
| 1639 if __name__ == '__main__': | 1639 if __name__ == '__main__': |
| 1640 subprocess42.inhibit_os_error_reporting() | 1640 subprocess42.inhibit_os_error_reporting() |
| 1641 fix_encoding.fix_encoding() | 1641 fix_encoding.fix_encoding() |
| 1642 tools.disable_buffering() | 1642 tools.disable_buffering() |
| 1643 colorama.init() | 1643 colorama.init() |
| 1644 sys.exit(main(sys.argv[1:])) | 1644 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |