diff --git a/nilmdb/server/bulkdata.py b/nilmdb/server/bulkdata.py index ca979ed..252bf6e 100644 --- a/nilmdb/server/bulkdata.py +++ b/nilmdb/server/bulkdata.py @@ -14,7 +14,6 @@ import re import sys import tempfile -#from . import pyrocket as rocket from . import rocket # Up to 256 open file descriptors at any given time. diff --git a/nilmdb/server/pyrocket.py b/nilmdb/server/pyrocket.py deleted file mode 100644 index 5e47252..0000000 --- a/nilmdb/server/pyrocket.py +++ /dev/null @@ -1,142 +0,0 @@ -# Python implementation of the "rocket" data parsing interface. -# This interface translates between the binary format on disk -# and the ASCII format used when communicating with clients. - -# This is slow! Use the C version instead. - -from __future__ import absolute_import -import struct -import cStringIO -import itertools -from . import layout as _layout -import nilmdb.utils - -ERR_UNKNOWN = 0 -ERR_NON_MONOTONIC = 1 -ERR_OUT_OF_INTERVAL = 2 -class ParseError(Exception): - pass - -@nilmdb.utils.must_close(wrap_verify = False) -class Rocket(object): - def __init__(self, layout, filename): - self.layout = layout - if filename: - self.file = open(filename, "a+b") - else: - self.file = None - - # For packing/unpacking into a binary file. - # This will change in the C version - try: - (self.ltype, lcount) = layout.split('_', 2) - self.lcount = int(lcount) - except: - raise ValueError("no such layout: badly formatted string") - if self.lcount < 1: - raise ValueError("no such layout: bad count") - try: - struct_fmt = '= 0: - line = line.split('#', 1)[0] - line = line.strip() - if line == "": - continue - try: - (ts, row) = self.layoutparser.parse(line) - except ValueError as e: - raise ParseError(linenum, 0, ERR_UNKNOWN, e) - if ts <= last_timestamp: - raise ParseError(linenum, 0, ERR_NON_MONOTONIC, ts) - last_timestamp = ts - if ts < start or ts >= end: - raise ParseError(linenum, 0, ERR_OUT_OF_INTERVAL, ts) - self.append_iter(1, [row]) - written += 1 - return (written, indata.tell(), last_timestamp, linenum) - - def extract_list(self, offset, count): - """Extract count rows of data from the file at offset offset. - Return a list of lists [[row],[row],...]""" - ret = [] - self.file.seek(offset) - for i in xrange(count): - data = self.file.read(self.binary_size) - ret.append(list(self.packer.unpack(data))) - return ret - - def extract_string(self, offset, count): - """Extract count rows of data from the file at offset offset. - Return an ascii formatted string according to the layout""" - return self.formatter.format(self.extract_list(offset, count))