diff --git a/cython/py_imc_termite.pyx b/cython/py_imc_termite.pyx index 4c5500d..be7a8bd 100644 --- a/cython/py_imc_termite.pyx +++ b/cython/py_imc_termite.pyx @@ -22,7 +22,7 @@ cdef class imctermite: # get JSON list of channels def get_channels(self, bool data): chnlst = self.cpp_imc.get_channels(True,data) - chnlstjn = [jn.loads(chn.decode(errors="ignore"),parse_float=decimal.Decimal) for chn in chnlst] + chnlstjn = [jn.loads(chn.decode(errors="ignore")) for chn in chnlst] return chnlstjn # print channels @@ -32,7 +32,7 @@ cdef class imctermite: # print table including channels def print_table(self, string outputfile): chnlst = self.cpp_imc.get_channels(True,True) - chnlstjn = [jn.loads(chn.decode(errors="ignore"),parse_float=decimal.Decimal) for chn in chnlst] + chnlstjn = [jn.loads(chn.decode(errors="ignore")) for chn in chnlst] with open(outputfile.decode(),'w') as fout: for chn in chnlstjn: fout.write('#' +str(chn['xname']).rjust(19)+str(chn['yname']).rjust(20)+'\n') diff --git a/lib/imc_raw.hpp b/lib/imc_raw.hpp index 4f12176..b6ef834 100644 --- a/lib/imc_raw.hpp +++ b/lib/imc_raw.hpp @@ -174,7 +174,7 @@ namespace imc // check consistency of blocks void check_consistency() { - for ( unsigned long int b = 0; b < this->rawblocks_.size()-1; b++ ) + for ( unsigned long int b = 0; b < this->rawblocks_.size()-1 && this->rawblocks_.size() > 0; b++ ) { if ( this->rawblocks_[b].get_end() >= this->rawblocks_[b+1].get_begin() ) { diff --git a/src/main.cpp b/src/main.cpp index 9ddf0bf..9148d1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -178,6 +178,13 @@ int main(int argc, char* argv[]) return 1; } + // catch invalid or empty ".raw" file + if ( imcraw.blocks().size() == 0 ) + { + std::cerr<<"this appears to be an empty/invalid '.raw' file since no blocks were found"<<"\n"; + return 1; + } + // list blocks if ( cfgopts.count("listblocks") == 1 ) {