Browse Source

Fix rocket.ParseError exception handling

Before, a tuple was crammed into args[0].  Now, the three arguments are
args[0:2].
tags/nilmdb-1.3.0
Jim Paris 11 years ago
parent
commit
1ac6abdad0
2 changed files with 5 additions and 5 deletions
  1. +2
    -2
      nilmdb/server/bulkdata.py
  2. +3
    -3
      nilmdb/server/pyrocket.py

+ 2
- 2
nilmdb/server/bulkdata.py View File

@@ -367,7 +367,7 @@ class Table(object):
) = f.append_string(count, data, data_offset, linenum,
start, end, last_timestamp)
except rocket.ParseError as e:
(linenum, errtype, obj) = e.message
(linenum, errtype, obj) = e.args
if errtype == rocket.ERR_NON_MONOTONIC:
err = sprintf("line %d: timestamp is not monotonically "
"increasing", linenum)
@@ -381,7 +381,7 @@ class Table(object):
"end time %s", linenum,
ftts(obj), ftts(end))
else:
err = str(e)
err = str(obj)
raise ValueError("error parsing input data: " + err)
tot_rows += added_rows
except Exception:


+ 3
- 3
nilmdb/server/pyrocket.py View File

@@ -112,12 +112,12 @@ class Rocket(object):
try:
(ts, row) = self.layoutparser.parse(line)
except ValueError as e:
raise ParseError((linenum, ERR_UNKNOWN, e))
raise ParseError(linenum, ERR_UNKNOWN, e)
if ts <= last_timestamp:
raise ParseError((linenum, ERR_NON_MONOTONIC, ts))
raise ParseError(linenum, ERR_NON_MONOTONIC, ts)
last_timestamp = ts
if ts < start or ts >= end:
raise ParseError((linenum, ERR_OUT_OF_INTERVAL, ts))
raise ParseError(linenum, ERR_OUT_OF_INTERVAL, ts)
self.append_iter(1, [row])
written += 1
return (written, indata.tell(), last_timestamp, linenum)


Loading…
Cancel
Save