def killJob(jobID): """ @param jobID: the url of the job or a sequence of jobID @type jobID: string or sequence of jobID @return: @rtype: @raise MobyleError: if the job has no number or if the job doesn't exist anymore @todo: tester la partie sge """ from types import StringTypes, TupleType, ListType from Mobyle.MobyleError import MobyleError from Mobyle.JobState import JobState, normUri from Mobyle.Job import Job from Mobyle.WorkflowJob import WorkflowJob if isinstance(jobID, StringTypes): jobIDs = [jobID] elif isinstance(jobID, (ListType, TupleType)): jobIDs = jobID else: raise MobyleError, "jobID must be a string or a Sequence of strings :%s" % type(jobID) errors = [] for jobID in jobIDs: try: path = normUri(jobID) except MobyleError, err: errors.append((jobID, str(err))) continue if path[:4] == "http": # the jobID is not on this Mobyle server errors.append((jobID, "can't kill distant job")) continue js = JobState(uri=jobID) if js.isWorkflow(): job = WorkflowJob(id=jobID) else: job = Job(ID=jobID) try: job.kill() except MobyleError, err: errors.append((jobID, str(err))) continue
def getFromJobId(cls, jobId): """ create a JobFacade to access an existing job. @param jobId: the job identifier @type jobId: string @return: the appropriate job facade @rtype: JobFacade """ jobState = JobState(jobId) jfargs = {'jobId': jobState.getID(),'programUrl':None,'workflowUrl':None} if jobState.isWorkflow(): jfargs['workflowUrl'] = jobState.getName() else: jfargs['programUrl']= jobState.getName() # this id is identical to the one in parameter, # except it has been normalized (may have removed # trailing index.xml from the id) if jobState.isLocal(): return(LocalJobFacade(**jfargs)) else: return(RemoteJobFacade(**jfargs))