Hi,
while testing sheet2pcp for the first time I noticed the error messages
and error handling could be improved a bit. The below patch gives clear
indication of a) wrong file name / type used and b) invalid datetime
used (otherwise will see those "Use of uninitialized value" messages
and timestamp for all records in the archives will be the Epoch).
There's still one case which I saw but I'm not sure how to best address
it, namely if you mistakenly have something like this in the map file:
<metric pmid="60.1.1" indom="60.0" units="1,0,0,PM_SPACE_KBYTE,0,0"
type="PM_TYPE_U64" sem="PM_SEM_INSTANT">mem.util.used</metric>
That is, indom defined for a singular metric, then you'll get:
pmiGetHandle: failed to create handle for metricspec mem.util.used: No error
Perhaps the earlier pmiAddMetric() error handling should be revisited
to have more descriptive error messages.
---
src/sheet2pcp/sheet2pcp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/sheet2pcp/sheet2pcp b/src/sheet2pcp/sheet2pcp
index d3db0db..f5dc2b8 100755
--- a/src/sheet2pcp/sheet2pcp
+++ b/src/sheet2pcp/sheet2pcp
@@ -100,7 +100,12 @@ sub dodate($)
else { $yy += 1900; }
}
- return $yy . "-" . $mm . "-" . $dd . "T" . $field[3] . ":" . $field[4] .
":" . $field[5];
+ my $tstr = $yy . "-" . $mm . "-" . $dd . "T" . $field[3] . ":" . $field[4]
. ":" . $field[5];
+ if (!defined(str2time($tstr, $zone))) {
+ print "sheet2pcp: Failed to parse the time format\n";
+ exit(1);
+ }
+ return $tstr;
}
# process the mapfile and set up the metadata and handles needed
@@ -519,6 +524,7 @@ elsif ($ARGV[0] =~ /\.xlsx$/) {
}
else {
print "sheet2pcp: Error: No clue how to deduce format of spreadsheet
$ARGV[0]\n";
+ print "File extension must be one of: .csv, .ods, .xls, .xlsx\n";
exit(1);
}
Thanks,
--
Marko Myllynen
|