Save warnings in output
This commit is contained in:
parent
1f7dbd80b3
commit
a5435e65dc
1 changed files with 6 additions and 2 deletions
|
@ -36,6 +36,7 @@ class Power:
|
|||
self.epochs = OrderedDict()
|
||||
self.first_ts = None
|
||||
self.last_ts = None
|
||||
self.warnings = ""
|
||||
|
||||
@classmethod
|
||||
def from_list(cls, data):
|
||||
|
@ -67,14 +68,14 @@ class Power:
|
|||
e = list(epochs)
|
||||
k = list(values.keys())
|
||||
if not e == k:
|
||||
print("Warning: Unexpected unsorted timestamps.")
|
||||
power.warnings += "# Warning: Unexpected unsorted timestamps.\n"
|
||||
|
||||
# check implicit assumptions: 2) each line has #nodes values
|
||||
nnodes = len(nodes)
|
||||
for epoch in epochs:
|
||||
actual = len(values[epoch])
|
||||
if actual != nnodes:
|
||||
print("Warning: Unexpected number of nodes ({actual}/{expected})".format(actual=actual, expected=nnodes))
|
||||
power.warnings += "# Warning: Unexpected number of nodes ({actual}/{expected})\n".format(actual=actual, expected=nnodes)
|
||||
break
|
||||
|
||||
return power
|
||||
|
@ -96,6 +97,7 @@ class Power:
|
|||
print("Error: cowardly refusing to overwrite file ", fname)
|
||||
return None
|
||||
|
||||
header += self.warnings
|
||||
try:
|
||||
with open(fname, "w+") as f:
|
||||
f.write(header + self.header())
|
||||
|
@ -247,6 +249,8 @@ class App:
|
|||
fn = power.to_file(jobid, header)
|
||||
if fn:
|
||||
print('Created file {fn}'.format(fn=fn))
|
||||
if power.warnings:
|
||||
print(power.warnings)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue