def __init__(self, service=None, **kw): apply( NetworkNode.__init__, (self,), kw ) self.inNodeWidgetsVisibleByDefault = True from mglutil.web.services.AppService_client import AppServiceLocator, launchJobRequest, \ getOutputsRequest, queryStatusRequest from mglutil.web.services.AppService_types import ns0 self.appLocator = AppServiceLocator() self.req = launchJobRequest() self.inputFile = ns0.InputFileType_Def('inputFile') self.widgetDescr['outputURL'] = { 'class':'NECheckButton', 'master':'ParamPanel', 'labelCfg':{'text':'output URL'}, } self.inputPortsDescr.append(datatype='boolean', name='outputURL') self.outputPortsDescr.append(datatype='string', name='URL') if service: self.constrkw['service'] = `service` self.service = service self.host = self.service[:7+self.service[7:].find('/')] #to get rid of part after http://ws.nbcr.net:8080
def __init__(self, service=None, **kw): apply(NetworkNode.__init__, (self, ), kw) self.inNodeWidgetsVisibleByDefault = True from mglutil.web.services.AppService_client import AppServiceLocator, launchJobRequest, \ getOutputsRequest, queryStatusRequest from mglutil.web.services.AppService_types import ns0 self.appLocator = AppServiceLocator() self.req = launchJobRequest() self.inputFile = ns0.InputFileType_Def('inputFile') self.widgetDescr['outputURL'] = { 'class': 'NECheckButton', 'master': 'ParamPanel', 'labelCfg': { 'text': 'output URL' }, } self.inputPortsDescr.append(datatype='boolean', name='outputURL') self.outputPortsDescr.append(datatype='string', name='URL') if service: self.constrkw['service'] = ` service ` self.service = service self.host = self.service[:7 + self.service[7:].find( '/')] #to get rid of part after http://ws.nbcr.net:8080
def startAutodock(self): self.cmdForms['default'].descr.entryByName['Run_autodock']['widget']\ .configure(state='disabled') dpf_file = self.dpf.get() if not os.path.exists(dpf_file): self.cmdForms['default'].descr.entryByName['status0']['widget'].\ configure(text = 'ERROR: dpf file ' + fpf_file + ' does not exist!') return self.host = self.cmdForms['default'].descr.entryByName['WS_address']['widget'].get() # if not self.login : # self.cmdForms['default'].descr.entryByName['status0']['widget'].\ # configure(text='Connecting to '+ self.host + ". Please wait...") # self.vf.GUI.ROOT.update() # f = self.validate_login() # if f == "Failed": # return self.appLocator = AppServiceLocator() self.req = launchJobRequest() input_file = os.path.basename(dpf_file) options = '-p ' + input_file + ' -l ' + os.path.splitext(input_file)[0] + '.dlg' self.req._argList = options #input_dpf = ns0.InputFileType_Def('inputFile') #input_dpf._name = input_file dpfFile = open(dpf_file, 'r') dpfFileString = dpfFile.read() dpfFile.close() #input_dpf._contents = dpfFileString #DPF file inputFiles = [] inputFiles.append(self.uploadFile(dpf_file)) run_option = self.ad_radio.get() if run_option == 0: # sends locally stored grid files inputs = re.findall("\w*.\w*\.map ",dpfFileString) inputs.extend(re.findall("\w*\.maps.fld",dpfFileString)) inputs.extend(re.findall("\w*.pdbq[t]*",dpfFileString)) for input in inputs: input = input.strip() #ws_input = ns0.InputFileType_Def('inputFile') #ws_input._name = input input_full_name = os.path.join(os.path.split(dpf_file)[0],input) #inputFile = open(input_full_name, 'r') #inputFileString = inputFile.read() #inputFile.close() #ws_input._contents = inputFileString inputFiles.append(self.uploadFile(input_full_name)) elif run_option == 2: # runs AutoGrid first prev_dir = self.prev_dir.get() inputs = re.findall("\w*.\w*\.map ",dpfFileString) inputs.extend(re.findall("\w*\.maps.fld",dpfFileString)) host = 'http://'+self.host.split('/')[2] for input in inputs: self.req._argList += " " +host+"/"+prev_dir+"/"+input pdbq_input = re.findall("\w*.pdbq[t]*",dpfFileString) pdbq_input = pdbq_input[0].strip() #ws_input = ns0.InputFileType_Def('inputFile') #ws_input._name = pdbq_input input_full_name = os.path.join(os.path.split(dpf_file)[0],pdbq_input) #inputFile = open(input_full_name, 'r') #inputFileString = inputFile.read() #inputFile.close() #ws_input._contents = inputFileString inputFiles.append(self.uploadFile(input_full_name)) self.req._inputFile = inputFiles self.vf.GUI.ROOT.update() self.appServicePort = self.appLocator.getAppServicePort( self.host+'/AutodockOpalService',) resp = self.appServicePort.launchJob(self.req) self.JobID = resp._jobID self.cmdForms['default'].descr.entryByName['status0']['widget'].\ configure(text = 'Running Autodock Job ID: ' + self.JobID) self.vf.GUI.ROOT.update() self.vf.GUI.ROOT.after(5, self.checkStatus) self.cmdForms['default'].descr.entryByName['Run_autodock']['widget'].configure(state='normal')
def startAutogrid(self): self.cmdForms['default'].descr.entryByName['Run_autogrid']['widget']\ .configure(state='disabled') gpf_file = self.gpf.get() if not os.path.exists(gpf_file): self.cmdForms['default'].descr.entryByName['status0']['widget'].\ configure(text = 'ERROR: gpf file ' + gpf_file + ' does not exist!') return self.host = self.cmdForms['default'].descr.entryByName['WS_address']['widget'].get() # if not self.login : # self.cmdForms['default'].descr.entryByName['status0']['widget'].\ # configure(text='Connecting to '+ self.host + ". Please wait...") # self.vf.GUI.ROOT.update() # f = self.validate_login() # if f == "Failed": # return self.appLocator = AppServiceLocator() self.req = launchJobRequest() input_file = os.path.basename(gpf_file) options = '-p ' + input_file + ' -l ' + os.path.splitext(input_file)[0] + '.glg' self.req._argList = options #input_gpf = ns0.InputFileType_Def('inputFile') #input_gpf._name = input_file gpfFile = open(gpf_file, 'r') gpfFileString = gpfFile.read() gpfFile.close() #input_gpf._contents = gpfFileString gpfFileString = gpfFileString.split('\n') for line in gpfFileString: if line[0:9] == 'receptor ': pdbqs = line.split()[1] #input_pdbqs = ns0.InputFileType_Def('inputFile') #input_pdbqs._name = pdbqs pdbqs = os.path.join(os.path.split(gpf_file)[0],pdbqs) #pdbqsFile = open(pdbqs, 'r') #pdbqsFileString = pdbqsFile.read() #pdbqsFile.close() #input_pdbqs._contents = pdbqsFileString inputFiles = [] #inputFiles.append(input_gpf) #inputFiles.append(input_pdbqs) inputFiles.append(self.uploadFile(gpf_file)) inputFiles.append(self.uploadFile(pdbqs)) self.req._inputFile = inputFiles self.appServicePort = self.appLocator.getAppServicePort( self.host+'/AutogridOpalService') resp = self.appServicePort.launchJob(self.req) self.JobID = resp._jobID self.cmdForms['default'].descr.entryByName['status0']['widget'].\ configure(text = 'Running Autogrid Job ID: ' + self.JobID) self.vf.GUI.ROOT.update() self.vf.GUI.ROOT.after(5, self.checkStatus) self.cmdForms['default'].descr.entryByName['Run_autogrid']['widget'].configure(state='normal') self.prev_dir.set(self.JobID) self.cmdForms['default'].descr.entryByName['use_remote']['widget'].configure(state='normal')
def executeWebJob(self, url, commandline, inFilesPath, numProcs): """ executeWebJob description: it execute a job through OpalInterface @input: -url: the url where to reach the Opal service -commandline the command line to use for the execution -inputFiles an array of input file to upload, it should contains an array of string with the path to the file -numProcs the number of processors to use """ inputFiles = [] if inFilesPath != None: for i in inFilesPath: inputFile = ns0.InputFileType_Def('inputFile') inputFile._name = os.path.basename(i) if self.isOpal2(url): #use attachment this is opal2 server if os.name == 'dos' or os.name == 'nt': inputFile._attachment = open(i, "rb") else: inputFile._attachment = open(i, "r") else: #it's not a opal2 server don't user attachment infile = open(i, "r") inputFile._contents = infile.read() infile.close() inputFiles.append(inputFile) appLocator = AppServiceLocator() appServicePort = appLocator.getAppServicePort(url) req = launchJobRequest() req._argList = commandline req._inputFile = inputFiles req._numProcs = numProcs if inputFiles != []: print "Uploading input files..." resp_s = -1 while resp_s == -1: try: resp = appServicePort.launchJob(req) resp_s = 0 except FaultException, inst: estr = inst.fault.AsSOAP() estr = estr.split("<message>")[1].split("</message>")[0] t = strftime("%Y-%m-%d %H:%M:%S", time.localtime()) cte = time.mktime(datetime.now().timetuple()) ete = cte + 60 * 60 + 10 print "WARNING: " + t + " Opal FaultException from server: " + estr print " will try again in about an hour" while time.mktime(datetime.now().timetuple()) < ete: if self.opalNode._vpe is not None: self.opalNode._vpe.updateGuiCycle() net = self.opalNode._node.network if net.execStatus == 'stop': #if self.opalNode._vpe.buttonBar.toolbarButtonDict['stop'].state == "disabled": self.onStoppingExecution() return None time.sleep(0.5) pass except: # no internet