[autotest] Bugfix to string formatting of num=None
Handle num=None as special case of string formatting
in task.py
BUG=chromium-os:38179
TEST=run suite_scheduler.py --sanity, see no string formatting
exception
Change-Id: Ibe96a4b09cb218875a68a689a327f35b5061c443
Reviewed-on: https://gerrit.chromium.org/gerrit/41933
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/site_utils/suite_scheduler/task.py b/site_utils/suite_scheduler/task.py
index 4e32fed..17e727a 100644
--- a/site_utils/suite_scheduler/task.py
+++ b/site_utils/suite_scheduler/task.py
@@ -160,8 +160,12 @@
# Since we expect __hash__() and other comparitor methods to be used
# frequently by set operations, and they use str() a lot, pre-compute
# the string representation of this object.
- self._str = '%s: %s on %s with pool %s, across %d machines' % (
- self.__class__.__name__, suite, branch_specs, pool, num)
+ if num is None:
+ numStr = '[Default num]'
+ else:
+ numStr = '%d' % num
+ self._str = '%s: %s on %s with pool %s, across %s machines' % (
+ self.__class__.__name__, suite, branch_specs, pool, numStr)
def _FitsSpec(self, branch):