def check_noint(argv): set=0 #There is the following set cases if ("--debug" in argv) or("-debug" in argv): set=1 info.debug=1 info.logFile=wmsui_utils.create_err_log(info.prgname) if ("--noint" in argv ) or ("-noint" in argv ): set=2 info.noint = 1 info.logFile=wmsui_utils.create_err_log( info.prgname) else: print "" #Write an empty line if ( ("--nomsg" in argv) or ("-nomsg" in argv) ): # if output=="glite-job-submit": if info.prgname=="glite-job-submit": set=3 info.logFile=wmsui_utils.create_err_log(info.prgname) #Redirect the error/debug logFile into a specified path if ("--logfile" in argv) or ("-logfile" in argv): info.setLog=1 info.logFile=wmsui_utils.create_err_log(info.prgname) set= 1 if set>0: #Could be debug, noint or nomsg (submit) #Print Information program inside the file printHeader(argv)
def checkConf(conf, virtualOrg, logPath): override = 1 voName = UnspecifiedVO vomsrc = "" src = VO_SOURCE_NONE; configFile = "" cfDefault = "" sys_exit = 0 # Trace if(conf and virtualOrg): wmsui_utils.errMsg("The following options cannot be specified together:\n" + \ conf + "\n" + \ virtualOrg + "\n\n", wmsui_utils.info.logFile) wmsui_utils.exit(1) # Read the GLITE_WMS_COMMANDS_CONFIG environment variable try: # Set the WMS Commands Config file envCommandsConfig = os.environ['GLITE_WMS_COMMANDS_CONFIG'] except: # Set a empty value due to missing environment variable envCommandsConfig = "" # Read the X509_USER_PROXY environment variable try: # Set the User Proxy filename from the environment variable proxy_file_name = os.environ['X509_USER_PROXY'] except: # Set the default User Proxy filename proxy_file_name = os.sep + "tmp" + os.sep + "x509up_u"+ repr(os.getuid()) # Read the Proxy file if it exists if os.path.isfile(proxy_file_name): #Try to look for the default Vo inside the user proxy printERRORS=1 err, voName = checkVomsExtension(proxy_file_name, printERRORS) # Check for errors if err: wmsui_utils.errMsg(err, wmsui_utils.info.logFile) wmsui_utils.exit(1) if voName: # Set the source of the voName src = VO_SOURCE_CERT_EXTENSION vomsrc = "proxy certificate extension" """ Options Parsing """ if(virtualOrg and src != VO_SOURCE_NONE): # VO name forcing ignored wmsui_utils.print_message (False, wmsui_utils.info.logFile, "Warning - --vo option ignored" ) elif(virtualOrg): # SCR is definitely NONE voName = virtualOrg src = VO_SOURCE_VO_OPT vomsrc = "--vo option" # Print a debug message if wmsui_utils.info.debug: debugMsg = "#### "+ time.ctime() + " Debug Message ####\n" + \ "VO Read from --vo option\n\n#### End Debug ####\n" #Print message wmsui_utils.print_message(False, wmsui_utils.info.logFile, debugMsg) # Set the config file configFile = wmsui_utils.info.prefix + os.sep + "etc" + os.sep + virtualOrg.lower() + os.sep + DEFAULT_UI_CLIENTCONFILE elif(conf): if (src == VO_SOURCE_NONE and wmsui_utils.info.debug): debugMsg = "#### "+ time.ctime() + " Debug Message ####\n" + \ "VO Read from --config option\n\n#### End Debug ####\n" #Print message wmsui_utils.print_message(False, wmsui_utils.info.logFile, debugMsg) # Set the config file configFile = conf src = VO_SOURCE_CONFIG_OPT vomsrc = "--config option" elif envCommandsConfig: if (src == VO_SOURCE_NONE and wmsui_utils.info.debug): debugMsg = "#### "+ time.ctime() + " Debug Message ####\n" + \ "VO Read from ENV option\n\n#### End Debug ####\n" #Print message wmsui_utils.print_message(False, wmsui_utils.info.logFile, msg) src = VO_SOURCE_CONFIG_VAR; vomsrc = "GLITE_WMSUI_CONFIG_VO env variable" # Set the GLITE_WMS_COMMANDS_CONFIG environment variable content as configuration file configFile = envCommandsConfig elif(src == VO_SOURCE_NONE): print "checkConf\nEmpty value: Unable to find any both VirtualOrganisation and any configuration file" sys.exit(1) err, voName, info.confAdVo, configFile = parseVo(src, configFile, voName, "Error", override) if err == 0 and not info.confAdVo: configFile = "" if wmsui_utils.info.debug and voName: # Print Info msg = "VirtualOrganisation value :" + voName wmsui_utils.print_message(False, wmsui_utils.info.logFile, msg) # Build the default config file it a VO name has been found if(voName): # Build the default config file cfDefault = wmsui_utils.info.prefix + os.sep + "etc" + os.sep + voName.lower() + os.sep + DEFAULT_UI_CLIENTCONFILE # Check if the file exists if not os.path.isfile (cfDefault): # Remove the path cfDefault = "" # Load the configuration loadConfiguration(configFile, cfDefault, voName) if wmsui_utils.info.debug: # Successfully Update needed Info msg = "Selected Virtual Organisation name (from "+ vomsrc + "): " + voName msg = "#### "+ time.ctime() + " Debug Message ####\n" + msg +"\nVOMS configuration file successfully loaded:\n" \ + configFile + info.confAdVo.toLines() + "\n#### End Debug ####\n" #Print VOMS message wmsui_utils.print_message(False, wmsui_utils.info.logFile, msg) # Check if the log path has been set if logPath: # Create the log filename logFile = os.path.abspath (logPath) # Remove the log file if it exists if os.path.isfile ( logFile): try: # Remove the log file os.remove(logFile) except: errMsg ( "Warning" , "UI_RM_FILE", logFile ) else : # Create a new log file logFile = wmsui_utils.create_err_log ( info.prgname ) # Rename the old logFile with the new value (if needed) if info.logFile: if info.logFile != logFile: try: shutil.copyfile( info.logFile, logFile ) except: errMsg('Error','UI_WRITE_FILE' , logFile ) wmsui_utils.exit(1) try: os.remove(info.logFile) except: errMsg("Warning",'UI_RM_FILE' , info.logFile ) info.logFile = logFile # Return the Virtual Organisation name return voName