|
7 | 7 |
|
8 | 8 | b = pyslurm.hostlist() |
9 | 9 |
|
10 | | -hosts = "dummy0,dummy1,dummy1,dummy3,dummy4" |
11 | | -print("Creating hostlist ...... with {0}".format(hosts)) |
12 | | -if b.create(hosts): |
| 10 | +HOSTS = "dummy0,dummy1,dummy1,dummy3,dummy4" |
| 11 | +print(f"Creating hostlist ...... with {HOSTS}") |
| 12 | +if b.create(HOSTS): |
13 | 13 | print() |
14 | | - print("\tHost list count is {0}".format(b.count())) |
15 | | - node = "dummy3" |
16 | | - pos = b.find(node) |
| 14 | + print(f"\tHost list count is {b.count()}") |
| 15 | + NODE = "dummy3" |
| 16 | + pos = b.find(NODE) |
17 | 17 | if pos == -1: |
18 | | - print("Failed to find {0} in list".format(node)) |
| 18 | + print(f"Failed to find {NODE} in list") |
19 | 19 | else: |
20 | | - print("\tHost {0} found at position {1}".format(node, pos)) |
| 20 | + print(f"\tHost {NODE} found at position {pos}") |
21 | 21 | print("\tCalling uniq on current host list") |
22 | 22 | b.uniq() |
23 | 23 |
|
24 | | - print("\tNew host list is {0}".format(b.get())) |
25 | | - print("\tNew host list count is {0}".format(b.count())) |
26 | | - pos = b.find(node) |
| 24 | + print(f"\tNew host list is {b.get()}") |
| 25 | + print(f"\tNew host list count is {b.count()}") |
| 26 | + pos = b.find(NODE) |
27 | 27 | if pos == -1: |
28 | | - print("Failed to find {0} in list".format(node)) |
| 28 | + print(f"Failed to find {NODE}") |
29 | 29 | else: |
30 | | - print("\tHost {0} found at position {1}".format(node, pos)) |
| 30 | + print(f"\tHost {NODE} found at position {pos}") |
31 | 31 |
|
32 | | - print("\tRanged host list is {0}".format(b.get())) |
| 32 | + print(f"\tRanged host list is {b.get()}") |
33 | 33 | print() |
34 | 34 |
|
35 | | - node = "dummy18" |
36 | | - print("\tPushing new entry {0}".format(node)) |
37 | | - if b.push(node): |
| 35 | + NODE = "dummy18" |
| 36 | + print(f"\tPushing new entry {NODE}") |
| 37 | + if b.push(NODE): |
38 | 38 | print("\t\tSuccess !") |
39 | | - print("\tNew ranged list is {0}".format(b.get())) |
| 39 | + print(f"\tNew ranged list is {b.get()}") |
40 | 40 | else: |
41 | 41 | print("\t\tFailed !") |
42 | 42 | print() |
43 | 43 |
|
44 | 44 | print("\tDropping first host from list") |
45 | 45 | name = b.pop() |
46 | 46 | if name: |
47 | | - print("\t\tDropped host {0} from list".format(name)) |
48 | | - print("\t\tNew host count is {0}".format(b.count())) |
49 | | - print("\t\tNew host list is {0}".format(b.get())) |
| 47 | + print(f"\t\tDropped host {name} from list") |
| 48 | + print(f"\t\tNew host count is {b.count()}") |
| 49 | + print(f"\t\tNew host list is {b.get()}") |
50 | 50 | else: |
51 | 51 | print("\t\tFailed !") |
52 | 52 |
|
53 | 53 | print("Destroying host list") |
54 | 54 | b.destroy() |
55 | | - print("\tHost listcount is {0}".format(b.count())) |
| 55 | + print(f"\tHost listcount is {b.count()}") |
56 | 56 |
|
57 | 57 | else: |
58 | 58 | print("\tFailed to create initial list !") |
0 commit comments