Esempio n. 1
0
    def __init__(self,
                 ocConnectInfo,
                 proxyHost="",
                 proxyPort="",
                 noProxy="",
                 proxyUsr="",
                 proxyPass="",
                 trace=logging.INFO):
        """Constructor

        Param ocConnectInfo holds the basic OpenClinica connection information
        """
        self._logger = logging.getLogger(__name__)
        logging.config.fileConfig("logging.ini",
                                  disable_existing_loggers=False)

        self.ocConnectInfo = ocConnectInfo

        proxyStr = None
        if noProxy != "" and noProxy is not whitespace and noProxy in self.ocConnectInfo.baseUrl:
            proxyStr = None
        else:
            if proxyHost != "" and proxyHost is not whitespace and proxyPort != "" and proxyPort is not whitespace:
                proxyStr = proxyHost + ":" + proxyPort

        if proxyStr:
            self._logger.info("OC SOAP web services are going to use: " +
                              proxyStr)
        else:
            self._logger.info(
                "OC SOAP web services are going to be used with enviromental proxy (including no proxy)."
            )

        self._logger.info(
            "OC SOAP web services are going to be used with authentication: " +
            str(proxyUsr))

        # Define OC WS bindings
        self.studyBinding = OCStudyWsService(
            self.ocConnectInfo.baseUrl + STUDYURL, proxyStr, proxyUsr,
            proxyPass, trace)
        self.dataBinding = OCDataWsService(
            self.ocConnectInfo.baseUrl + DATAURL, proxyStr, proxyUsr,
            proxyPass, trace)
        self.studySubjectBinding = OCStudySubjectWsService(
            self.ocConnectInfo.baseUrl + STUDYSUBJECTURL, proxyStr, proxyUsr,
            proxyPass, trace)
        self.studyEventDefinitionBinding = OCStudyEventDefinitionWsService(
            self.ocConnectInfo.baseUrl + STUDYEVENTDEFURL, proxyStr, proxyUsr,
            proxyPass, trace)
        self.eventBinding = OCEventWsService(
            self.ocConnectInfo.baseUrl + DATAURL, proxyStr, proxyUsr,
            proxyPass, trace)

        # Define WSSE security
        self.studyBinding.wsse(self.ocConnectInfo.userName,
                               self.ocConnectInfo.passwordHash)
        self.dataBinding.wsse(self.ocConnectInfo.userName,
                              self.ocConnectInfo.passwordHash)
        self.studySubjectBinding.wsse(self.ocConnectInfo.userName,
                                      self.ocConnectInfo.passwordHash)
        self.studyEventDefinitionBinding.wsse(self.ocConnectInfo.userName,
                                              self.ocConnectInfo.passwordHash)
        self.eventBinding.wsse(self.ocConnectInfo.userName,
                               self.ocConnectInfo.passwordHash)