Skip to content

Commit

Permalink
Make buildbot_json.py work even if natsort.py is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
maruel committed Apr 20, 2012
1 parent 7768fa3 commit 52b53f5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions master/contrib/buildbot_json.py
Expand Up @@ -22,8 +22,13 @@
import urllib2
import sys

try:
from natsort import natsorted
except ImportError:
# natsorted is a simple helper to sort "naturally", e.g. "vm40" is sorted
# after "vm7". Defaults to normal sorting.
natsorted = sorted

import natsort

# These values are buildbot constants used for Build and BuildStep.
# This line was copied from master/buildbot/status/builder.py.
Expand Down Expand Up @@ -1018,7 +1023,6 @@ def CMDinteractive(parser, args):
local_vars = {
'buildbot': buildbot,
'b': buildbot,
'natsort': natsort,
}
code.interact(prompt, None, local_vars)

Expand Down Expand Up @@ -1070,9 +1074,9 @@ def find_idle_busy_slaves(parser, args, show_idle):
slaves = builder.slaves.names
busy_slaves = [build.slave.name for build in builder.current_builds]
if show_idle:
slaves = natsort.natsorted(set(slaves) - set(busy_slaves))
slaves = natsorted(set(slaves) - set(busy_slaves))
else:
slaves = natsort.natsorted(set(slaves) & set(busy_slaves))
slaves = natsorted(set(slaves) & set(busy_slaves))
if options.quiet:
for slave in slaves:
print slave
Expand Down

0 comments on commit 52b53f5

Please sign in to comment.