@@ -82,9 +82,9 @@ def blockprint(title, d, p, pd):
82
82
title (str): The title of the block.
83
83
d (dict): Dictionary containing detailed metrics.
84
84
p (int): Parameter used in formatting the output.
85
- pd (dict): Dictionary containing overall metrics for comparison.
85
+ pd (dict, None ): Dictionary containing overall metrics for comparison.
86
86
"""
87
- if pd != 0 :
87
+ if pd is not None :
88
88
s = " - %.1f%% of total" % (float (d ["glideins" ]) / float (pd ["glideins" ]) * 100.0 )
89
89
t = ""
90
90
else :
@@ -191,16 +191,16 @@ def lineprint(entry_name, entry, g_entry, g, to_be_printed, attr_list, sort_attr
191
191
s = "total_time"
192
192
193
193
# For Sorting
194
- list = dict (entry , ** g_entry ) # combine the two dictionaries
194
+ e_list = dict (entry , ** g_entry ) # combine the two dictionaries
195
195
div = 1
196
196
if attr_list [sort_attribute ] in ["FailedNr" , "JobsNr_None" ]:
197
197
div = float (g_entry ["glideins" ])
198
198
elif attr_list [sort_attribute ] in ["validation_All" , "validation" , "idle" , "wst" , "badput" ]:
199
199
div = float (entry [s ])
200
200
if attr_list [sort_attribute ] == "wst" :
201
- sorter = int ((float (list ["waste" ]) / div ) * 100 )
201
+ sorter = int ((float (e_list ["waste" ]) / div ) * 100 )
202
202
else :
203
- sorter = int ((float (list [attr_list [sort_attribute ]]) / div ) * 100 )
203
+ sorter = int ((float (e_list [attr_list [sort_attribute ]]) / div ) * 100 )
204
204
205
205
if totals is not None :
206
206
ekeys = ("FailedNr" , "validation_All" , "JobsNr_None" , s )
@@ -297,7 +297,7 @@ USAGE:
297
297
298
298
# flags
299
299
x = 24
300
- dir = os .getcwd ()
300
+ w_dir = os .getcwd ()
301
301
sorting = 0
302
302
fe_sorting = 0
303
303
sort_attribute = 0
@@ -318,7 +318,7 @@ USAGE:
318
318
if o == "-x" :
319
319
x = a
320
320
elif o == "--source" :
321
- dir = a
321
+ w_dir = a
322
322
elif o in ("-h" , "-help" ):
323
323
print (usage )
324
324
return
@@ -411,10 +411,10 @@ USAGE:
411
411
"wastemill_data" : "rrd_Log_Completed_WasteTime.xml" ,
412
412
}
413
413
414
- if "http" in dir :
415
- file_dir = os .path .join (dir )
414
+ if "http" in w_dir :
415
+ file_dir = os .path .join (w_dir )
416
416
else :
417
- file_dir = os .path .join (dir , "monitor" )
417
+ file_dir = os .path .join (w_dir , "monitor" )
418
418
if not os .path .isdir (file_dir ):
419
419
# Try RPM location
420
420
rpmdir = "/var/lib/gwms-factory/work-dir"
@@ -423,17 +423,20 @@ USAGE:
423
423
print ("\n Cannot open" , file_dir )
424
424
print ("Please set --source to the factory work dir and try again." )
425
425
sys .exit (1 )
426
- if dir != os .getcwd ():
426
+ if w_dir != os .getcwd ():
427
427
# Directory explicitly set, print warning
428
428
print ("\n WARNING: Cannot open" , file_dir )
429
429
print ("Using RPM default %s instead" % rpmfile_dir )
430
- dir = rpmdir
430
+ w_dir = rpmdir
431
431
file_dir = rpmfile_dir
432
432
433
433
for name , xml in rrd_list .items ():
434
434
try :
435
435
file_loc = os .path .join (file_dir , xml )
436
- u = urlopen ("file://" + file_loc )
436
+ if "://" in file_loc :
437
+ u = urlopen (file_loc )
438
+ else :
439
+ u = open (file_loc )
437
440
data [name ] = xmlParse .xmlfile2dict (u )
438
441
except Exception :
439
442
print ("\n Cannot open" , file_loc )
@@ -613,7 +616,7 @@ Glidein log analysis for frontend %s - %s
613
616
######################################################################
614
617
615
618
# sort periods from least to greatest, with 24 hours at the top
616
- period_list = sorted (period_data .keys ())
619
+ period_list = sorted (list ( period_data .keys () ))
617
620
period_list .remove (86400 )
618
621
period_list .insert (0 , 86400 )
619
622
@@ -643,7 +646,7 @@ Glidein log analysis for frontend %s - %s
643
646
644
647
if show_block :
645
648
print ("----------------------------------------\n %s:\n " % title )
646
- blockprint (title , period_data [p ], p , 0 )
649
+ blockprint (title , period_data [p ], p , None )
647
650
648
651
################################################################################
649
652
# Print per entry stats (all frontends)
@@ -671,9 +674,19 @@ Per Entry (all frontends) stats for the past %s hours.\n"""
671
674
entry ["validation" ] = 1
672
675
673
676
lineprint (entry_name , entry , entry , 0 , to_be_printed , attr_list , sort_attribute , min_limit , totals )
674
- lineprint (
675
- "Total/Average" , totals ["entry" ], totals ["g_entry" ], 0 , totals_to_be_printed , attr_list , sort_attribute , {}
676
- )
677
+ if len (totals ) > 0 :
678
+ lineprint (
679
+ "Total/Average" ,
680
+ totals ["entry" ],
681
+ totals ["g_entry" ],
682
+ 0 ,
683
+ totals_to_be_printed ,
684
+ attr_list ,
685
+ sort_attribute ,
686
+ {},
687
+ )
688
+ else :
689
+ print ("No Entries with Glideins." )
677
690
print (totals_to_be_printed [0 ][1 ])
678
691
print (LINEPRINT_HEADER_DIV )
679
692
@@ -697,7 +710,7 @@ Per Entry (all frontends) stats for the past %s hours.\n"""
697
710
---------------------------------------
698
711
---------------------------------------
699
712
Per Entry (per frontend) stats for the past %s hours.\n """
700
- % ( x )
713
+ % x
701
714
)
702
715
else :
703
716
units = ["Slots" , "Seconds" , "Hours" ]
@@ -706,7 +719,7 @@ Per Entry (per frontend) stats for the past %s hours.\n"""
706
719
---------------------------------------
707
720
---------------------------------------
708
721
Frontend stats for the past %s hours.\n """
709
- % ( x )
722
+ % x
710
723
)
711
724
print (
712
725
"%-25s%7s %7s %3s %7s %3s %7s %3s %7s %3s %7s %3s %4s\n "
0 commit comments