|
@@
-124,6
+124,43
def isFileinThisTime(filename, startTime, endTime):
|
|
124
|
|
|
124
|
|
|
125
|
return thisDatetime
|
|
125
|
return thisDatetime
|
|
126
|
|
|
126
|
|
|
|
|
|
127
|
def getFileFromSet(path,ext,set):
|
|
|
|
|
128
|
validFilelist = []
|
|
|
|
|
129
|
fileList = os.listdir(path)
|
|
|
|
|
130
|
|
|
|
|
|
131
|
# 0 1234 567 89A BCDE
|
|
|
|
|
132
|
# H YYYY DDD SSS .ext
|
|
|
|
|
133
|
|
|
|
|
|
134
|
for file in fileList:
|
|
|
|
|
135
|
try:
|
|
|
|
|
136
|
year = int(file[1:5])
|
|
|
|
|
137
|
doy = int(file[5:8])
|
|
|
|
|
138
|
|
|
|
|
|
139
|
|
|
|
|
|
140
|
except:
|
|
|
|
|
141
|
continue
|
|
|
|
|
142
|
|
|
|
|
|
143
|
if (os.path.splitext(file)[-1].lower() != ext.lower()):
|
|
|
|
|
144
|
continue
|
|
|
|
|
145
|
|
|
|
|
|
146
|
validFilelist.append(file)
|
|
|
|
|
147
|
|
|
|
|
|
148
|
myfile = fnmatch.filter(validFilelist,'*%4.4d%3.3d%3.3d*'%(year,doy,set))
|
|
|
|
|
149
|
|
|
|
|
|
150
|
if len(myfile)!= 0:
|
|
|
|
|
151
|
return myfile[0]
|
|
|
|
|
152
|
else:
|
|
|
|
|
153
|
filename = '*%4.4d%3.3d%3.3d%s'%(year,doy,set,ext.lower())
|
|
|
|
|
154
|
print 'the filename %s does not exist'%filename
|
|
|
|
|
155
|
print '...going to the last file: '
|
|
|
|
|
156
|
|
|
|
|
|
157
|
if validFilelist:
|
|
|
|
|
158
|
validFilelist = sorted( validFilelist, key=str.lower )
|
|
|
|
|
159
|
return validFilelist[-1]
|
|
|
|
|
160
|
|
|
|
|
|
161
|
return None
|
|
|
|
|
162
|
|
|
|
|
|
163
|
|
|
127
|
def getlastFileFromPath(path, ext):
|
|
164
|
def getlastFileFromPath(path, ext):
|
|
128
|
"""
|
|
165
|
"""
|
|
129
|
Depura el fileList dejando solo los que cumplan el formato de "PYYYYDDDSSS.ext"
|
|
166
|
Depura el fileList dejando solo los que cumplan el formato de "PYYYYDDDSSS.ext"
|
|
@@
-439,7
+476,7
class JRODataReader(JRODataIO, ProcessingUnit):
|
|
439
|
|
|
476
|
|
|
440
|
return pathList, filenameList
|
|
477
|
return pathList, filenameList
|
|
441
|
|
|
478
|
|
|
442
|
def __searchFilesOnLine(self, path, expLabel = "", ext = None, walk=True):
|
|
479
|
def __searchFilesOnLine(self, path, expLabel = "", ext = None, walk=True, set=None):
|
|
443
|
|
|
480
|
|
|
444
|
"""
|
|
481
|
"""
|
|
445
|
Busca el ultimo archivo de la ultima carpeta (determinada o no por startDateTime) y
|
|
482
|
Busca el ultimo archivo de la ultima carpeta (determinada o no por startDateTime) y
|
|
@@
-467,7
+504,7
class JRODataReader(JRODataIO, ProcessingUnit):
|
|
467
|
|
|
504
|
|
|
468
|
if not walk:
|
|
505
|
if not walk:
|
|
469
|
fullpath = path
|
|
506
|
fullpath = path
|
|
470
|
foldercounter = ''
|
|
507
|
foldercounter = 0
|
|
471
|
else:
|
|
508
|
else:
|
|
472
|
#Filtra solo los directorios
|
|
509
|
#Filtra solo los directorios
|
|
473
|
for thisPath in os.listdir(path):
|
|
510
|
for thisPath in os.listdir(path):
|
|
@@
-490,15
+527,18
class JRODataReader(JRODataIO, ProcessingUnit):
|
|
490
|
|
|
527
|
|
|
491
|
print "%s folder was found: " %(fullpath )
|
|
528
|
print "%s folder was found: " %(fullpath )
|
|
492
|
|
|
529
|
|
|
|
|
|
530
|
if set == None:
|
|
493
|
filename = getlastFileFromPath(fullpath, ext)
|
|
531
|
filename = getlastFileFromPath(fullpath, ext)
|
|
|
|
|
532
|
else:
|
|
|
|
|
533
|
filename = getFileFromSet(fullpath, ext, set)
|
|
494
|
|
|
534
|
|
|
495
|
if not(filename):
|
|
535
|
if not(filename):
|
|
496
|
return None, None, None, None, None
|
|
536
|
return None, None, None, None, None, None
|
|
497
|
|
|
537
|
|
|
498
|
print "%s file was found" %(filename)
|
|
538
|
print "%s file was found" %(filename)
|
|
499
|
|
|
539
|
|
|
500
|
if not(self.__verifyFile(os.path.join(fullpath, filename))):
|
|
540
|
if not(self.__verifyFile(os.path.join(fullpath, filename))):
|
|
501
|
return None, None, None, None, None
|
|
541
|
return None, None, None, None, None, None
|
|
502
|
|
|
542
|
|
|
503
|
year = int( filename[1:5] )
|
|
543
|
year = int( filename[1:5] )
|
|
504
|
doy = int( filename[5:8] )
|
|
544
|
doy = int( filename[5:8] )
|
|
@@
-672,6
+712,10
class JRODataReader(JRODataIO, ProcessingUnit):
|
|
672
|
self.__rdBasicHeader()
|
|
712
|
self.__rdBasicHeader()
|
|
673
|
return 1
|
|
713
|
return 1
|
|
674
|
|
|
714
|
|
|
|
|
|
715
|
if self.fileSize == self.fileSizeByHeader:
|
|
|
|
|
716
|
# self.flagEoF = True
|
|
|
|
|
717
|
return 0
|
|
|
|
|
718
|
|
|
675
|
print "\tWaiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries+1)
|
|
719
|
print "\tWaiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries+1)
|
|
676
|
time.sleep( self.delay )
|
|
720
|
time.sleep( self.delay )
|
|
677
|
|
|
721
|
|
|
@@
-684,18
+728,29
class JRODataReader(JRODataIO, ProcessingUnit):
|
|
684
|
return
|
|
728
|
return
|
|
685
|
|
|
729
|
|
|
686
|
csize = self.fileSize - self.fp.tell()
|
|
730
|
csize = self.fileSize - self.fp.tell()
|
|
|
|
|
731
|
blocksize = self.processingHeaderObj.blockSize
|
|
687
|
|
|
732
|
|
|
688
|
#sata el primer bloque de datos
|
|
733
|
#salta el primer bloque de datos
|
|
689
|
if csize > self.processingHeaderObj.blockSize:
|
|
734
|
if csize > self.processingHeaderObj.blockSize:
|
|
690
|
self.fp.seek(self.fp.tell() + self.processingHeaderObj.blockSize)
|
|
735
|
self.fp.seek(self.fp.tell() + blocksize)
|
|
691
|
else:
|
|
736
|
else:
|
|
692
|
return
|
|
737
|
return
|
|
693
|
|
|
738
|
|
|
694
|
csize = self.fileSize - self.fp.tell()
|
|
739
|
csize = self.fileSize - self.fp.tell()
|
|
695
|
neededsize = self.processingHeaderObj.blockSize + self.basicHeaderSize
|
|
740
|
neededsize = self.processingHeaderObj.blockSize + self.basicHeaderSize
|
|
696
|
factor = int(csize/neededsize)
|
|
741
|
while True:
|
|
697
|
if factor > 0:
|
|
742
|
|
|
698
|
self.fp.seek(self.fp.tell() + factor*neededsize)
|
|
743
|
if self.fp.tell()<self.fileSize:
|
|
|
|
|
744
|
self.fp.seek(self.fp.tell() + neededsize)
|
|
|
|
|
745
|
else:
|
|
|
|
|
746
|
self.fp.seek(self.fp.tell() - neededsize)
|
|
|
|
|
747
|
break
|
|
|
|
|
748
|
|
|
|
|
|
749
|
# csize = self.fileSize - self.fp.tell()
|
|
|
|
|
750
|
# neededsize = self.processingHeaderObj.blockSize + self.basicHeaderSize
|
|
|
|
|
751
|
# factor = int(csize/neededsize)
|
|
|
|
|
752
|
# if factor > 0:
|
|
|
|
|
753
|
# self.fp.seek(self.fp.tell() + factor*neededsize)
|
|
699
|
|
|
754
|
|
|
700
|
self.flagIsNewFile = 0
|
|
755
|
self.flagIsNewFile = 0
|
|
701
|
self.__isFirstTimeOnline = 0
|
|
756
|
self.__isFirstTimeOnline = 0
|
|
@@
-854,7
+909,7
class JRODataReader(JRODataIO, ProcessingUnit):
|
|
854
|
endDate=None,
|
|
909
|
endDate=None,
|
|
855
|
startTime=datetime.time(0,0,0),
|
|
910
|
startTime=datetime.time(0,0,0),
|
|
856
|
endTime=datetime.time(23,59,59),
|
|
911
|
endTime=datetime.time(23,59,59),
|
|
857
|
set=0,
|
|
912
|
set=None,
|
|
858
|
expLabel = "",
|
|
913
|
expLabel = "",
|
|
859
|
ext = None,
|
|
914
|
ext = None,
|
|
860
|
online = False,
|
|
915
|
online = False,
|
|
@@
-871,7
+926,7
class JRODataReader(JRODataIO, ProcessingUnit):
|
|
871
|
print "Searching files in online mode..."
|
|
926
|
print "Searching files in online mode..."
|
|
872
|
|
|
927
|
|
|
873
|
for nTries in range( self.nTries ):
|
|
928
|
for nTries in range( self.nTries ):
|
|
874
|
fullpath, foldercounter, file, year, doy, set = self.__searchFilesOnLine(path=path, expLabel=expLabel, ext=ext, walk=walk)
|
|
929
|
fullpath, foldercounter, file, year, doy, set = self.__searchFilesOnLine(path=path, expLabel=expLabel, ext=ext, walk=walk, set=set)
|
|
875
|
|
|
930
|
|
|
876
|
if fullpath:
|
|
931
|
if fullpath:
|
|
877
|
break
|
|
932
|
break
|