def __init__(self, archi_info, session_info, debug, script): self.user_info = UserInfo() self.archi_info = archi_info self.session_info = session_info self.debug = debug self.script = script self.checker = DetectManager(self.archi_info, self.user_info, self.session_info, self.script, self.debug) self.logger = logging.getLogger('MA5')
def further_install(self, opts): # initialization install_delphes = False install_delphesMA5tune = False user_info = UserInfo() # A few useful methods def validate_bool_key(key): if not isinstance(opts[key], bool): self.logger.warning( 'Unknown value for the further_install key ' + key + '. Ignoring.') return False return opts[key] def update_options(usrkey, value): inname = os.path.join(MA5_root_path, 'madanalysis', 'input', 'installation_options.dat') outname = os.path.join(MA5_root_path, 'madanalysis', 'input', 'installation_options.new') infile = open(inname, 'r') outfile = open(outname, 'w') for line in infile: if usrkey in line: outfile.write(usrkey + ' = ' + value + '\n') else: outfile.write(line) infile.close() outfile.close() shutil.move(outname, inname) def setinc(key, usrkey, value, archi_reset=''): if opts[key] not in [True, None] and os.path.isdir(opts[key]): user_info.SetValue(usrkey, value, '') update_options(usrkey, value) if archi_reset != '': self.main.archi_info.__dict__[ archi_reset.keys()[0]] = archi_reset.values()[0] elif opts[key] not in [True, None]: self.logger.warning('Non-existing ' + key.replace('with-','') + \ ' path. Automatic detection used.') elif usrkey == 'root_veto': update_options(usrkey, value) # Configuration for key in opts.keys(): value = opts[key] if key == 'veto-delphes': user_info.delphes_veto = validate_bool_key(key) elif key == 'veto-delphesMA5tune': user_info.delphesMA5tune_veto = validate_bool_key(key) elif key == 'veto-root': user_info.root_veto = validate_bool_key(key) if user_info.root_veto == True: self.main.session_info.has_root = False killroot1=[ 'root_bin_path', 'root_version', 'root_inc_path', 'root_compiler', \ 'root_lib_path' ] killroot2 = ['root_original_bins', 'root_features'] for x in killroot1: self.main.archi_info.__dict__[x] = '' for x in killroot2: self.main.archi_info.__dict__[x] = [] self.main.archi_info.has_root = False setinc(key, 'root_veto', '1') del self.main.archi_info.libraries['TH1F.h'] del self.main.archi_info.libraries['libCore.so'] elif key == 'with-zlib': if not isinstance(opts[key], bool): setinc(key, 'zlib_libs', opts[key] + '/lib', archi_reset={'zlib_original_libs': []}) setinc(key, 'zlib_includes', opts[key] + '/include') elif key == 'with-fastjet': setinc(key, 'fastjet_bin_path', opts[key]) elif key == 'with-root': setinc(key, 'root_bin_path', opts[key]) elif key == 'with-delphes': install_delphes = validate_bool_key(key) elif key == 'with-delphesMA5tune': install_delphesMA5tune = validate_bool_key(key) else: raise UNK_OPT('Unknown options for further_install') # Muting the logger lvl = self.logger.getEffectiveLevel() self.setLogLevel(10) # updating the configuration internally def config_update(checkup): if not checkup.CheckOptionalProcessingPackages(): self.logger.error( 'Impossible to internally update the paths of the dependences.' ) return False arch_to_update = [ 'has_zlib', 'zlib_lib', 'zlib_lib_path', 'zlib_inc_path', 'zlib_original_libs',\ 'fastjet_bin_path', 'fastjet_original_bins', 'toPATH1', 'fastjet_lib_paths', 'toLDPATH1', \ 'has_fastjet', 'root_bin_path', 'root_original_bins', 'root_version', 'libraries', \ 'root_inc_path', 'root_features', 'root_compiler', 'root_lib_path' ] for x in arch_to_update: self.main.archi_info.__dict__[x] = checkup.archi_info.__dict__[ x] checkup = CheckUp(self.main.archi_info, self.main.session_info, True, self.main.script) checkup.user_info = user_info checkup.checker.user_info = user_info config_update(checkup) # If not zlib -> install zlib if not self.main.archi_info.has_zlib: self.logger.info( 'The zlib package has not been found. Proceeding with its local installation.' ) installer = InstallManager(self.main) if not installer.Execute('zlib'): self.logger.error('Impossible to install zlib.') return False # If not fastjet -> install fastjet if not self.main.archi_info.has_fastjet: self.logger.info( 'The fastjet package has not been found. Proceeding with its local installation.' ) installer = InstallManager(self.main) if not installer.Execute('fastjet'): self.logger.error('Impossible to install fastjet.') return False # Delphes installation if self.main.archi_info.has_root and user_info.delphes_veto and install_delphes: self.logger.warning( 'Delphes has been both vetoed and non-vetoed. Ignoring veto.') user_info.delphes_veto = False elif self.main.archi_info.has_root and user_info.delphes_veto: self.logger.info( 'Delphes installation has been vetoed. Skipping it.') if not self.main.archi_info.has_root and install_delphes: self.logger.warning( 'The root package has not been found. Skipping the delphes installation.' ) if self.main.archi_info.has_root and install_delphes: self.logger.info('Proceeding with the delphes installation.') installer = InstallManager(self.main) if not installer.Execute('delphes'): self.logger.error('Impossible to install delphes.') return False self.logger.info('Proceeding with the PAD installation.') if not installer.Execute('pad'): self.logger.error('Impossible to install the PAD.') return False # DelphesMA5tune installation root_v = (len(self.main.archi_info.root_version) == 3) and (int( self.main.archi_info.root_version[0]) == 5) if self.main.archi_info.has_root and user_info.delphesMA5tune_veto and install_delphesMA5tune: self.logger.warning( 'DelphesMA5tune has been both vetoed and non-vetoed. Ignoring veto.' ) user_info.delphesMA5tune_veto = False elif self.main.archi_info.has_root and user_info.delphesMA5tune_veto: self.logger.info( 'DelphesMA5tune installation has been vetoed. Skipping it.') if not self.main.archi_info.has_root and install_delphesMA5tune: self.logger.warning( 'The root package has not been found. Skipping the delphesMA5tune installation.' ) if not self.main.archi_info.has_root and install_delphesMA5tune and not root_v: self.logger.warning( 'DelphesMA5tune is not compatible with root 6. Skipping its installation.' ) if self.main.archi_info.has_root and install_delphesMA5tune and root_v: self.logger.info( 'Proceeding with the delphesMA5tune installation.') installer = InstallManager(self.main) if not installer.Execute('delphesMA5tune'): self.logger.error('Impossible to install delphesMA5tune.') return False self.logger.info('Proceeding with the PADForMA5tune installation.') if not installer.Execute('padforma5tune'): self.logger.error('Impossible to install the PADForMA5tune.') return False # Compilation if not self.main.CheckConfig(debug=False): raise MA5Configuration('Issue with the configuration') self.compile() # restoring the log level self.setLogLevel(lvl) return True
def Activate(self): # output = 1: activation successfull. # output = 0: nothing is done. # output = -1: error user_info = UserInfo() user_info.ReadUserOptions( self.main.archi_info.ma5dir + '/madanalysis/input/installation_options.dat') checker = ConfigChecker(self.main.archi_info, user_info, self.main.session_info, self.main.script, False) hasdelphes = checker.checkDelphes(True) if hasdelphes: # Paths delpath = os.path.normpath( self.main.archi_info.delphes_lib_paths[0]) deldeac = delpath.replace("DEACT_", "") self.main.archi_info.delphes_lib = self.main.archi_info.delphes_lib.replace( "DEACT_", "") self.main.archi_info.delphes_original_libs =\ [x.replace("DEACT_","") for x in self.main.archi_info.delphes_original_libs] self.main.archi_info.delphes_inc_paths =\ [ x.replace("DEACT_","") for x in self.main.archi_info.delphes_inc_paths ] if len(self.main.archi_info.delphes_inc_paths) > 2: del self.main.archi_info.delphes_inc_paths[-1] del self.main.archi_info.delphes_inc_paths[-1] self.main.archi_info.delphes_lib_paths =\ list(set([ x.replace("DEACT_","") for x in self.main.archi_info.delphes_lib_paths ])) # do we have to activate delphes? if not 'DEACT' in delpath: return 0 self.logger.warning("Delphes is deactivated. Activating it.") # naming shutil.move(delpath, deldeac) # Compiler setup compiler = LibraryWriter('lib', self.main) ncores = compiler.get_ncores2() from madanalysis.build.setup_writer import SetupWriter SetupWriter.WriteSetupFile( True, self.main.archi_info.ma5dir + '/tools/SampleAnalyzer/', self.main.archi_info) SetupWriter.WriteSetupFile( False, self.main.archi_info.ma5dir + '/tools/SampleAnalyzer/', self.main.archi_info) # if ncores>1: # strcores='-j'+str(ncores) ToBuild = ['delphes', 'root', 'process'] # Makefile self.main.archi_info.has_delphes = True self.main.archi_info.delphes_priority = True dpath = os.path.normpath( os.path.join(self.main.archi_info.ma5dir, 'tools', 'delphes')) mylib = os.path.normpath(os.path.join(dpath, 'libDelphes.so')) self.main.archi_info.libraries['Delphes'] = mylib + ":" + str( os.stat(mylib).st_mtime) self.main.archi_info.toLDPATH1 = [ x for x in self.main.archi_info.toLDPATH1 if not 'MA5tune' in x ] self.main.archi_info.toLDPATH1.append(dpath) for mypackage in ToBuild: if not compiler.WriteMakefileForInterfaces(mypackage): self.logger.error("library building aborted.") return -1 # Cleaning for mypackage in ToBuild: myfolder = 'Process' if mypackage != 'process': myfolder = 'Interfaces' if not compiler.MrProper( mypackage, self.main.archi_info.ma5dir + '/tools/SampleAnalyzer/' + myfolder): self.logger.error("Library '" + mypackage + "' precleaning aborted.") return -1 # Compiling for mypackage in ToBuild: myfolder = 'Process' if mypackage != 'process': myfolder = 'Interfaces' if not compiler.Compile( ncores, mypackage, self.main.archi_info.ma5dir + '/tools/SampleAnalyzer/' + myfolder): self.logger.error("Library '" + mypackage + "' compilation aborted.") return -1 # Linking for mypackage in ToBuild: myfolder = 'Process' if mypackage != 'process': myfolder = 'Interfaces' if not compiler.Link( mypackage, self.main.archi_info.ma5dir + '/tools/SampleAnalyzer/' + myfolder): self.logger.error("Library '" + mypackage + "' linking aborted.") return -1 # Checking for mypackage in ToBuild: if mypackage == 'process': myfolder = 'Lib/libprocess_for_ma5.so' elif mypackage == 'root': myfolder = 'Lib/libroot_for_ma5.so' else: myfolder = 'Lib/libdelphes_for_ma5.so' if not os.path.isfile(self.main.archi_info.ma5dir + '/tools/SampleAnalyzer/' + myfolder): self.logger.error("Library '" + mypackage + "' checking aborted.") return -1 # Cleaning for mypackage in ToBuild: myfolder = 'Process' if mypackage != 'process': myfolder = 'Interfaces' if not compiler.Clean( mypackage, self.main.archi_info.ma5dir + '/tools/SampleAnalyzer/' + myfolder): self.logger.error("Library '" + mypackage + "' cleaning aborted.") return -1 # Paths lev = self.logger.getEffectiveLevel() self.logger.setLevel(100) checkup = CheckUp(self.main.archi_info, self.main.session_info, False, self.main.script) if not checkup.SetFolder(): self.logger.error("Problem with the path updates.") return -1 if not self.main.archi_info.save(self.main.archi_info.ma5dir + '/tools/architecture.ma5'): return -1 if not self.main.CheckConfig(): return -1 self.logger.setLevel(lev) return 1
class CheckUp(): def __init__(self, archi_info, session_info, debug, script): self.user_info = UserInfo() self.archi_info = archi_info self.session_info = session_info self.debug = debug self.script = script self.checker = DetectManager(self.archi_info, self.user_info, self.session_info, self.script, self.debug) self.logger = logging.getLogger('MA5') def CheckArchitecture(self): # Fill with Python info import sys self.archi_info.python_version = sys.version.replace('\n', '') # Fill with Platform info import platform self.archi_info.platform = platform.system() self.archi_info.release = platform.release() # Fill with number of cores import multiprocessing self.archi_info.ncores = multiprocessing.cpu_count() # Is Mac platform_text = "Platform: " + self.archi_info.platform + " " + self.archi_info.release + " " if self.archi_info.platform.lower() in ['darwin', 'mac', 'macosx']: self.archi_info.isMac = True platform_text += '\x1b[32m' + '[MAC/OSX mode]' + '\x1b[0m' else: self.archi_info.isMac = False platform_text += '\x1b[32m' + '[Linux mode]' + '\x1b[0m' self.logger.info(platform_text) # Info for debug mode if self.debug: # Machine general import platform self.logger.debug("") self.logger.debug("Machine - Cross platform information") self.logger.debug( StringTools.Left(" Machine type: ", 28) + str(platform.machine())) self.logger.debug( StringTools.Left(" Processor name: ", 28) + str(platform.processor())) self.logger.debug( StringTools.Left(" Platform: ", 28) + str(platform.platform())) self.logger.debug( StringTools.Left(" Platform release: ", 28) + str(platform.release())) self.logger.debug( StringTools.Left(" System: ", 28) + str(platform.system())) self.logger.debug( StringTools.Left(" Node: ", 28) + str(platform.node())) self.logger.debug( StringTools.Left(" Number of cores: ", 28) + str(self.archi_info.ncores)) self.logger.debug("") # Machine OS self.logger.debug("Machine - OS-specific information") try: tmp = platform.java_ver() except: tmp = '' self.logger.debug( StringTools.Left(" Java version: ", 28) + str(tmp)) try: tmp = platform.win32_ver() except: tmp = '' self.logger.debug( StringTools.Left(" Windows version: ", 28) + str(tmp)) try: tmp = platform.mac_ver() except: tmp = '' self.logger.debug( StringTools.Left(" Mac Os version: ", 28) + str(tmp)) try: tmp = platform.dist() except: tmp = '' self.logger.debug( StringTools.Left(" Unix distribution:", 28) + str(platform.platform())) self.logger.debug("") return True def CheckSessionInfo(self): # Fill with user name try: import getpass self.session_info.username = getpass.getuser() except: self.session_info.username = '******' # Display user info if self.debug: self.logger.debug('') self.logger.debug("User") self.logger.debug( StringTools.Left(" User name:", 28) + str(self.session_info.username)) import os self.logger.debug( StringTools.Left(" User ID:", 28) + str(os.getuid())) self.logger.debug( StringTools.Left(" Expanding folder ~/:", 28) + str(os.path.expanduser("~/"))) for name in [ "USER", "USERNAME", "LNAME", "LOGNAME", "HOME", "HOMEDRIVE", "posix", "HOMEPATH" ]: if name in os.environ: tmp = os.environ[name] else: tmp = '' self.logger.debug( StringTools.Left(" Variable $" + name + ":", 28) + str(tmp)) self.logger.debug('') # Web access self.logger.debug("Web access") if self.user_info.webaccess_veto: self.session_info.has_web = False self.logger.debug(' disable') else: self.session_info.has_web = True self.logger.debug(' enable') self.logger.debug('') # Fill with tmp folder import os self.logger.debug("Temporary folder") tmpdir = '' # force by the user? if self.user_info.tmp_dir != None: self.logger.debug(' Folder forced by the user: '******'-> found') else: self.logger.debug('-> not found') self.logger.debug('Try to create the folder ' + tmpdir + ' ...') try: os.mkdir(tmpdir) except: self.logger.debug('-> impossible to create it') tmpdir = '' # environment variable if tmpdir == '': for name in ["TMPDIR", "TMP", "TEMP"]: if name in os.environ: tmp = os.environ[name] else: tmp = '' self.logger.debug( StringTools.Left(" Variable $" + name + ":", 28) + str(tmp)) if tmp != '' and tmpdir == '': tmp = os.path.normpath(tmp) self.logger.debug('Check if the folder ' + tmp + ' exists ...') if os.path.isdir(tmp): self.logger.debug('-> found') tmpdir = tmp else: self.logger.debug('-> not found') self.logger.debug('Try to create this folder ...') try: os.mkdir(tmp) self.logger.debug('-> ok') tmpdir = tmp except: self.logger.debug('-> impossible to create it') # /tmp/ + username if tmpdir == '': pathname = os.path.normpath('/tmp/' + self.session_info.username) self.logger.debug('Check if the folder ' + pathname + ' exists ...') if os.path.isdir(pathname): self.logger.debug('-> found') tmpdir = pathname else: self.logger.debug('-> not found') self.logger.debug('Try to create the folder ' + pathname + ' ...') try: os.mkdir(pathname) tmpdir = pathname except: self.logger.debug('-> impossible to create it') if tmpdir != '': self.session_info.tmpdir = tmpdir self.logger.debug('temporary folder will be used for MA5: ' + tmpdir) else: self.logger.error('Impossible to create a tmp folder') return False self.logger.debug('') # Download dir self.logger.debug("Download dir") tmpdir = '' # -> forced by the user? if self.user_info.download_dir != None: self.logger.debug(' Folder forced by the user: '******'-> found') else: self.logger.debug('-> not found') self.logger.debug('Try to create the folder ' + tmpdir + ' ...') try: os.mkdir(tmpdir) except: self.logger.debug('-> impossible to create it') tmpdir = '' # -> temporary folder + 'MA5_download' if tmpdir == '': pathname = os.path.normpath(self.session_info.tmpdir + '/MA5_downloads/') self.logger.debug('Check if the folder ' + pathname + ' exists ...') if os.path.isdir(pathname): self.logger.debug('-> found') tmpdir = pathname else: self.logger.debug('-> not found') self.logger.debug('Try to create the folder ' + pathname + ' ...') try: os.mkdir(pathname) tmpdir = pathname except: self.logger.debug('-> impossible to create it') if tmpdir != '': self.session_info.downloaddir = tmpdir self.logger.debug('download folder will be used for MA5: ' + tmpdir) else: self.logger.error('Impossible to create a download folder') return False self.logger.debug('') # Fill with editor program self.logger.debug("Text editor") self.logger.debug("Look for the global variable $EDITOR ...") if 'EDITOR' in os.environ: self.session_info.editor = os.environ['EDITOR'] self.session_info.editor = self.session_info.editor.lstrip() self.session_info.editor = self.session_info.editor.rstrip() self.logger.debug("-> variable $EDITOR found : " + self.session_info.editor) else: self.session_info.editor = 'vi' self.logger.debug( '-> variable not found. VI editor is set by default.') if self.session_info.editor == '': self.session_info.editor = 'vi' self.logger.debug( '-> variable empty. VI editor is set by default.') self.logger.debug('') # Ok return True def ReadUserOptions(self): # Reading user options self.logger.info("Reading user settings ...") filename = self.archi_info.ma5dir + '/madanalysis/input/installation_options.dat' if not self.user_info.ReadUserOptions(filename): return False return True def CheckMandatoryPackages(self): # Mandatory packages self.logger.info("Checking mandatory packages:") if not self.checker.Execute('python'): return False if not self.checker.Execute('gpp'): return False if not self.checker.Execute('make'): return False return True def CheckOptionalGraphicalPackages(self): # Optional packages self.logger.info( "Checking optional packages devoted to histogramming:") if not self.checker.Execute('root_graphical'): return False if not self.checker.Execute('matplotlib'): return False if not self.checker.Execute('pdflatex'): return False if not self.checker.Execute('latex'): return False return True def CheckOptionalProcessingPackages(self): # Optional packages self.logger.info( "Checking optional packages devoted to data processing:") checker2 = ConfigChecker(self.archi_info, self.user_info, self.session_info, self.script, self.debug) # self.archi_info.has_zlib = checker2.checkZLIB() if not self.checker.Execute('zlib'): return False if not self.checker.Execute('fastjet'): return False if not self.checker.Execute('root'): return False self.archi_info.has_delphes = checker2.checkDelphes() self.archi_info.has_delphesMA5tune = checker2.checkDelphesMA5tune() return True def CreateSymLink(self, source, destination): # Is it a good source if source == '': self.logger.error('source empty for creating symbolic link: ' + source) # Is there a previous link? if os.path.islink(destination): try: os.remove(destination) except: self.logger.error('impossible to remove the file ' + destination) return False # Does the destination exist but it is a file or a folder elif os.path.isfile(destination): self.logger.error( 'creating symbolic link: destination already exist and it is file' ) return False elif os.path.isdir(destination): self.logger.error( 'creating symbolic link: destination already exist and it is folder' ) return False # Creating a link logging.getLogger('MA5').debug('Creating symbolic link from ' + source) logging.getLogger('MA5').debug(' to ' + destination + ' ...') try: os.symlink(source, destination) except: self.logger.error('impossible to create the link ' + destination) return False return True def SetFolder(self): # Reset the pieces of environment variables self.archi_info.toPATH1 = [] # First in PATH variable self.archi_info.toPATH2 = [] # Last in PATH variable self.archi_info.toLDPATH1 = [] # First in (DY)LD_LIBRARY_PATH self.archi_info.toLDPATH2 = [] # Last in (DY)LD_LIBRARY_PATH # Creating folder Lib if not found folder = os.path.normpath(self.archi_info.ma5dir + '/tools/SampleAnalyzer/Lib/') if not os.path.isdir(folder): try: os.mkdir(folder) except: self.logger.error('impossible to create the folder ' + folder) self.archi_info.toLDPATH1.append(folder) # Creating folder ExternalSymLink if not found folder = os.path.normpath(self.archi_info.ma5dir + '/tools/SampleAnalyzer/ExternalSymLink') if not os.path.isdir(folder): try: os.mkdir(folder) except: self.logger.error('impossible to create the folder ' + folder) # Creating folder ExternalSymLink/Lib if not found folder = os.path.normpath(self.archi_info.ma5dir + '/tools/SampleAnalyzer/ExternalSymLink/Lib') if not os.path.isdir(folder): try: os.mkdir(folder) except: self.logger.error('impossible to create the folder ' + folder) self.archi_info.toLDPATH1.append(folder) folderSymLinkLib = folder # Creating folder ExternalSymLink/Bin if not found folder = os.path.normpath(self.archi_info.ma5dir + '/tools/SampleAnalyzer/ExternalSymLink/Bin') if not os.path.isdir(folder): try: os.mkdir(folder) except: self.logger.error('impossible to create the folder ' + folder) self.archi_info.toPATH1.append(folder) folderSymLinkBin = folder # ROOT if self.archi_info.has_root: for source in self.archi_info.root_original_bins: destination = os.path.normpath(folderSymLinkBin + '/' + source.split('/')[-1]) self.CreateSymLink(source, destination) if 1: #self.archi_info.root_priority: self.archi_info.toLDPATH1.append(self.archi_info.root_lib_path) self.archi_info.toPATH1.append(self.archi_info.root_bin_path) else: self.archi_info.toLDPATH2.append(self.archi_info.root_lib_path) self.archi_info.toPATH2.append(self.archi_info.root_bin_path) # FASTJET if self.archi_info.has_fastjet: for source in self.archi_info.fastjet_original_bins: destination = os.path.normpath(folderSymLinkBin + '/' + source.split('/')[-1]) self.CreateSymLink(source, destination) if 1: #self.archi_info.fastjet_priority: self.archi_info.toPATH1.append( self.archi_info.fastjet_bin_path) for path in self.archi_info.fastjet_lib_paths: self.archi_info.toLDPATH1.append(path) else: self.archi_info.toPATH2.append( self.archi_info.fastjet_bin_path) for path in self.archi_info.fastjet_lib_paths: self.archi_info.toLDPATH2.append(path) # ZLIB if self.archi_info.has_zlib: for source in self.archi_info.zlib_original_libs: destination = os.path.normpath(folderSymLinkLib + '/' + source.split('/')[-1]) self.CreateSymLink(source, destination) # if self.archi_info.zlib_priority: # self.archi_info.toLDPATH1.append(self.archi_info.zlib_lib_path) # else: # self.archi_info.toLDPATH2.append(self.archi_info.zlib_lib_path) # DELPHES if self.archi_info.has_delphes: for source in self.archi_info.delphes_original_libs: destination = os.path.normpath(folderSymLinkLib + '/' + source.split('/')[-1]) self.CreateSymLink(source, destination) # if self.archi_info.delphes_priority: # for path in self.archi_info.delphes_lib_paths: # self.archi_info.toLDPATH1.append(path) # else: # for path in self.archi_info.delphes_lib_paths: # self.archi_info.toLDPATH2.append(path) # DELPHES MA5tune if self.archi_info.has_delphesMA5tune: for source in self.archi_info.delphesMA5tune_original_libs: destination = os.path.normpath(folderSymLinkLib + '/' + source.split('/')[-1]) self.CreateSymLink(source, destination) # if self.archi_info.delphesMA5tune_priority: # for path in self.archi_info.delphesMA5tune_lib_paths: # self.archi_info.toLDPATH1.append(path) # else: # for path in self.archi_info.delphesMA5tune_lib_paths: # self.archi_info.toLDPATH2.append(path) # Setting environment variables self.logger.debug('-------- BEGIN: set environment variables --------') # - PATH self.logger.debug('before PATH=' + str(os.environ['PATH'])) self.logger.debug('--------') os.environ['PATH'] = ':'.join(self.archi_info.toPATH1) + ":" + \ os.environ['PATH'] + ":" + \ ':'.join(self.archi_info.toPATH2) self.logger.debug('after PATH=' + str(os.environ['PATH'])) self.logger.debug('--------') # - LD_LIBRARY_PATH self.logger.debug('before LD_LIBRARY_PATH=' + str(os.environ['LD_LIBRARY_PATH'])) self.logger.debug('--------') os.environ['LD_LIBRARY_PATH'] = ':'.join(self.archi_info.toLDPATH1) + ":" + \ os.environ['LD_LIBRARY_PATH'] + ":" + \ ':'.join(self.archi_info.toLDPATH2) self.logger.debug('after LD_LIBRARY_PATH=' + str(os.environ['LD_LIBRARY_PATH'])) self.logger.debug('--------') # - DYLD_LIBRARY_PATH self.logger.debug('before DYLD_LIBRARY_PATH=' + str(os.environ['DYLD_LIBRARY_PATH'])) self.logger.debug('--------') if self.archi_info.isMac: os.environ['DYLD_LIBRARY_PATH'] = ':'.join(self.archi_info.toLDPATH1) + ":" + \ os.environ['DYLD_LIBRARY_PATH'] + ":" + \ ':'.join(self.archi_info.toLDPATH2) self.logger.debug('after DYLD_LIBRARY_PATH=' + str(os.environ['DYLD_LIBRARY_PATH'])) self.logger.debug('--------') self.logger.debug('-------- END: set environment variables --------') return True
def do_main(self, args): # Looking for '=' if args[1] != '=': logging.getLogger('MA5').error( "syntax error with the command 'set'.") self.help() return # Looking for one dot in the name object = args[0] # object = object.lower() object = object.replace('fastsim.bjet_id.', 'fastsim.bjet_idXXX') object = object.replace('fastsim.tau_id.', 'fastsim.tau_idXXX') objs = object.split('.') for i in range(len(objs)): objs[i] = objs[i].replace('XXX', '.') if len(objs) == 2 and objs[0].lower() == 'main' and objs[1].lower( ) == 'recast': user_info = UserInfo() user_info.ReadUserOptions( self.main.archi_info.ma5dir + '/madanalysis/input/installation_options.dat') checker = ConfigChecker(self.main.archi_info, user_info, self.main.session_info, self.main.script, False) hasdelphes = checker.checkDelphes(True) hasMA5tune = checker.checkDelphesMA5tune(True) hasPAD = checker.checkPAD() hasPADtune = checker.checkPADForMA5tune() self.main.recasting.user_SetParameter( "status", args[2], self.main.mode, self.main.archi_info.has_root, hasdelphes, hasMA5tune, self.main.datasets, hasPAD, hasPADtune) if args[2] == 'on' and self.main.fastsim.package != 'none': logging.getLogger('MA5').warning( "Fastsim package switched off and internally handled") self.main.fastsim.package = "none" elif len(objs) == 2 and objs[0].lower() == 'main': if objs[1] == 'mode' and args[2] == 'parton': self.main.mode = MA5RunningType.PARTON self.main.ResetParameters() self.main.AutoSetGraphicalRenderer() self.main.InitObservables(self.main.mode) lvl = logging.getLogger('MA5').getEffectiveLevel() logging.getLogger('MA5').setLevel(100) self.main.multiparticles.Reset() cmd_define = CmdDefine(self.main) input = ParticleReader(self.main.archi_info.ma5dir, cmd_define, self.main.mode, self.main.forced) input.Load() input = MultiparticleReader(self.main.archi_info.ma5dir, cmd_define, self.main.mode, self.main.forced) input.Load() logging.getLogger('MA5').setLevel(lvl) else: self.main.user_SetParameter(objs[1], args[2]) elif len(objs) == 3 and objs[0].lower() == 'main' and objs[1].lower( ) == 'isolation': self.main.isolation.user_SetParameter(objs[2], args[2]) elif len(objs) == 3 and objs[0].lower() == 'main' and objs[1].lower( ) == 'fom': self.main.fom.user_SetParameter(objs[2], args[2]) elif len(objs) == 3 and objs[0].lower() == 'main' and objs[1].lower( ) == 'merging': self.main.merging.user_SetParameter( objs[2], args[2], self.main.mode, self.main.archi_info.has_fastjet) elif len(objs) == 3 and objs[0].lower() == 'main' and objs[1].lower( ) == 'fastsim': user_info = UserInfo() user_info.ReadUserOptions( self.main.archi_info.ma5dir + '/madanalysis/input/installation_options.dat') checker = ConfigChecker(self.main.archi_info, user_info, self.main.session_info, self.main.script, False) hasdelphes = checker.checkDelphes(True) hasMA5tune = checker.checkDelphesMA5tune(True) self.main.fastsim.user_SetParameter( objs[2], args[2], self.main.datasets, self.main.mode, self.main.archi_info.has_fastjet, hasdelphes, hasMA5tune) if objs[2] == 'package' and args[2] in [ 'fastjet', 'delphes', 'delphesMA5tune' ] and self.main.recasting.status == 'on': logging.getLogger('MA5').warning("Recasting mode switched off") self.main.recasting.status = "off" elif len(objs) == 3 and objs[0].lower() == 'main' and objs[1].lower( ) == 'recast': user_info = UserInfo() user_info.ReadUserOptions( self.main.archi_info.ma5dir + '/madanalysis/input/installation_options.dat') checker = ConfigChecker(self.main.archi_info, user_info, self.main.session_info, self.main.script, False) hasdelphes = checker.checkDelphes(True) hasMA5tune = checker.checkDelphesMA5tune(True) hasPAD = checker.checkPAD() hasPADtune = checker.checkPADForMA5tune() self.main.recasting.user_SetParameter( objs[2], args[2], self.main.mode, self.main.archi_info.has_root, hasdelphes, hasMA5tune, self.main.datasets, hasPAD, hasPADtune) else: logging.getLogger('MA5').error( "syntax error with the command 'set'.") self.help() return