Skip to content

Commit

Permalink
Improve colouring in spalloc-machine
Browse files Browse the repository at this point in the history
Consistently chooses colours based on a function of the Job ID meaning that
when a machine diagram is updated the colour scheme is consistent (even if the
two-character keys change). This commit also triples the number of colours in
the palette.
  • Loading branch information
mossblaser committed Feb 23, 2016
1 parent 5ee72ec commit 7ed0920
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions spalloc/scripts/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,17 @@ def show_machine(t, machines, jobs, machine_name, compact=False):
# Extract list of jobs running on the machine
displayed_jobs = []
job_key_generator = iter(generate_keys())
job_colour_generator = iter(cycle([
t.green, t.blue, t.magenta,
t.yellow, t.cyan,
]))
job_colours = [
t.green, t.blue, t.magenta, t.yellow, t.cyan,
t.dim_green, t.dim_blue, t.dim_magenta, t.dim_yellow, t.dim_cyan,
t.bright_green, t.bright_blue, t.bright_magenta, t.bright_yellow,
t.bright_cyan,
]
for job in jobs:
if job["allocated_machine_name"] == machine_name:
displayed_jobs.append(job)
job["key"] = next(job_key_generator)
job["colour"] = next(job_colour_generator)
job["colour"] = job_colours[job["job_id"] % len(job_colours)]

# Calculate machine stats
num_boards = ((machine["width"] * machine["height"] * 3) -
Expand Down

0 comments on commit 7ed0920

Please sign in to comment.