def __init__(self, fileSettings, timeslot, areaSettings, hostSettings, optional=False, parent=None, logger=None): ''' Inputs fileSettings - A systemsettings.models.File object defined in the XML file. timeslot - A datetime.datetime object areaSettings - A systemsettings.models.Area object hostSettings - A systemsettings.models.Host object optional - A boolean indicating if the object is optional or not. parent - A operations.core.g2pacakges.G2Package object. ''' super(G2File, self).__init__(timeslot, areaSettings, host=hostSettings, logger=logger) self.name = fileSettings.name self.parent = parent self.optional = optional self.toCopy = fileSettings.toCopy self.toCompress = fileSettings.toCompress self.toArchive = fileSettings.toArchive self.toDisseminate = fileSettings.toDisseminate self.toDelete = fileSettings.toDelete for extraInfo in fileSettings.fileextrainfo_set.all(): exec('self.%s = utilities.parse_marked(extraInfo, self)' % extraInfo.name) self.numFiles = fileSettings.numFiles self.exceptHours = [eh.hour for eh in fileSettings.exceptHours.all()] self.fileType = fileSettings.fileType self.frequency = fileSettings.frequency self.searchPaths = [] for filePathObj in fileSettings.filepath_set.all(): #relativePath = utilities.parse_marked(filePathObj, self) relativePath = self.get_path(filePathObj, self) #self.searchPaths.append(os.path.join(self.host.basePath, # relativePath)) self.searchPaths.append(relativePath) self.searchPatterns = [] for searchPattObj in fileSettings.filepattern_set.all(): pattern = utilities.parse_marked(searchPattObj, self) self.searchPatterns.append(pattern) #hf = HostFactory(log_level=log_level) specific_archives = fileSettings.specificArchives.all() if len(specific_archives) == 0: specific_archives = [hs for hs in ss.Host.objects.filter(role__name='archive')] #hf = HostFactory() #self.archives = [hf.create_host(hs) for hs in specific_archives] self.io_buffers = self._get_io_buffers(fileSettings) self.archives = self._get_archives(fileSettings)
def get_path(self, markedString, obj): ''' Return a path that has been specified via the markedString mechanism. Inputs: markedString ''' if markedString.string == 'fromOriginator': dirName = markedString.name parentPackObj = None parent = ss.Package.objects.get(name=self.parent.name) packOutsSettings = parent.packageOutput_systemsettings_packageoutput_related.all( ) if len(packOutsSettings) > 0: # the parent package has outputs if self.name in [ po.outputItem.name for po in packOutsSettings ]: # this instance is an output of its own parent package parentPackObj = self.parent if parentPackObj is None: # haven't been able to find out the package that originated # this instance yet for pSetts in ss.Package.objects.all(): outpSetts = pSetts.packageOutput_systemsettings_packageoutput_related.all( ) for pOut in outpSetts: if pOut.outputItem.name == self.name: #self.logger.info('%s\'s parent is %s' % # (self.name, pSetts.name)) parentPackObj = self._create_originator_pack(pOut) fullPath = eval('parentPackObj.%s' % dirName) correctedDateDirs = self._correct_date_directories(fullPath) # trimming the first character in order to eliminate the '/' relativePath = correctedDateDirs.replace(self.parent.host.dataPath, '')[1:] thePath = relativePath else: thePath = utilities.parse_marked(markedString, obj) return thePath
def get_path(self, markedString, obj): ''' Return a path that has been specified via the markedString mechanism. Inputs: markedString ''' if markedString.string == 'fromOriginator': dirName = markedString.name parentPackObj = None parent = ss.Package.objects.get(name=self.parent.name) packOutsSettings = parent.packageOutput_systemsettings_packageoutput_related.all() if len(packOutsSettings) > 0: # the parent package has outputs if self.name in [po.outputItem.name for po in packOutsSettings]: # this instance is an output of its own parent package parentPackObj = self.parent if parentPackObj is None: # haven't been able to find out the package that originated # this instance yet for pSetts in ss.Package.objects.all(): outpSetts = pSetts.packageOutput_systemsettings_packageoutput_related.all() for pOut in outpSetts: if pOut.outputItem.name == self.name: #self.logger.info('%s\'s parent is %s' % # (self.name, pSetts.name)) parentPackObj = self._create_originator_pack(pOut) fullPath = eval('parentPackObj.%s' % dirName) correctedDateDirs = self._correct_date_directories(fullPath) # trimming the first character in order to eliminate the '/' relativePath = correctedDateDirs.replace(self.parent.host.dataPath, '')[1:] thePath = relativePath else: thePath = utilities.parse_marked(markedString, obj) return thePath
def __init__(self, fileSettings, timeslot, areaSettings, hostSettings, optional=False, parent=None, logger=None): ''' Inputs fileSettings - A systemsettings.models.File object defined in the XML file. timeslot - A datetime.datetime object areaSettings - A systemsettings.models.Area object hostSettings - A systemsettings.models.Host object optional - A boolean indicating if the object is optional or not. parent - A operations.core.g2pacakges.G2Package object. ''' super(G2File, self).__init__(timeslot, areaSettings, host=hostSettings, logger=logger) self.name = fileSettings.name self.parent = parent self.optional = optional self.toCopy = fileSettings.toCopy self.toCompress = fileSettings.toCompress self.toArchive = fileSettings.toArchive self.toDisseminate = fileSettings.toDisseminate self.toDelete = fileSettings.toDelete for extraInfo in fileSettings.fileextrainfo_set.all(): exec('self.%s = utilities.parse_marked(extraInfo, self)' % extraInfo.name) self.numFiles = fileSettings.numFiles self.exceptHours = [eh.hour for eh in fileSettings.exceptHours.all()] self.fileType = fileSettings.fileType self.frequency = fileSettings.frequency self.searchPaths = [] for filePathObj in fileSettings.filepath_set.all(): #relativePath = utilities.parse_marked(filePathObj, self) relativePath = self.get_path(filePathObj, self) #self.searchPaths.append(os.path.join(self.host.basePath, # relativePath)) self.searchPaths.append(relativePath) self.searchPatterns = [] for searchPattObj in fileSettings.filepattern_set.all(): pattern = utilities.parse_marked(searchPattObj, self) self.searchPatterns.append(pattern) #hf = HostFactory(log_level=log_level) specific_archives = fileSettings.specificArchives.all() if len(specific_archives) == 0: specific_archives = [ hs for hs in ss.Host.objects.filter(role__name='archive') ] #hf = HostFactory() #self.archives = [hf.create_host(hs) for hs in specific_archives] self.io_buffers = self._get_io_buffers(fileSettings) self.archives = self._get_archives(fileSettings)