def __init__(self,optargs=sys.argv[1:],quiet=False): """ Starts a new function and gets all the parameters """ ### setup some expected values self.startmem = mem.active() self.t0 = time.time() self.createDefaultStats() self.quiet = quiet # self.timestamp = apParam.makeTimestamp() # if not self.quiet: # apDisplay.printMsg("Time stamp: "+self.timestamp) self.functionname = apParam.getFunctionName(sys.argv[0]) if not self.quiet: apDisplay.printMsg("Function name: "+self.functionname) apParam.setUmask() self.parsePythonPath() # loadavg = os.getloadavg()[0] # if loadavg > 2.0: # apDisplay.printMsg("Load average is %.2f, wait for %.1f second " % (round(loadavg,2),loadavg**2)) # time.sleep(loadavg**2) # apDisplay.printMsg("Load average is high "+str(round(loadavg,2))) ### setup default parser: run directory, etc. self.setParams(optargs) self.checkConflicts() ### write function log self.logfile = apParam.writeFunctionLog(sys.argv, msg=(not self.quiet)) ### any custom init functions go here self.onInit()
def __init__(self,optargs=sys.argv[1:],quiet=False): """ Starts a new function and gets all the parameters """ ### setup some expected values self.startmem = mem.active() self.t0 = time.time() self.createDefaultStats() self.quiet = quiet self.timestamp = apParam.makeTimestamp() if not self.quiet: apDisplay.printMsg("Time stamp: "+self.timestamp) self.functionname = apParam.getFunctionName(sys.argv[0]) if not self.quiet: apDisplay.printMsg("Function name: "+self.functionname) apParam.setUmask() self.parsePythonPath() loadavg = os.getloadavg()[0] if loadavg > 2.0: apDisplay.printMsg("Load average is %.2f, wait for %.1f second " % (round(loadavg,2),loadavg**2)) time.sleep(loadavg**2) apDisplay.printMsg("Load average is high "+str(round(loadavg,2))) ### setup default parser: run directory, etc. self.setParams(optargs) self.checkConflicts() ### write function log self.logfile = apParam.writeFunctionLog(sys.argv, msg=(not self.quiet)) ### any custom init functions go here self.onInit()
def __init__(self, optargs=sys.argv[1:], quiet=False, useglobalparams=True, maxnproc=None): """ Starts a new function and gets all the parameters """ ### setup some expected values self.successful_run = False self.params = {} sys.stdout.write("\n\n") self.quiet = quiet self.maxnproc = maxnproc self.startmem = mem.active() self.t0 = time.time() self.createDefaultStats() self.timestamp = apParam.makeTimestamp() self.argdict = {} self.optdict = {} apDisplay.printMsg("Time stamp: " + self.timestamp) self.functionname = apParam.getFunctionName(sys.argv[0]) apDisplay.printMsg("Function name: " + self.functionname) self.appiondir = apParam.getAppionDirectory() apDisplay.printMsg("Appion directory: " + self.appiondir) self.parsePythonPath() # loadavg = os.getloadavg()[0] # if loadavg > 2.0: # apDisplay.printMsg("Load average is high "+str(round(loadavg,2))) # loadsquared = loadavg*loadavg # time.sleep(loadavg) # apDisplay.printMsg("New load average "+str(round(os.getloadavg()[0],2))) self.setLockname('lock') ### setup default parser: run directory, etc. self.setParams(optargs, useglobalparams) #if 'outdir' in self.params and self.params['outdir'] is not None: # self.params['rundir'] = self.params['outdir'] self.checkConflicts() if useglobalparams is True: self.checkGlobalConflicts() ### setup run directory self.setProcessingDirName() self.setupRunDirectory() ### Start pool of threads to run subprocesses. ### Later you will use self.process_launcher.launch(...) to ### put commands into the queue. ### There is currently a timeout built into it that will cause ### the threads to die if they have no tasks after 10 seconds. self.process_launcher = apThread.ProcessLauncher( 2, self.params['rundir']) ### write function log self.logfile = apParam.writeFunctionLog(sys.argv, msg=(not self.quiet)) ### any custom init functions go here self.onInit()
def __init__(self,optargs=sys.argv[1:],quiet=False,useglobalparams=True,maxnproc=None): """ Starts a new function and gets all the parameters """ ### setup some expected values self.successful_run = False self.params = {} sys.stdout.write("\n\n") self.quiet = quiet self.maxnproc = maxnproc self.startmem = mem.active() self.t0 = time.time() self.createDefaultStats() self.timestamp = apParam.makeTimestamp() self.argdict = {} self.optdict = {} apDisplay.printMsg("Time stamp: "+self.timestamp) self.functionname = apParam.getFunctionName(sys.argv[0]) apDisplay.printMsg("Function name: "+self.functionname) self.appiondir = apParam.getAppionDirectory() apDisplay.printMsg("Appion directory: "+self.appiondir) self.parsePythonPath() # loadavg = os.getloadavg()[0] # if loadavg > 2.0: # apDisplay.printMsg("Load average is high "+str(round(loadavg,2))) # loadsquared = loadavg*loadavg # time.sleep(loadavg) # apDisplay.printMsg("New load average "+str(round(os.getloadavg()[0],2))) self.setLockname('lock') ### setup default parser: run directory, etc. self.setParams(optargs,useglobalparams) #if 'outdir' in self.params and self.params['outdir'] is not None: # self.params['rundir'] = self.params['outdir'] self.checkConflicts() if useglobalparams is True: self.checkGlobalConflicts() ### setup run directory self.setProcessingDirName() self.setupRunDirectory() ### Start pool of threads to run subprocesses. ### Later you will use self.process_launcher.launch(...) to ### put commands into the queue. ### There is currently a timeout built into it that will cause ### the threads to die if they have no tasks after 10 seconds. self.process_launcher = apThread.ProcessLauncher(2, self.params['rundir']) ### write function log self.logfile = apParam.writeFunctionLog(sys.argv, msg=(not self.quiet)) ### any custom init functions go here self.onInit()
def __init__(self, optargs=sys.argv[1:], quiet=False, useglobalparams=True, maxnproc=None): """ Starts a new function and gets all the parameters """ ### setup some expected values self.successful_run = False self.clusterjobdata = None self.params = {} sys.stdout.write("\n\n") self.quiet = quiet self.maxnproc = maxnproc self.startmem = mem.active() self.t0 = time.time() self.createDefaultStats() self.timestamp = apParam.makeTimestamp() self.argdict = {} self.optdict = {} apDisplay.printMsg("Time stamp: " + self.timestamp) self.functionname = apParam.getFunctionName(sys.argv[0]) apDisplay.printMsg("Function name: " + self.functionname) self.appiondir = apParam.getAppionDirectory() apDisplay.printMsg("Appion directory: " + self.appiondir) self.parsePythonPath() loadavg = os.getloadavg()[0] if loadavg > 2.0: apDisplay.printMsg("Load average is high " + str(round(loadavg, 2))) loadsquared = loadavg * loadavg time.sleep(loadavg) apDisplay.printMsg("New load average " + str(round(os.getloadavg()[0], 2))) self.setLockname('lock') ### setup default parser: run directory, etc. self.setParams(optargs, useglobalparams) #if 'outdir' in self.params and self.params['outdir'] is not None: # self.params['rundir'] = self.params['outdir'] ### setup correct database after we have read the project id if 'projectid' in self.params and self.params['projectid'] is not None: apDisplay.printMsg("Using split database") # use a project database newdbname = apProject.getAppionDBFromProjectId( self.params['projectid']) sinedon.setConfig('appiondata', db=newdbname) apDisplay.printColor("Connected to database: '" + newdbname + "'", "green") ### check if user wants to print help message if 'commit' in self.params and self.params['commit'] is True: apDisplay.printMsg("Committing data to database") else: apDisplay.printWarning("Not committing data to database") self.checkConflicts() if useglobalparams is True: self.checkGlobalConflicts() ### setup run directory self.setProcessingDirName() self.setupRunDirectory() ### Start pool of threads to run subprocesses. ### Later you will use self.process_launcher.launch(...) to ### put commands into the queue. ### There is currently a timeout built into it that will cause ### the threads to die if they have no tasks after 10 seconds. self.process_launcher = apThread.ProcessLauncher( 2, self.params['rundir']) ### write function log self.logfile = apParam.writeFunctionLog(sys.argv, msg=(not self.quiet)) ### upload command line parameters to database self.uploadScriptData() ### any custom init functions go here self.onInit()
def __init__(self,optargs=sys.argv[1:],quiet=False,useglobalparams=True,maxnproc=None): """ Starts a new function and gets all the parameters """ ### setup some expected values self.successful_run = False self.clusterjobdata = None self.params = {} sys.stdout.write("\n\n") self.quiet = quiet self.maxnproc = maxnproc self.startmem = mem.active() self.t0 = time.time() self.createDefaultStats() self.timestamp = apParam.makeTimestamp() self.argdict = {} self.optdict = {} apDisplay.printMsg("Time stamp: "+self.timestamp) self.functionname = apParam.getFunctionName(sys.argv[0]) apDisplay.printMsg("Function name: "+self.functionname) self.appiondir = apParam.getAppionDirectory() apDisplay.printMsg("Appion directory: "+self.appiondir) hostname = apParam.getHostname() apDisplay.printMsg("Processing hostname: "+hostname) self.parsePythonPath() # loadavg = os.getloadavg()[0] # if loadavg > 2.0: # apDisplay.printMsg("Load average is high "+str(round(loadavg,2))) # loadsquared = loadavg*loadavg # time.sleep(loadavg) # apDisplay.printMsg("New load average "+str(round(os.getloadavg()[0],2))) self.setLockname('lock') ### setup default parser: run directory, etc. self.setParams(optargs,useglobalparams) #if 'outdir' in self.params and self.params['outdir'] is not None: # self.params['rundir'] = self.params['outdir'] ### setup correct database after we have read the project id if 'projectid' in self.params and self.params['projectid'] is not None: apDisplay.printMsg("Using split database") # use a project database newdbname = apProject.getAppionDBFromProjectId(self.params['projectid']) sinedon.setConfig('appiondata', db=newdbname) apDisplay.printColor("Connected to database: '"+newdbname+"'", "green") ### check if user wants to print help message if 'commit' in self.params and self.params['commit'] is True: apDisplay.printMsg("Committing data to database") else: apDisplay.printWarning("Not committing data to database") self.checkConflicts() if useglobalparams is True: self.checkGlobalConflicts() ### setup run directory self.setProcessingDirName() self.setupRunDirectory() ### Start pool of threads to run subprocesses. ### Later you will use self.process_launcher.launch(...) to ### put commands into the queue. ### There is currently a timeout built into it that will cause ### the threads to die if they have no tasks after 10 seconds. self.process_launcher = apThread.ProcessLauncher(2, self.params['rundir']) ### write function log self.logfile = apParam.writeFunctionLog(sys.argv, msg=(not self.quiet)) ### upload command line parameters to database self.uploadScriptData() ### any custom init functions go here self.onInit()