except: (type, value, tb) = sys.exc_info() #print("type: %s, value: %s" % (type, value)) compteur += 1 #fcntl.flock(file, fcntl.LOCK_UN) file.close() time.sleep(1) else: #fcntl.flock(file, fcntl.LOCK_UN) file.close() return compositeClientDict, compositeInputDirDict # Read configuration file config = ConfigParser() config.readfp(template.openFile(FULL_MAIN_CONF)) pdsTab = config.get('PDS', 'tab') # Server redirection if pdsTab is not ON if pdsTab != 'ON': URL = "pxCircuitsTab.py\n" print 'Location: ', URL results_name = config.get('CIR', 'results_name') # How the "results" file (sent by CIR host) will be named (path not included) logname = config.get('CS', 'logname') # Full name for the logfile log_level = config.get('CS', 'log_level') # Level of logging timeout = int(config.get('CS', 'results_timeout')) # Number of minutes after which the "results" are considered outdated # If not defined in configuration file, set defaults if (not logname ): logname = CS + "/log/" + "CS.log"
def readQueueMax(filename, system): clientsRegex = {} directoriesRegex = {} circuitsRegex = {} timersRegex = {} pdsGraphsRegex = {} pxGraphsRegex = {} # PDS Default when no entries is present in the maxSettings.conf file default_client = 200 default_inputDir = 400 default_pdsGraph = 0 # PX Default when no enty is present in the maxSettings.conf file default_circuit = 800 default_timer = 20 default_pxGraph = 0 file = template.openFile(filename, 0) lines = file.readlines() # Parsing inClients = 0 inInputDirs = 0 inPXCircuits = 0 inPXTimers = 0 inPDSGraphs = 0 inPXGraphs = 0 regex_CLIENTS = re.compile(r'^PDS_CLIENTS\s*') regex_INPUT_DIRECTORIES = re.compile(r'^PDS_INPUT_DIRECTORIES\s*') regex_PDS_GRAPHS = re.compile(r'^PDS_GRAPHS\s*') regex_PX_GRAPHS = re.compile(r'^PX_GRAPHS\s*') regex_PX_CIRCUITS = re.compile(r'^PX_CIRCUITS\s*') regex_PX_TIMERS = re.compile(r'^PX_TIMERS\s*') regex_DEFAULT = re.compile(r'^DEFAULT\s+(\d+).*') regex_NameValue = re.compile(r'^(.*?)\s+(\d+).*') for line in lines: match_CLIENTS = regex_CLIENTS.match(line) match_INPUT_DIRECTORIES = regex_INPUT_DIRECTORIES.match(line) match_PDS_GRAPHS = regex_PDS_GRAPHS.match(line) match_PX_GRAPHS = regex_PX_GRAPHS.match(line) match_PX_CIRCUITS = regex_PX_CIRCUITS.match(line) match_PX_TIMERS = regex_PX_TIMERS.match(line) match_DEFAULT = regex_DEFAULT.match(line) match_NameValue = regex_NameValue.match(line) if line[0] == "#": continue elif match_CLIENTS: if DEBUG: print "Les Clients" inClients = 1 (inInputDirs, inPXCircuits, inPXTimers, inPDSGraphs, inPXGraphs) = (0, 0, 0, 0, 0) elif match_INPUT_DIRECTORIES: if DEBUG: print "Les Directories" inInputDirs = 1 (inClients, inPXCircuits, inPXTimers, inPDSGraphs, inPXGraphs) = (0, 0, 0, 0, 0) elif match_PDS_GRAPHS: if DEBUG: print "Les Graphs PDS" inPDSGraphs = 1 (inClients, inInputDirs, inPXCircuits, inPXTimers, inPXGraphs) = (0, 0, 0, 0, 0) elif match_PX_GRAPHS: if DEBUG: print "Les Graphs PX" inPXGraphs = 1 (inClients, inInputDirs, inPXCircuits, inPXTimers, inPDSGraphs) = (0, 0, 0, 0, 0) elif match_PX_CIRCUITS: if DEBUG: print "Les Circuits" inPXCircuits = 1 (inClients, inInputDirs, inPXTimers, inPDSGraphs, inPXGraphs) = (0, 0, 0, 0, 0) elif match_PX_TIMERS: if DEBUG: print "Les Timers" inPXTimers = 1 (inClients, inInputDirs, inPXCircuits, inPDSGraphs, inPXGraphs) = (0, 0, 0, 0, 0) elif inClients: if (match_DEFAULT): default_client = match_DEFAULT.group(1) elif (match_NameValue): (name, number) = match_NameValue.groups() clientsRegex[glob_to_regex(name)] = number if DEBUG: print "client ", print match_NameValue.groups() elif inInputDirs: if (match_DEFAULT): default_inputDir = match_DEFAULT.group(1) elif (match_NameValue): (name, number) = match_NameValue.groups() directoriesRegex[glob_to_regex(name)] = number if DEBUG: print "inputDir ", print match_NameValue.groups() elif inPDSGraphs: if (match_DEFAULT): default_pdsGraph = match_DEFAULT.group(1) elif (match_NameValue): (name, number) = match_NameValue.groups() pdsGraphsRegex[glob_to_regex(name)] = number if DEBUG: print "PDS graph ", print match_NameValue.groups() elif inPXGraphs: if (match_DEFAULT): default_pxGraph = match_DEFAULT.group(1) elif (match_NameValue): (name, number) = match_NameValue.groups() pxGraphsRegex[glob_to_regex(name)] = number if DEBUG: print "PX graph ", print match_NameValue.groups() elif inPXCircuits: if (match_DEFAULT): default_circuit = match_DEFAULT.group(1) elif (match_NameValue): (name, number) = match_NameValue.groups() circuitsRegex[glob_to_regex(name)] = number if DEBUG: print "circuit", print match_NameValue.groups() elif inPXTimers: if (match_DEFAULT): default_timer = match_DEFAULT.group(1) elif (match_NameValue): (name, number) = match_NameValue.groups() timersRegex[glob_to_regex(name)] = number if DEBUG: print "timer", print match_NameValue.groups() if system == 'PDS': return clientsRegex, default_client, directoriesRegex, default_inputDir, pdsGraphsRegex, default_pdsGraph elif system == 'PX': return circuitsRegex, default_circuit, timersRegex, default_timer, pxGraphsRegex, default_pxGraph
compositeClientDict = pickle.load(file) compositeInputDirDict = pickle.load(file) file.close() return compositeClientDict, compositeInputDirDict def unarchiveListing(filename): file = open(filename, "rb") listingDict = pickle.load(file) file.close() return listingDict # Read configuration file config = ConfigParser() config.readfp(template.openFile(FULL_MAIN_CONF)) results_name = config.get( 'CIR', 'results_name') # How the "results" file will be named (path not included) logname = config.get('CS', 'logname') # Full name for the logfile log_level = config.get('CS', 'log_level') # Level of logging host = config.get( 'CCS', 'host') # Where the program to create a client listing must be initiated timeout = int( config.get('CS', 'results_timeout') ) # Number of minutes after which the "results" are considered outdated # If not defined in configuration file, set defaults if (not logname): logname = CS + "/log/" + "CS.log"