From 248131ce173da3fd61e1b8d60f8c471b76059779 2012-11-22 13:59:15 From: Miguel Valdez Date: 2012-11-22 13:59:15 Subject: [PATCH] Metodo self.__waitNewBlock agreagado: Bug leyendo datos en linea. No esperaba un nuevo bloque, siempre saltaba al siguiente archivo. --- diff --git a/schainpy2/IO/JRODataIO.py b/schainpy2/IO/JRODataIO.py index 0ee3db2..9663c10 100644 --- a/schainpy2/IO/JRODataIO.py +++ b/schainpy2/IO/JRODataIO.py @@ -620,6 +620,36 @@ class JRODataReader(JRODataIO): self.nReadBlocks = 0 return 1 + def __waitNewBlock(self): + #si es OnLine y ademas aun no se han leido un bloque completo entonces se espera por uno valido + if not self.online: + return + + + if (self.nReadBlocks < self.m_ProcessingHeader.dataBlocksPerFile): + + currentPointer = self.fp.tell() + + for nTries in range( self.nTries ): + #self.fp.close() + + print "\tWaiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries+1) + time.sleep( self.delay ) + + #self.fp = open( self.filename, 'rb' ) + #self.fp.seek( fpointer ) + + self.fileSize = os.path.getsize( self.filename ) + currentSize = self.fileSize - currentPointer + + if ( currentSize >= neededSize ): + self.__rdBasicHeader() + return 1 + + return 0 + + return 1 + def __setNewBlock(self): if self.fp == None: return 0 @@ -634,6 +664,9 @@ class JRODataReader(JRODataIO): if (currentSize >= neededSize): self.__rdBasicHeader() return 1 + + if self.__waitNewBlock(): + return 1 if not(self.setNextFile()): return 0 diff --git a/schainpy2/IO/SpectraIO.py b/schainpy2/IO/SpectraIO.py index 13adaa4..3b6dc65 100644 --- a/schainpy2/IO/SpectraIO.py +++ b/schainpy2/IO/SpectraIO.py @@ -7,7 +7,7 @@ $Id$ import os, sys import numpy -import pyfits +#import pyfits import glob import fnmatch import time, datetime