PEATSA/WebApp/JobSubmission.py
def runBackend(self):
	
		'''Executes the command string for the job via Popen
		
		Returns:
			An URL which specifies a page giving information about the Job
			or None if construct() has not been called.'''
	
		if self.runString == None:
			return
	
		try:
			#Put selected calculations into state Queued regardless of whether this following works or not.
			#This avoid a possible a race condition if the backed is launched quickly between who
			#modified the jobs state first
			states = self.job.calculationStates()
			for calculation in states.keys():
				if states[calculation] != "NotSelected":
					self.job.setCalculationState(calculation, "Queued")
		
			#Start the job running
			#FIXME - Wont really be able to use files for a log
			standardOut = open(os.path.join(self.webServerDirectory, "PDTWebRuns.log"), "a")
			standardOut.write("\n----------------------------------------------------------\n")
			standardOut.write("\nRunning Job %s\nDate %s\nWebScript command line %s\n\n" % (self.job.identification, self.job.date, self.runString))
			standardOut.flush()
			standardError = open(os.path.join(self.webServerDirectory, "PDTWebErrors.log"), "a")
			process = subprocess.Popen(self.runString, shell=True, stdout=standardOut, stderr=standardError)
			
			#Wait until the job is running
			time.sleep(1.0)
			process.poll()
				
			if process.returncode != None and process.returncode != 0:
				string = "Unable to launch job - launch script exited with error %d" % process.returncode
				standardError.write(string)
				raise Exceptions.SubmissionException, string

			standardOut.close()
			standardError.close()	
				
			#Constrtuct the url for the processing job page
			#Pass the information on what is being calculated on aswell
			#The elements here are scheme, location, hierarchical path, parameters, query, fragment
			location = os.environ['SERVER_NAME'] + ":" + os.environ['SERVER_PORT']
			components = ("http", location, "PEATSA/Pages/Results.php", "", "jobId=%s" % self.job.identification, "")
			resultURL = urlparse.urlunparse(components)
	
		except BaseException, data:
			if hasattr(data, "child_traceback"):
				errorString = "Exception %s. \n Child traceback %s" % (data, data.child_traceback)
			else:
				errorString = "Exception - %s" % data
				
			#Delete job information from the db if it exists
			if self.job is not None:
				self.jobManager.deleteJob(self.job)

			self.errorData = {"domain":"PDT.SubmissionDomain",
					  "description":"Error when attempting to run job.",
					  "detailedDescription":errorString,
					   "recoverySuggestion":"This is a bug - please contact the developers."}

			resultURL = self.errorURL()
	
		return resultURL
Executes the command string for the job via Popen
		
		Returns:
			An URL which specifies a page giving information about the Job
			or None if construct() has not been called.
Executes the command string for the job via Popen
Executes the command string for the job via Popen
def runBackend(self):
		if self.runString == None:
			return
		try:
			states = self.job.calculationStates()
			for calculation in states.keys():
				if states[calculation] != "NotSelected":
					self.job.setCalculationState(calculation, "Queued")
			standardOut = open(os.path.join(self.webServerDirectory, "PDTWebRuns.log"), "a")
			standardOut.write("\n----------------------------------------------------------\n")
			standardOut.write("\nRunning Job %s\nDate %s\nWebScript command line %s\n\n" % (self.job.identification, self.job.date, self.runString))
			standardOut.flush()
			standardError = open(os.path.join(self.webServerDirectory, "PDTWebErrors.log"), "a")
			process = subprocess.Popen(self.runString, shell=True, stdout=standardOut, stderr=standardError)
			time.sleep(1.0)
			process.poll()
			if process.returncode != None and process.returncode != 0:
				string = "Unable to launch job - launch script exited with error %d" % process.returncode
				standardError.write(string)
				raise Exceptions.SubmissionException, string
			standardOut.close()
			standardError.close()	
			location = os.environ['SERVER_NAME'] + ":" + os.environ['SERVER_PORT']
			components = ("http", location, "PEATSA/Pages/Results.php", "", "jobId=%s" % self.job.identification, "")
			resultURL = urlparse.urlunparse(components)
		except BaseException, data:
			if hasattr(data, "child_traceback"):
				errorString = "Exception %s. \n Child traceback %s" % (data, data.child_traceback)
			else:
				errorString = "Exception - %s" % data
			if self.job is not None:
				self.jobManager.deleteJob(self.job)
			self.errorData = {"domain":"PDT.SubmissionDomain",
					  "description":"Error when attempting to run job.",
					  "detailedDescription":errorString,
					   "recoverySuggestion":"This is a bug - please contact the developers."}
			resultURL = self.errorURL()
		return resultURL
def runBackend ( self ) : if self . runString == None : return try : states = self . job . calculationStates ( ) for calculation in states . keys ( ) : if states [ calculation ] != "NotSelected" : self . job . setCalculationState ( calculation , "Queued" ) standardOut = open ( os . path . join ( self . webServerDirectory , "PDTWebRuns.log" ) , "a" ) standardOut . write ( "\n----------------------------------------------------------\n" ) standardOut . write ( "\nRunning Job %s\nDate %s\nWebScript command line %s\n\n" % ( self . job . identification , self . job . date , self . runString ) ) standardOut . flush ( ) standardError = open ( os . path . join ( self . webServerDirectory , "PDTWebErrors.log" ) , "a" ) process = subprocess . Popen ( self . runString , shell = True , stdout = standardOut , stderr = standardError ) time . sleep ( 1.0 ) process . poll ( ) if process . returncode != None and process . returncode != 0 : string = "Unable to launch job - launch script exited with error %d" % process . returncode standardError . write ( string ) raise Exceptions . SubmissionException , string standardOut . close ( ) standardError . close ( ) location = os . environ [ 'SERVER_NAME' ] + ":" + os . environ [ 'SERVER_PORT' ] components = ( "http" , location , "PEATSA/Pages/Results.php" , "" , "jobId=%s" % self . job . identification , "" ) resultURL = urlparse . urlunparse ( components ) except BaseException , data : if hasattr ( data , "child_traceback" ) : errorString = "Exception %s. \n Child traceback %s" % ( data , data . child_traceback ) else : errorString = "Exception - %s" % data if self . job is not None : self . jobManager . deleteJob ( self . job ) self . errorData = { "domain" : "PDT.SubmissionDomain" , "description" : "Error when attempting to run job." , "detailedDescription" : errorString , "recoverySuggestion" : "This is a bug - please contact the developers." } resultURL = self . errorURL ( ) return resultURL
Executes the command string for the job via Popen
Executes the command string for the job via Popen
'''Executes the command string for the job via Popen
		
		Returns:
			An URL which specifies a page giving information about the Job
			or None if construct() has not been called.''' #Put selected calculations into state Queued regardless of whether this following works or not. #This avoid a possible a race condition if the backed is launched quickly between who #modified the jobs state first #Start the job running #FIXME - Wont really be able to use files for a log #Wait until the job is running #Constrtuct the url for the processing job page #Pass the information on what is being calculated on aswell #The elements here are scheme, location, hierarchical path, parameters, query, fragment #Delete job information from the db if it exists
An URL which specifies a page giving information about the Job
or None if construct() has not been called.
An URL which specifies a page giving information about the Job or None if construct () has not been called .
self