11#!/usr/bin/env python
2-
2+ """
3+ Retrieve list of blocked items
4+ """
35from __future__ import print_function
46
57import pyslurm
6- from time import gmtime , strftime
78
8- def display (block_dict ):
99
10+ def display (block_dict ):
11+ """Format output"""
1012 if block_dict :
1113
12- date_fields = [ ]
14+ date_fields = []
1315
14- print (' {0:*^80}' .format ('' ))
16+ print (" {0:*^80}" .format ("" ))
1517
1618 for key , value in block_dict .items ():
1719
@@ -22,19 +24,23 @@ def display(block_dict):
2224 ddate = value [part_key ]
2325 if ddate == 0 :
2426 print ("\t {0:<17} : N/A" .format (part_key ))
25- elif (' reason_uid' in part_key ) and (value [' reason' ] is None ):
27+ elif (" reason_uid" in part_key ) and (value [" reason" ] is None ):
2628 print ("\t {0:<17} :" .format (part_key ))
2729 else :
2830 ddate = pyslurm .epoch2date (ddate )
2931 print ("\t {0:<17} : {1}" .format (part_key , ddate ))
30- elif part_key == 'connection_type' :
31- print ("\t {0:<17} : {1}" .format (part_key , pyslurm .get_connection_type (value [part_key ])))
32- elif part_key == 'state' :
32+ elif part_key == "connection_type" :
33+ print (
34+ "\t {0:<17} : {1}" .format (
35+ part_key , pyslurm .get_connection_type (value [part_key ])
36+ )
37+ )
38+ elif part_key == "state" :
3339 print ("\t {0:<17} : {1}" .format (part_key , value [part_key ]))
3440 else :
3541 print ("\t {0:<17} : {1}" .format (part_key , value [part_key ]))
3642
37- print (' {0:*^80}' .format ('' ))
43+ print (" {0:*^80}" .format ("" ))
3844
3945
4046if __name__ == "__main__" :
@@ -43,15 +49,11 @@ def display(block_dict):
4349 try :
4450 a .load ()
4551 block_dict = a .get ()
46- except ValueError as e :
47- print ("Block query failed - {0}" .format (e .args [0 ]))
52+ except ValueError as value_error :
53+ print ("Block query failed - {0}" .format (value_error .args [0 ]))
4854 else :
49- if len (block_dict ) > 0 :
50-
55+ if block_dict :
5156 display (block_dict )
52- print ()
53- print ("Block IDs - {0}" .format (a .ids ()))
54- print ()
55-
57+ print ("\n Block IDs - {0}\n " .format (a .ids ()))
5658 else :
5759 print ("No Blocks found !" )
0 commit comments