Skip to content
Snippets Groups Projects
Commit d9060806 authored by sveseli's avatar sveseli
Browse files

fixed issue with directories being discovered as files

parent 000f81f7
No related branches found
No related tags found
No related merge requests found
...@@ -46,9 +46,13 @@ class DmFileSystemEventHandler(FileSystemEventHandler): ...@@ -46,9 +46,13 @@ class DmFileSystemEventHandler(FileSystemEventHandler):
files = glob.glob(os.path.join(event.src_path,'*')) files = glob.glob(os.path.join(event.src_path,'*'))
self.logger.debug('Processing directory event: %s , src path: %s' % (event.__dict__, event.src_path)) self.logger.debug('Processing directory event: %s , src path: %s' % (event.__dict__, event.src_path))
if len(files) > 0: if len(files) > 0:
filePath = max(files, key=os.path.getctime) sortedFiles = sorted(files, key=os.path.getctime, reverse=True)
self.logger.debug('Latest file: %s' % (filePath)) for filePath in sortedFiles:
self.fileSystemObserver.fileUpdated(filePath, self.dataDirectory, self.experiment) if os.path.isfile(filePath):
self.logger.debug('Latest file: %s' % (filePath))
self.fileSystemObserver.fileUpdated(filePath, self.dataDirectory, self.experiment)
return
self.logger.debug('No new files found in %s' % (event.src_path))
except Exception, ex: except Exception, ex:
self.logger.error('Exception occured when searching for file in directory %s: %s' % (event.__dict__, ex)) self.logger.error('Exception occured when searching for file in directory %s: %s' % (event.__dict__, ex))
else: else:
......
...@@ -110,7 +110,7 @@ class FileSystemObserver(threading.Thread,Singleton): ...@@ -110,7 +110,7 @@ class FileSystemObserver(threading.Thread,Singleton):
observedFile['statusMonitor'] = daqInfo observedFile['statusMonitor'] = daqInfo
observedFile.setLastUpdateTimeToNow() observedFile.setLastUpdateTimeToNow()
self.observedFileMap[filePath] = observedFile self.observedFileMap[filePath] = observedFile
self.logger.debug('Observed file updated: %s', observedFile) self.logger.debug('Observed file updated: %s', filePath)
@ThreadingUtility.synchronize @ThreadingUtility.synchronize
def checkObservedFilesForProcessing(self): def checkObservedFilesForProcessing(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment