def __init__(self, ReportService, ReportExecution, user, key_password, verbose=True): self.verbose = verbose service_cred = dict(username=user, password=key_password) service_cred = HttpAuthenticated(**service_cred) exec_cred = dict(username=user, password=key_password) exec_cred = HttpAuthenticated(**exec_cred) log.basicConfig(filename='SSRS.log', level=log.INFO) try: self.ServiceClient = Client(ReportService, transport=service_cred) self.ExecutionClient = Client(ReportExecution, transport=exec_cred) except BaseException as e: msg = "Error during connection: %s" % e.fault.faultstring log.error(msg) if self.verbose: print(msg) exit()
def get_soap_client(wsdl, cache_requests=True, max_age=MAX_AGE_DEFAULT, minimum_spacing=0): """ Creates and returns a suds/SOAP client instance bound to the provided ``WSDL``. If ``cache_requests`` is True, then the client is configured to use a :class:`CachedThrottledTransport`. The transport is constructed to use :data:`SOAP_CACHE` as the cache folder, along with the ``max_age`` and ``minimum_spacing`` parameters if provided. If ``cache_requests`` is ``False``, the client uses the default :class:`suds.transport.http.HttpAuthenticated` transport. """ if cache_requests is True: if proxy_dict is None: soap_transport = CachedThrottledTransport( cache_dir=SOAP_CACHE, max_age=max_age, minimum_spacing=minimum_spacing, ) else: soap_transport = CachedThrottledTransport( cache_dir=SOAP_CACHE, max_age=max_age, minimum_spacing=minimum_spacing, proxy=proxy_dict, ) else: if proxy_dict is None: soap_transport = HttpAuthenticated() else: soap_transport = HttpAuthenticated(proxy=proxy_dict) return Client(wsdl, transport=soap_transport)
def __init__(self, wsdl_url, username, password, servicename=None): #create parser and download the WSDL document self.url = wsdl_url self.username = username self.password = password self.servicename = servicename if servicename: self.url = self.get_service_url() if is_https(self.url): logger.info("Creating secure connection") from suds.transport.http import HttpAuthenticated http_transport = HttpAuthenticated(username=self.username, password=self.password) else: from suds.transport.http import HttpAuthenticated http_transport = HttpAuthenticated(username=self.username, password=self.password) #Client.__init__(self, self.url, transport=http_transport, plugins=[SoapFixer()]) # uncomment after testing #schema_import = Import(schema_url) #schema_doctor = ImportDoctor(schema_import) Client.__init__(self, self.url, transport=http_transport, plugins=[SoapFixer()]) # added for testing purpose
def process(self, _edObject=None): """ First uses the ImageService to find the imageId. Then uses ToolsForCollectionWebService for storing the image quality indicators. """ EDPluginExec.process(self) self.DEBUG("EDPluginISPyBStoreImageQualityIndicatorsv1_4.process") # First get the image ID xsDataImageQualityIndicators = self.getDataInput().getImageQualityIndicators() strPathToImage = xsDataImageQualityIndicators.getImage().getPath().getValue() strDirName = os.path.dirname(strPathToImage)+os.sep strFileName = os.path.basename(strPathToImage) if strDirName.endswith(os.sep): strDirName = strDirName[:-1] self.DEBUG("Looking for ISPyB imageId for dir %s name %s" % (strDirName, strFileName)) httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated(username=self.strUserName, password=self.strPassWord) clientToolsForCollectionWebService = Client(self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService) iDataCollectionId = clientToolsForCollectionWebService.service.findDataCollectionFromFileLocationAndFileName( strDirName, \ strFileName, \ ) print iDataCollectionId httpAuthenticatedToolsForAutoprocessingWebService = HttpAuthenticated(username=self.strUserName, password=self.strPassWord) clientToolsForAutoprocessingWebService = Client(self.strToolsForAutoprocessingWebServiceWsdl, transport=httpAuthenticatedToolsForAutoprocessingWebService) iImageId = 0 iAutoProcProgramId = self.iAutoProcProgramId iSpotTotal = xsDataImageQualityIndicators.getSpotTotal().getValue() iInResTotal = xsDataImageQualityIndicators.getInResTotal().getValue() iGoodBraggCandidates = xsDataImageQualityIndicators.getGoodBraggCandidates().getValue() iIceRings = xsDataImageQualityIndicators.getIceRings().getValue() fMethod1res = xsDataImageQualityIndicators.getMethod1Res().getValue() fMethod2res = xsDataImageQualityIndicators.getMethod2Res().getValue() fMaxUnitCell = xsDataImageQualityIndicators.getMaxUnitCell().getValue() fPctSaturationTop50peaks = xsDataImageQualityIndicators.getPctSaturationTop50Peaks().getValue() iInResolutionOvrlSpots = xsDataImageQualityIndicators.getInResolutionOvrlSpots().getValue() fBinPopCutOffMethod2res = xsDataImageQualityIndicators.getBinPopCutOffMethod2Res().getValue() providedDate = Date(datetime.datetime.now()) self.iImageQualityIndicatorsId = clientToolsForAutoprocessingWebService.service.storeImageQualityIndicators( strDirName, \ strFileName, \ iImageId, \ iAutoProcProgramId, \ iSpotTotal, \ iInResTotal, \ iGoodBraggCandidates, \ iIceRings, \ fMethod1res, \ fMethod2res, \ fMaxUnitCell, \ fPctSaturationTop50peaks, \ iInResolutionOvrlSpots, \ fBinPopCutOffMethod2res, \ providedDate) self.DEBUG("EDPluginISPyBStoreImageQualityIndicatorsv1_4.process: imageQualityIndicatorsId=%d" % self.iImageQualityIndicatorsId)
def process(self, _edObject=None): """ Uses ToolsForCollectionWebService for storing the workflow status """ EDPluginExec.process(self) self.DEBUG("EDPluginISPyBStoreGridInfov1_4.process") # First get the image ID xsDataInputGridInfo = self.getDataInput() httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated( username=self.strUserName, password=self.strPassWord) clientToolsForCollectionWebService = Client( self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService) gridInfoWS3VO = clientToolsForCollectionWebService.factory.create( 'gridInfoWS3VO') gridInfoWS3VO.gridInfoId = self.getXSValue( xsDataInputGridInfo.gridInfoId) gridInfoWS3VO.workflowMeshId = self.getXSValue( xsDataInputGridInfo.workflowMeshId) gridInfoWS3VO.dx_mm = self.getXSValue(xsDataInputGridInfo.dx_mm) gridInfoWS3VO.dy_mm = self.getXSValue(xsDataInputGridInfo.dy_mm) gridInfoWS3VO.xOffset = self.getXSValue(xsDataInputGridInfo.xOffset) gridInfoWS3VO.yOffset = self.getXSValue(xsDataInputGridInfo.yOffset) gridInfoWS3VO.steps_x = self.getXSValue(xsDataInputGridInfo.steps_x) gridInfoWS3VO.steps_y = self.getXSValue(xsDataInputGridInfo.steps_y) gridInfoWS3VO.meshAngle = self.getXSValue( xsDataInputGridInfo.meshAngle) # print gridInfoWS3VO self.iGridInfoId = clientToolsForCollectionWebService.service.storeOrUpdateGridInfo( gridInfoWS3VO) self.DEBUG("EDPluginISPyBStoreGridInfov1_4.process: WorkflowId=%d" % self.iGridInfoId)
def process(self, _edObject=None): """ Uses ToolsForCollectionWebService for storing the workflow status """ EDPluginExec.process(self) self.DEBUG("EDPluginISPyBSetDataCollectionPositionv1_4.process") # Get the workflow ID and status strImagePath = self.dataInput.fileName.path.value xsDataStartPosition = self.dataInput.startPosition xsDataEndPosition = self.dataInput.endPosition httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated( username=self.strUserName, password=self.strPassWord) clientToolsForCollectionWebService = Client( self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService) startMotorPosition3VO = self.createMotorPosition3VO( clientToolsForCollectionWebService, xsDataStartPosition) if xsDataEndPosition is not None: endMotorPosition3VO = self.createMotorPosition3VO( clientToolsForCollectionWebService, xsDataEndPosition) else: endMotorPosition3VO = None self.iDataCollectionId = clientToolsForCollectionWebService.service.setDataCollectionPosition( fileLocation = os.path.dirname(strImagePath), \ fileName = os.path.basename(strImagePath), \ startPosition = startMotorPosition3VO, \ endPosition = endMotorPosition3VO) self.DEBUG( "EDPluginISPyBSetDataCollectionPositionv1_4.process: DataCollectionId=%r" % self.iDataCollectionId)
def process(self, _edObject=None): """ Uses ToolsForCollectionWebService """ EDPluginISPyBv1_4.process(self) self.DEBUG("EDPluginISPyBSetImageQualityIndicatorsPlotv1_4.process") httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated( username=self.strUserName, password=self.strPassWord) clientToolsForCollectionWebService = Client( self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService, cache=None) # Loop over all positions xsDataInputISPyBSetImageQualityIndicatorsPlot = self.getDataInput() iDataCollectionId = self.getXSValue( xsDataInputISPyBSetImageQualityIndicatorsPlot.dataCollectionId) imageQualityIndicatorsPlotPath = self.getXSValue( xsDataInputISPyBSetImageQualityIndicatorsPlot. imageQualityIndicatorsPlotPath) imageQualityIndicatorsCSVPath = self.getXSValue( xsDataInputISPyBSetImageQualityIndicatorsPlot. imageQualityIndicatorsCSVPath) self.dataCollectionId = clientToolsForCollectionWebService.service.setImageQualityIndicatorsPlot( arg0=iDataCollectionId, \ imageQualityIndicatorsPlotPath=imageQualityIndicatorsPlotPath, \ imageQualityIndicatorsCSVPath=imageQualityIndicatorsCSVPath, \ ) self.DEBUG( "EDPluginISPyBSetImageQualityIndicatorsPlotv1_4.process: dataCollectionId=%r" % self.dataCollectionId)
def run(self, inData): dictConfig = UtilsConfig.getTaskConfig('ISPyB') username = dictConfig['username'] password = dictConfig['password'] httpAuthenticated = HttpAuthenticated(username=username, password=password) wdsl = dictConfig['ispyb_ws_url'] + '/ispybWS/ToolsForCollectionWebService?wsdl' client = Client(wdsl, transport=httpAuthenticated, cache=None) if 'image' in inData: path = pathlib.Path(inData['image']) indir = path.parent.as_posix() infilename = path.name dataCollection = client.service.findDataCollectionFromFileLocationAndFileName( indir, infilename ) elif 'dataCollectionId' in inData: dataCollectionId = inData['dataCollectionId'] dataCollection = client.service.findDataCollection(dataCollectionId) else: errorMessage = 'Neither image nor data collection id given as input!' logger.error(errorMessage) raise BaseException(errorMessage) if dataCollection is not None: outData = Client.dict(dataCollection) else: outData = {} return outData
def process(self, _edObject=None): """ First uses the ImageService to find the imageId. Then uses ToolsForCollectionWebService for storing the image quality indicators. """ EDPluginExec.process(self) self.DEBUG("EDPluginISPyBStoreListOfImageQualityIndicatorsv1_4.process") httpAuthenticatedToolsForAutoprocessingWebService = HttpAuthenticated(username=self.strUserName, password=self.strPassWord) clientToolsForAutoprocessingWebService = Client(self.strToolsForAutoprocessingWebServiceWsdl, transport=httpAuthenticatedToolsForAutoprocessingWebService) # Loop over all input image quality indicators: listImageQualityIndicatorsForWS = [] for xsDataImageQualityIndicators in self.dataInput.imageQualityIndicators: #print xsDataImageQualityIndicators.marshal() imageQualityIndicatorsWS3VO = clientToolsForAutoprocessingWebService.factory.create('imageQualityIndicatorsWS3VO') strPathToImage = xsDataImageQualityIndicators.getImage().getPath().getValue() imageQualityIndicatorsWS3VO.fileName = os.path.basename(strPathToImage) imageQualityIndicatorsWS3VO.fileLocation = os.path.dirname(strPathToImage) # imageQualityIndicatorsWS3VO.imageId = 0 imageQualityIndicatorsWS3VO.autoProcProgramId = self.iAutoProcProgramId imageQualityIndicatorsWS3VO.spotTotal = self.getXSValue(xsDataImageQualityIndicators.spotTotal) imageQualityIndicatorsWS3VO.inResTotal = self.getXSValue(xsDataImageQualityIndicators.inResTotal) imageQualityIndicatorsWS3VO.goodBraggCandidates = self.getXSValue(xsDataImageQualityIndicators.goodBraggCandidates) imageQualityIndicatorsWS3VO.iceRings = self.getXSValue(xsDataImageQualityIndicators.iceRings) imageQualityIndicatorsWS3VO.method1Res = self.getXSValue(xsDataImageQualityIndicators.method1Res) imageQualityIndicatorsWS3VO.method2Res = self.getXSValue(xsDataImageQualityIndicators.method2Res) imageQualityIndicatorsWS3VO.maxUnitCell = self.getXSValue(xsDataImageQualityIndicators.maxUnitCell) imageQualityIndicatorsWS3VO.pctSaturationTop50Peaks = self.getXSValue(xsDataImageQualityIndicators.pctSaturationTop50Peaks) imageQualityIndicatorsWS3VO.inResolutionOvrlSpots = self.getXSValue(xsDataImageQualityIndicators.inResolutionOvrlSpots) imageQualityIndicatorsWS3VO.binPopCutOffMethod2Res = self.getXSValue(xsDataImageQualityIndicators.binPopCutOffMethod2Res) imageQualityIndicatorsWS3VO.totalIntegratedSignal = self.getXSValue(xsDataImageQualityIndicators.totalIntegratedSignal) imageQualityIndicatorsWS3VO.recordTimeStamp = DateTime(datetime.datetime.now()) listImageQualityIndicatorsForWS.append(imageQualityIndicatorsWS3VO) self.listImageQualityIndicatorsId = clientToolsForAutoprocessingWebService.service.storeOrUpdateImageQualityIndicatorsForFileNames( listImageQualityIndicatorsForWS = listImageQualityIndicatorsForWS) self.DEBUG("EDPluginISPyBStoreListOfImageQualityIndicatorsv1_4.process: listImageQualityIndicatorsId=%r" % self.listImageQualityIndicatorsId)
def init_connection(self, company): t = HttpAuthenticated( username=company.postlogistics_username, password=company.postlogistics_password) self.client = Client( company.postlogistics_wsdl_url, transport=t)
def process(self, _edObject=None): """ Uses ToolsForCollectionWebService """ EDPluginISPyBv1_4.process(self) self.DEBUG("EDPluginISPyBSetImagesPositionsv1_4.process") httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated(username=self.strUserName, password=self.strPassWord) clientToolsForCollectionWebService = Client(self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService, cache=None) # Loop over all positions listImagePosition = [] for xsDataImagePosition in self.dataInput.imagePosition: imagePosition = clientToolsForCollectionWebService.factory.create('imagePosition') # Get the workflow ID and status imagePosition.fileName = os.path.basename(xsDataImagePosition.fileName.path.value) imagePosition.fileLocation = os.path.dirname(xsDataImagePosition.fileName.path.value) if xsDataImagePosition.jpegFileFullPath is not None: imagePosition.jpegFileFullPath = xsDataImagePosition.jpegFileFullPath.path.value if xsDataImagePosition.jpegThumbnailFileFullPath is not None: imagePosition.jpegThumbnailFileFullPath = xsDataImagePosition.jpegThumbnailFileFullPath.path.value listImagePosition.append(imagePosition) self.listImageCreation = clientToolsForCollectionWebService.service.setImagesPositions( listImagePosition=listImagePosition) self.DEBUG("EDPluginISPyBSetImagesPositionsv1_4.process: listImageCreation=%r" % self.listImageCreation)
def process(self, _edObject=None): """ Uses ToolsForCollectionWebService for storing the workflow status """ EDPluginISPyBv1_4.process(self) self.DEBUG("EDPluginISPyBStoreWorkflowv1_4.process") # First get the image ID xsDataWorkflow = self.getDataInput().getWorkflow() httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated(username=self.strUserName, password=self.strPassWord) clientToolsForCollectionWebService = Client(self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService, cache=None) workflow3VO = clientToolsForCollectionWebService.factory.create('workflow3VO') workflow3VO.comments = self.getXSValue(xsDataWorkflow.comments) workflow3VO.logFilePath = self.getXSValue(xsDataWorkflow.logFilePath) workflow3VO.recordTimeStamp = self.getDateValue(xsDataWorkflow.recordTimeStamp, "%a %b %d %H:%M:%S %Y", DateTime(datetime.datetime.now())) workflow3VO.resultFilePath = self.getXSValue(xsDataWorkflow.resultFilePath) workflow3VO.status = self.getXSValue(xsDataWorkflow.status) workflow3VO.workflowId = self.getXSValue(xsDataWorkflow.workflowId) workflow3VO.workflowTitle = self.getXSValue(xsDataWorkflow.workflowTitle) workflow3VO.workflowType = self.getXSValue(xsDataWorkflow.workflowType) # print workflow3VO self.iWorkflowId = clientToolsForCollectionWebService.service.storeOrUpdateWorkflow(workflow3VO) self.DEBUG("EDPluginISPyBStoreWorkflowv1_4.process: WorkflowId=%d" % self.iWorkflowId)
def _get_suds_client(self, url, **kw): """ Make a suds client for a specifij WSDL (via url). Added new Suds cache features. Warning: These don't work on Windows. *nix should be fine. Also exposed general kwargs to pass down to Suds for advance users who don't want to deal with set_options(). """ if self.fromurl == False: # We're file:// access, so don't use https transport. t = HttpAuthenticated(username=self.username, password=self.password) c = Client(url, transport=t, doctor=DOCTOR, **kw) else: try: c = Client(url, username=self.username, password=self.password, doctor=DOCTOR, **kw) except URLError as e: t = HTTPSUnVerifiedCertTransport(username=self.username, password=self.password) c = Client(url, username=self.username, password=self.password, doctor=DOCTOR, transport=t, **kw) return c
def process(self, _edObject=None): """ Uses ToolsForCollectionWebService for storing the workflow status """ EDPluginISPyBv1_4.process(self) self.DEBUG("EDPluginISPyBGroupDataCollectionsv1_4.process") xsDataInput = self.getDataInput() arrayOfFileLocation = [] arrayOfFileName = [] for xsDataStringFilePath in xsDataInput.filePath: strFilePath = xsDataStringFilePath.value arrayOfFileLocation.append(os.path.dirname(strFilePath)) arrayOfFileName.append(os.path.basename(strFilePath)) httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated( username=self.strUserName, password=self.strPassWord) clientToolsForCollectionWebService = Client( self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService, cache=None) self.listDataCollectionIds = clientToolsForCollectionWebService.service.groupDataCollections(\ dataCollectionGroupId=self.getXSValue(xsDataInput.dataCollectionGroupId), \ arrayOfFileLocation=arrayOfFileLocation, \ arrayOfFileName=arrayOfFileName, \ ) self.DEBUG( "EDPluginISPyBGroupDataCollectionsv1_4.process: listDataCollectionIds=%r" % self.listDataCollectionIds)
def _wsdl_client(self, service_name): # Handling of redirection at soleil needs cookie handling cj = CookieJar() url_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) trans = HttpAuthenticated(username=self.ws_username, password=self.ws_password) logging.info('_wsdl_client service_name %s - trans %s' % (service_name, trans)) print '_wsdl_client service_name %s - trans %s' % (service_name, trans) trans.urlopener = url_opener urlbase = service_name + "?wsdl" locbase = service_name ws_root = self.ws_root.strip() url = ws_root + urlbase loc = ws_root + locbase print '_wsdl_client, url', url ws_client = Client(url, transport=trans, timeout=3, \ location=loc, cache = None) return ws_client
def process(self, _edObject=None): """ Stores the contents of the AutoProcContainer in ISPyB. """ EDPluginExec.process(self) self.DEBUG("EDPluginISPyBStoreAutoProcStatusv1_4.process") httpAuthenticatedToolsForAutoprocessingWebService = HttpAuthenticated( username=self.strUserName, password=self.strPassWord) clientToolsForAutoprocessingWebService = Client( self.strToolsForAutoprocessingWebServiceWsdl, transport=httpAuthenticatedToolsForAutoprocessingWebService) xsDataInputStoreAutoProcStatus = self.getDataInput() if xsDataInputStoreAutoProcStatus.dataCollectionId is not None: iDataCollectionId = xsDataInputStoreAutoProcStatus.dataCollectionId if xsDataInputStoreAutoProcStatus.autoProcIntegrationId is not None: self.iAutoProcIntegrationId = xsDataInputStoreAutoProcStatus.autoProcIntegrationId if xsDataInputStoreAutoProcStatus.autoProcStatusId is not None: self.iAutoProcStatusId = xsDataInputStoreAutoProcStatus.autoProcStatusId # If autoProcIntegrationId is not given a dataCollectionId must be present: if (self.iAutoProcIntegrationId is None) and (iDataCollectionId is None): strErrorMessage = "Either data collection id or auto proc integration id must be given as input!" self.error(strErrorMessage) self.addErrorMessage(strErrorMessage) else: if self.iAutoProcIntegrationId is None: # If no autoProcessingId is given create a dummy entry in the integration table self.iAutoProcIntegrationId = self.storeOrUpdateAutoProcIntegration( clientToolsForAutoprocessingWebService, _iDataCollectionId=iDataCollectionId) # Store the AutoProcStatus self.iAutoProcStatusId = self.storeOrUpdateAutoProcStatus(clientToolsForAutoprocessingWebService, \ _xsDataAutoProcStatus = xsDataInputStoreAutoProcStatus.getAutoProcStatus(), \ _iAutoProcIntegrationId = self.iAutoProcIntegrationId, \ _iAutoProcStatusId = self.iAutoProcStatusId)
def __init__(self, url, username, password): httpAuthenticatedToolsForAutoprocessingWebService = HttpAuthenticated( username=username, password=password) self.client = Client( url, transport=httpAuthenticatedToolsForAutoprocessingWebService, cache=None, timeout=15)
def main(): url = 'https://blah.com/soap/sp/Services?wsdl' credentials = dict(username='******', password='******') t = HttpAuthenticated(**credentials) client = Client(url, location='https://blah.com/soap/sp/Services', transport=t) print(client.last_sent())
def send(self, xml): t = HttpAuthenticated(username='******', password='******') client = Client( url='http://test3.alignetsac.com/sfewsperu/ws/invoker?wsdl', transport=t) response = client.service.invoke(xml) _logger.info('resultado ' + response) return self
def process(self, _edObject=None): """ Uses ToolsForCollectionWebService for storing the workflow status """ EDPluginISPyBv1_4.process(self) self.DEBUG( "EDPluginISPyBUpdateDataCollectionGroupWorkflowIdv1_4.process") xsDataInput = self.getDataInput() newComment = xsDataInput.newComment.value # print xsDataInput.marshal() httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated( username=self.strUserName, password=self.strPassWord) clientToolsForCollectionWebService = Client( self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService, cache=None) if xsDataInput.dataCollectionId is None: self.ERROR("No input data collection id") self.setFailure() return dataCollectionId = xsDataInput.dataCollectionId.value dataCollectionWS3VO = clientToolsForCollectionWebService.service.findDataCollection( dataCollectionId) if dataCollectionWS3VO is None: self.ERROR( "No data collection corresponding to data collection id {0}". format(dataCollectionId)) self.setFailure() return dataCollectionGroupId = dataCollectionWS3VO.dataCollectionGroupId if dataCollectionGroupId is None: self.ERROR( "No data collection group corresponding to data collection id {0}" .format(dataCollectionId)) self.setFailure() return dataCollectionGroupWS3VO = clientToolsForCollectionWebService.service.findDataCollectionGroup( dataCollectionGroupId) if not newComment in str(dataCollectionGroupWS3VO.comments): dataCollectionGroupWS3VO.comments = newComment self.iDataCollectionGroupId = clientToolsForCollectionWebService.service.storeOrUpdateDataCollectionGroup( dataCollectionGroupWS3VO) # Make sure the comments hasn't already been added by ISPyB: dataCollectionWS3VO = clientToolsForCollectionWebService.service.findDataCollection( dataCollectionId) if hasattr(dataCollectionWS3VO, "comments"): if not newComment in dataCollectionWS3VO.comments: dataCollectionWS3VO.comments += " " + newComment dataCollectionId = clientToolsForCollectionWebService.service.storeOrUpdateDataCollection( dataCollectionWS3VO) else: dataCollectionWS3VO.comments = newComment dataCollectionId = clientToolsForCollectionWebService.service.storeOrUpdateDataCollection( dataCollectionWS3VO) self.DEBUG( "EDPluginISPyBUpdateDataCollectionGroupWorkflowIdv1_4.process: DataCollectionGroupId=%r" % self.iDataCollectionGroupId)
def __initWebservice(self): self.httpAuthenticatedToolsForAutoprocessingWebService = HttpAuthenticated( username=self.user, password=self.password) self.client = Client( self.URL, transport=self.httpAuthenticatedToolsForAutoprocessingWebService, cache=None, timeout=self.timeout) self.experiments = [] self.response = None
def __init__(self, **kwargs): if 'url' not in kwargs.keys(): self.complain(self.parameter_error, 'url') self.__dict__.update(kwargs) t = HttpAuthenticated(username=self.username, password=self.password) #self.client = Client(self.url, transport=t) self.client = Client(self.url) self.service = self.client.service self.session = self.service.login(self.username, self.password)
def init_app(self, app): """Initializes user office class. Args: app (flask app): Flask app """ http_auth = HttpAuthenticated(username=app.config.get("SMIS_USERNAME"), password=app.config.get("SMIS_PASSWORD")) self.smis_ws = Client(app.config.get("SMIS_WS_URL"), transport=http_auth, cache=None, timeout=180)
def process(self, _edObject=None): """ Uses ToolsForCollectionWebService for storing the workflow status """ EDPluginExec.process(self) self.DEBUG("EDPluginISPyBUpdateWorkflowStatusv1_4.process") # Get the workflow ID and status iWorkflowId = self.dataInput.workflowId.value strStatus = self.dataInput.newStatus.value httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated(username=self.strUserName, password=self.strPassWord) clientToolsForCollectionWebService = Client(self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService) self.iWorkflowId = clientToolsForCollectionWebService.service.updateWorkflowStatus(iWorkflowId, strStatus) self.DEBUG("EDPluginISPyBUpdateWorkflowStatusv1_4.process: WorkflowId=%d" % self.iWorkflowId)
def __init__(self, credentials): # logging.basicConfig(level=logging.INFO) # logging.getLogger('suds.client').setLevel(logging.DEBUG) soap_url = 'http://api.rostelecontent.ru/server.services.php' wsdl_url = 'http://api.rostelecontent.ru/services.wsdl' transport = HttpAuthenticated(**credentials) self.api = Client(url=wsdl_url, location=soap_url, transport=transport, plugins=[NamespaceCorrectionPlugin()]) self.api.set_options(cache=None)
def main(): # Build transport and client objects using HttpAuth for authentication # and MessagePlugin to allow the capturing of raw XML, necessary for # extracting the IPControl session ID later plugin = MyPlugin() credentials = dict(username=user, password=pw) transport = HttpAuthenticated(**credentials) client = Client('http://ipcontrol.foobar.net/inc-ws/services/Exports?wsdl', headers={ 'username': user, 'password': pw }, transport=transport, plugins=[plugin]) query_parameters = ('ipaddress = 1.2.3.4', False ) # The boolean is for includeFreeBlocks # Exports must be initialized first. The IPControl session ID can then # be extracted from the raw reply data. This is necessary later when # the export service is called. context = client.service.initExportChildBlock(*query_parameters) session_id_re = re.search(r'([0-9-]{19,20})', str(plugin.last_received_raw), re.M) if session_id_re: session_id = session_id_re.group(1) print("SESSION ID: {}".format(session_id)) else: print("NO SESSION ID FOUND") sys.exit() # Build a new SOAP header where the 'sessionID' is set to the value extracted # from the raw initialization reply data above, then apply the new # header to the existing client object. sid = Element( 'sessionID', ns=('ns1', 'http://xml.apache.org/axis/session')).setText(session_id) sid.set("SOAP-ENV:mustUnderstand", "0") sid.set("SOAP-ENV:actor", "http://schemas.xmlsoap.org/soap/actor/next") sid.set("xsi:type", "soapenc:long") client.set_options(soapheaders=sid) result = client.service.exportChildBlock(context) print("RESULT: {}".format(result))
def preProcess(self, _edObject=None): EDPluginControl.preProcess(self) # Initializing webservices self.DEBUG("EDPluginBioSaxsISPyBv1_0.preProcess") self.dataBioSaxsSample = self.dataInput.sample user = None password = "" if self.dataBioSaxsSample: if self.dataBioSaxsSample.login: user = self.dataBioSaxsSample.login.value password = self.dataBioSaxsSample.passwd.value if not user: self.ERROR( "No login/password information in sample configuration. Giving up." ) self.setFailure() return # I don't trust in this authentication.... but it is going to work soon self.httpAuthenticatedToolsForBiosaxsWebService = HttpAuthenticated( username=user, password=password) self.client = Client( self.URL, transport=self.httpAuthenticatedToolsForBiosaxsWebService, cache=None) if self.dataInput.dammifAvg: self.dammifAvg = self.dataInput.dammifAvg.value if self.dataInput.dammifFilter: self.dammifFilter = self.dataInput.dammifFilter.value if self.dataInput.dammifStart: self.dammifStart = self.dataInput.dammifStart.value if self.dataInput.dammifJobs: self.dammifJobs = self.dataInput.dammifJobs.value if self.dataInput.scatterPlotFile: self.scatterPlotFilePath = self.dataInput.scatterPlotFile.path.value if self.dataInput.guinierPlotFile: self.guinierPlotFilePath = self.dataInput.guinierPlotFile.path.value if self.dataInput.kratkyPlotFile: self.kratkyPlotFilePath = self.dataInput.kratkyPlotFile.path.value
def preProcess(self, _edObject=None): EDPluginControl.preProcess(self) # Initializing webservices self.DEBUG("EDPluginBioSaxsISPyB_HPLCv1_0.preProcess") self.dataBioSaxsSample = self.dataInput.sample user = None password = "" if self.dataBioSaxsSample: if self.dataBioSaxsSample.login: user = self.dataBioSaxsSample.login.value password = self.dataBioSaxsSample.passwd.value if self.dataBioSaxsSample.ispybURL: self.URL = self.dataBioSaxsSample.ispybURL.value if not user: self.ERROR( "No login/password information in sample configuration. Giving up. falling back on test mode" ) # self.setFailure() # return user = "******" password = "******" # construct code based on letters + numbers user concept self.code = ''.join(i for i in user if i.isalpha()) self.number = ''.join(i for i in user if i.isdigit()) # I don't trust in this authentication.... but it is going to work soon self.httpAuthenticatedToolsForBiosaxsWebService = HttpAuthenticated( username=user, password=password) self.client = Client( self.URL, transport=self.httpAuthenticatedToolsForBiosaxsWebService, cache=None) if (self.dataInput.hdf5File is not None): if (self.dataInput.hdf5File.path is not None): self.hdf5File = self.dataInput.hdf5File.path.value if (self.dataInput.jsonFile is not None): if (self.dataInput.jsonFile.path is not None): self.jsonFile = self.dataInput.jsonFile.path.value if (self.dataInput.hplcPlot is not None): if (self.dataInput.hplcPlot.path is not None): self.hplcPlot = self.dataInput.hplcPlot.path.value
def _get_suds_client(self, url): """ Make a suds client for a specific WSDL (via url). For now, we have to work around a few minor issues with the Suds cache and different authentication methods based on uri or file:// access. """ if self.fromurl == False: # We're file:// access, so don't use https transport. t = HttpAuthenticated(username = self.username, password = self.password) # Suds will intermittantly throw a SAX exception trying to parse cached files. # if it does this, retry. c = Client(url, transport=t, doctor=DOCTOR) else: c = Client(url, username=self.username, password=self.password,doctor=DOCTOR) return c
def process(self, _edObject=None): """ Uses ToolsForCollectionWebService for storing the workflow status """ EDPluginISPyBv1_4.process(self) self.DEBUG("EDPluginISPyBStoreWorkflowStepv1_4.process") # First get the image ID httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated( username=self.strUserName, password=self.strPassWord) clientToolsForCollectionWebService = Client( self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService, cache=None) dictWorkflowStep = { "workflowId": self.getXSValue(self.dataInput.workflowId), "workflowStepType": self.getXSValue(self.dataInput.workflowStepType), "status": self.getXSValue(self.dataInput.status), "folderPath": self.getXSValue(self.dataInput.folderPath), "imageResultFilePath": self.getXSValue(self.dataInput.imageResultFilePath), "htmlResultFilePath": self.getXSValue(self.dataInput.htmlResultFilePath), "resultFilePath": self.getXSValue(self.dataInput.resultFilePath), "comments": self.getXSValue(self.dataInput.comments), "crystalSizeX": self.getXSValue(self.dataInput.crystalSizeX), "crystalSizeY": self.getXSValue(self.dataInput.crystalSizeY), "crystalSizeZ": self.getXSValue(self.dataInput.crystalSizeZ), "maxDozorScore": self.getXSValue(self.dataInput.maxDozorScore), } strDictWorkflowStep = json.dumps(dictWorkflowStep) self.iWorkflowStepId = clientToolsForCollectionWebService.service.storeWorkflowStep( strDictWorkflowStep) self.DEBUG( "EDPluginISPyBStoreWorkflowStepv1_4.process: WorkflowStepId = {0}". format(self.iWorkflowStepId))