* py_imc_termite.pyx: remove json loads parse_float option
* imc_raw.hpp: catch empty/invalid file to avoid seg fault
This commit is contained in:
parent
16a77ecf1e
commit
e7094d0125
@ -22,7 +22,7 @@ cdef class imctermite:
|
|||||||
# get JSON list of channels
|
# get JSON list of channels
|
||||||
def get_channels(self, bool data):
|
def get_channels(self, bool data):
|
||||||
chnlst = self.cpp_imc.get_channels(True,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
|
return chnlstjn
|
||||||
|
|
||||||
# print channels
|
# print channels
|
||||||
@ -32,7 +32,7 @@ cdef class imctermite:
|
|||||||
# print table including channels
|
# print table including channels
|
||||||
def print_table(self, string outputfile):
|
def print_table(self, string outputfile):
|
||||||
chnlst = self.cpp_imc.get_channels(True,True)
|
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:
|
with open(outputfile.decode(),'w') as fout:
|
||||||
for chn in chnlstjn:
|
for chn in chnlstjn:
|
||||||
fout.write('#' +str(chn['xname']).rjust(19)+str(chn['yname']).rjust(20)+'\n')
|
fout.write('#' +str(chn['xname']).rjust(19)+str(chn['yname']).rjust(20)+'\n')
|
||||||
|
@ -174,7 +174,7 @@ namespace imc
|
|||||||
// check consistency of blocks
|
// check consistency of blocks
|
||||||
void check_consistency()
|
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() )
|
if ( this->rawblocks_[b].get_end() >= this->rawblocks_[b+1].get_begin() )
|
||||||
{
|
{
|
||||||
|
@ -178,6 +178,13 @@ int main(int argc, char* argv[])
|
|||||||
return 1;
|
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
|
// list blocks
|
||||||
if ( cfgopts.count("listblocks") == 1 )
|
if ( cfgopts.count("listblocks") == 1 )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user