def get(self): pngname = '%s%s' % (self.directory , self.png) if self.png != '' and os.path.exists(pngname) and os.path.isfile(pngname): return open(pngname).read() else: vsince = str(self.validateIOVIntervals(self.since)) files = PlotsNamesCreator.generateNames(self.tag, vsince, self.fileType) generate = False for file in files:#check if files that should be generated already exist name = '%s%s' % (self.directory, file) if file == '' or not os.path.exists(name) or not os.path.isfile(name): generate = True break; if generate: cfgfile = CfgFileGenerator.generateCfg(self.dbName, self.tag, vsince, self.directory) os.system('pushd %s; cmsRun %s; popd' % (self.directory, cfgfile)) if self.png != '' and os.path.exists(pngname) and os.path.isfile(pngname): return open(pngname).read() elif os.path.exists('%s%s' % (self.directory, files[0])) and os.path.isfile('%s%s' % (self.directory, files[0])): return open('%s%s' % (self.directory, files[0])).read() else: raise ValueError('File not found.') else: if len(files) > 0: return open('%s%s' % (self.directory, files[0])).read() else: raise ValueError('unable to generate files for given parameters.')
def _create(self): cfgfile = CfgFileGenerator.generateCfg(self._dbName, self._tag, self._since, self._directory) #if self._tag == 'SiStripDetVOff_GR10_v1_prompt_100705V0': dir = os.getcwd() #raise Exception('Found TAG: cd %s; cmsRun %s; cd %' % (self._directory, cfgfile, dir)) #raise Exception('lala' + 'pushd %s; cmsRun %s; popd' % (self._directory, cfgfile)) os.system('pushd %s; cmsRun %s; popd' % (self._directory, cfgfile))