Exemple #1
0
    def DSGetReposInfo(self,
                       handleProj,
                       objectType,
                       infoType,
                       searchCriteria,
                       startingCategory,
                       subcategories=1):
        self.__api.DSGetReposInfo.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_int, ctypes.c_int,
            ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int,
            ctypes.POINTER(DSREPOSINFO)
        ]
        self.__api.DSGetReposInfo.restype = ctypes.c_int

        reposInfo = DSREPOSINFO()
        res = self.__api.DSGetReposInfo(handleProj, objectType, infoType,
                                        encode_string(searchCriteria),
                                        encode_string(startingCategory),
                                        subcategories,
                                        ctypes.pointer(reposInfo))

        if res > 0:
            return reposInfo.info.jobs.contents, None
        if res == 0:
            return None, None

        return None, DSAPIERROR.create_error("DSGetReposInfo",
                                             self.DSGetLastError())
Exemple #2
0
    def DSAddProject(self, projectName, projectLocation=''):
        self.__api.DSAddProject.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
        self.__api.DSAddProject.restype = ctypes.c_int

        res = self.__api.DSAddProject(encode_string(projectName),
                                      encode_string(projectLocation))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSAddProject",
                                                 self.DSGetLastError())
        else:
            return 0, None
Exemple #3
0
    def DSSetServerParams(self, domainName, userName, password, serverName):
        self.__api.DSSetServerParams.argtypes = [
            ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p
        ]
        self.__api.DSSetServerParams.restype = ctypes.c_void_p

        self.__api.DSSetServerParams(encode_string(domainName),
                                     encode_string(userName),
                                     encode_string(password),
                                     encode_string(serverName))

        return True, None
Exemple #4
0
    def DSSetEnvVar(self, handleProj, envVarName, value):
        self.__api.DSSetEnvVar.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_char_p, ctypes.c_char_p
        ]
        self.__api.DSSetEnvVar.restype = ctypes.c_int

        res = self.__api.DSSetEnvVar(handleProj, encode_string(envVarName),
                                     encode_string(value))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetEnvVar",
                                                 self.DSGetLastError())
        else:
            return 0, None
Exemple #5
0
    def DSSetIdForJob(self, handleProj, jobName, jobId):
        self.__api.DSSetIdForJob.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_char_p, ctypes.c_char_p
        ]
        self.__api.DSSetIdForJob.restype = ctypes.c_int

        res = self.__api.DSSetIdForJob(handleProj, encode_string(jobName),
                                       encode_string(jobId))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetIdForJob",
                                                 self.DSGetLastError())
        else:
            return 0, None
Exemple #6
0
    def DSLogEvent(self, handleJob, eventType, message):
        self.__api.DSLogEvent.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_int, ctypes.c_char_p,
            ctypes.c_char_p
        ]
        self.__api.DSLogEvent.restype = ctypes.c_int

        res = self.__api.DSLogEvent(handleJob, eventType, encode_string(''),
                                    encode_string(message))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSLogEvent",
                                                 self.DSGetLastError())
        else:
            return 0, None
Exemple #7
0
    def DSSetProjectProperty(self, handleProj, property, value):
        self.__api.DSSetProjectProperty.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_char_p, ctypes.c_char_p
        ]
        self.__api.DSSetProjectProperty.restype = ctypes.c_int

        res = self.__api.DSSetProjectProperty(handleProj,
                                              encode_string(property),
                                              encode_string(value))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetProjectProperty",
                                                 self.DSGetLastError())
        else:
            return 0, None
Exemple #8
0
    def DSGetIdForJob(self, handleProj, jobName):
        self.__api.DSGetIdForJob.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_char_p
        ]
        self.__api.DSGetIdForJob.restype = ctypes.c_char_p

        jobId = self.__api.DSGetIdForJob(handleProj, encode_string(jobName))

        if not jobId:
            return None, DSAPIERROR.create_error("DSGetIdForJob",
                                                 self.DSGetLastError())
        else:
            return jobId, None
Exemple #9
0
    def DSOpenProject(self, projectName):
        self.__api.DSOpenProjectEx.argtypes = [ctypes.c_int, ctypes.c_char_p]
        self.__api.DSOpenProjectEx.restype = ctypes.POINTER(DSPROJECT)

        handleProj = self.__api.DSOpenProjectEx(self.DSAPI_VERSION,
                                                encode_string(projectName))

        if not handleProj:
            return None, DSAPIERROR.create_error("DSOpenProject",
                                                 self.DSGetLastError())
        else:
            self.__handleProj = handleProj
            return handleProj, None
Exemple #10
0
    def DSJobNameFromJobId(self, handleProj, jobId):
        self.__api.DSJobNameFromJobId.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_char_p
        ]
        self.__api.DSJobNameFromJobId.restype = ctypes.c_char_p

        jobName = self.__api.DSJobNameFromJobId(handleProj,
                                                encode_string(jobId))

        if not jobName:
            return None, DSAPIERROR.create_error("DSJobNameFromJobId",
                                                 self.DSGetLastError())
        else:
            return jobName, None
Exemple #11
0
    def DSGetCustInfo(self, handleJob, stageName, custInfoName, infoType):
        self.__api.DSGetCustInfo.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_char_p, ctypes.c_char_p,
            ctypes.c_int,
            ctypes.POINTER(DSCUSTINFO)
        ]
        self.__api.DSGetCustInfo.restype = ctypes.c_int

        custInfo = DSCUSTINFO()
        res = self.__api.DSGetCustInfo(handleJob, encode_string(stageName),
                                       encode_string(custInfoName), infoType,
                                       ctypes.pointer(custInfo))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetCustInfo",
                                                 self.DSGetLastError())
        else:
            if infoType == self.DSJ_CUSTINFOVALUE:
                return custInfo.info.custInfoValue, None
            if infoType == self.DSJ_CUSTINFODESC:
                return custInfo.info.custInfoDesc, None
            else:
                return '', None
Exemple #12
0
    def DSGetVarInfo(self, handleJob, stageName, varName, infoType):
        self.__api.DSGetVarInfo.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_char_p, ctypes.c_char_p,
            ctypes.c_int,
            ctypes.POINTER(DSVARINFO)
        ]
        self.__api.DSGetVarInfo.restype = ctypes.c_int

        varInfo = DSVARINFO()
        res = self.__api.DSGetVarInfo(handleJob, encode_string(stageName),
                                      encode_string(varName), infoType,
                                      ctypes.pointer(varInfo))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetVarInfo",
                                                 self.DSGetLastError())
        else:
            if infoType == self.DSJ_VARVALUE:
                return varInfo.info.varValue, None
            if infoType == self.DSJ_VARDESC:
                return varInfo.info.varDesc, None
            else:
                return '', None
Exemple #13
0
    def DSGetStageInfo(self, handleJob, stageName, infoType):
        self.__api.DSGetStageInfo.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_char_p, ctypes.c_int,
            ctypes.POINTER(DSSTAGEINFO)
        ]
        self.__api.DSGetStageInfo.restype = ctypes.c_int

        stageInfo = DSSTAGEINFO()
        res = self.__api.DSGetStageInfo(handleJob, encode_string(stageName),
                                        infoType, ctypes.pointer(stageInfo))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetStageInfo",
                                                 self.DSGetLastError())
        else:
            if infoType == self.DSJ_LINKLIST:
                return convert_char_p_to_list(stageInfo.info.linkList), None
            if infoType == self.DSJ_STAGELASTERR:
                return stageInfo.info.lastError, None
            if infoType == self.DSJ_STAGENAME:
                return stageInfo.info.stageName, None
            if infoType == self.DSJ_STAGETYPE:
                return stageInfo.info.typeName, None
            if infoType == self.DSJ_STAGEINROWNUM:
                return stageInfo.info.inRowNum, None
            if infoType == self.DSJ_VARLIST:
                return convert_char_p_to_list(stageInfo.info.varList), None
            if infoType == self.DSJ_STAGESTARTTIMESTAMP:
                return stageInfo.info.stageStartTime, None
            if infoType == self.DSJ_STAGEENDTIMESTAMP:
                return stageInfo.info.stageEndTime, None
            if infoType == self.DSJ_STAGEDESC:
                return stageInfo.info.stageDesc, None
            if infoType == self.DSJ_STAGEINST:
                return convert_char_p_to_list(stageInfo.info.instList), None
            if infoType == self.DSJ_STAGECPU:
                return convert_char_p_to_list(stageInfo.info.cpuList), None
            if infoType == self.DSJ_LINKTYPES:
                return convert_char_p_to_list(stageInfo.info.linkTypes), None
            if infoType == self.DSJ_STAGEELAPSED:
                return stageInfo.info.stageElapsed, None
            if infoType == self.DSJ_STAGEPID:
                return convert_char_p_to_list(stageInfo.info.pidList), None
            if infoType == self.DSJ_STAGESTATUS:
                return stageInfo.info.stageStatus, None
            if infoType == self.DSJ_CUSTINFOLIST:
                return convert_char_p_to_list(
                    stageInfo.info.custInfoList), None
            else:
                return '', None
Exemple #14
0
    def DSGetLinkInfo(self, handleJob, stageName, linkName, infoType):
        self.__api.DSGetLinkInfo.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_char_p, ctypes.c_char_p,
            ctypes.c_int,
            ctypes.POINTER(DSLINKINFO)
        ]
        self.__api.DSGetLinkInfo.restype = ctypes.c_int

        linkInfo = DSLINKINFO()
        res = self.__api.DSGetLinkInfo(handleJob, encode_string(stageName),
                                       encode_string(linkName), infoType,
                                       ctypes.pointer(linkInfo))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetLinkInfo",
                                                 self.DSGetLastError())
        else:
            if infoType == self.DSJ_LINKLASTERR:
                return linkInfo.info.lastError, None
            if infoType == self.DSJ_LINKNAME:
                return linkInfo.info.linkName, None
            if infoType == self.DSJ_LINKROWCOUNT:
                return linkInfo.info.rowCount, None
            if infoType == self.DSJ_LINKSQLSTATE:
                return linkInfo.info.linkSQLState, None
            if infoType == self.DSJ_LINKDBMSCODE:
                return linkInfo.info.linkDBMSCode, None
            if infoType == self.DSJ_LINKDESC:
                return linkInfo.info.linkDesc, None
            if infoType == self.DSJ_LINKSTAGE:
                return linkInfo.info.linkedStage, None
            if infoType == self.DSJ_INSTROWCOUNT:
                return convert_char_p_to_list(linkInfo.info.rowCountList), None
            if infoType == self.DSJ_LINKEXTROWCOUNT:
                return convert_char_p_to_list(linkInfo.info.rowCountList), None
            else:
                return '', None
Exemple #15
0
    def DSSetParam(self, handleJob, paramName, param):
        self.__api.DSSetParam.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_char_p,
            ctypes.POINTER(DSPARAM)
        ]
        self.__api.DSSetParam.restype = ctypes.c_int

        res = self.__api.DSSetParam(handleJob, encode_string(paramName),
                                    ctypes.pointer(param))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetParam",
                                                 self.DSGetLastError())
        else:
            return 0, None
Exemple #16
0
    def DSOpenJob(self, handleProj, jobName):
        self.__api.DSOpenJob.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_char_p
        ]
        self.__api.DSOpenJob.restype = ctypes.POINTER(DSJOB)

        handleJob = self.__api.DSOpenJob(
            handleProj, ctypes.c_char_p(encode_string(jobName)))

        if not handleJob:
            return None, DSAPIERROR.create_error("DSOpenJob",
                                                 self.DSGetLastError())
        else:
            self.__handleJob = handleJob
            return handleJob, None
Exemple #17
0
    def DSServerMessage(self,
                        defMsg,
                        prms=None,
                        msgIdStr='',
                        sizeMessage=1000):
        # How to use messages from the msg.text file?
        # Where to find another message ids? For example DSTAGE_JSG_M_0001-DSTAGE_JSG_M_0075
        # Why [L] and [E] are not replaced?
        # What errors are possible?
        if prms is None:
            prms = []

        if not isinstance(prms, list):
            return None, DSAPIERROR.create_error(
                "DSServerMessage", "Variable prms must be a list")

        maxPrms = len(prms)

        self.__api.DSServerMessage.argtypes = [
            ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p * maxPrms,
            ctypes.c_char_p, ctypes.c_int
        ]
        self.__api.DSServerMessage.restype = ctypes.c_int

        encodedPrms = [encode_string(str(prm)) for prm in prms]
        resMessage = ctypes.c_char_p(encode_string(''))

        msgSize = self.__api.DSServerMessage(
            encode_string(msgIdStr), encode_string(defMsg),
            (ctypes.c_char_p * maxPrms)(*encodedPrms), resMessage, sizeMessage)

        if not resMessage:
            return None, DSAPIERROR.create_error("DSServerMessage",
                                                 self.DSGetLastError())
        else:
            return resMessage.value, None
Exemple #18
0
    def DSGetParamInfo(self, handleJob, paramName):
        self.__api.DSGetParamInfo.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_char_p,
            ctypes.POINTER(DSPARAMINFO)
        ]
        self.__api.DSGetParamInfo.restype = ctypes.c_int

        paramInfo = DSPARAMINFO()
        res = self.__api.DSGetParamInfo(handleJob, encode_string(paramName),
                                        ctypes.pointer(paramInfo))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetParamInfo",
                                                 self.DSGetLastError())
        else:
            return paramInfo, None
Exemple #19
0
    def DSMakeJobReport(self, handleJob, reportType, lineSeparator='CRLF'):
        self.__api.DSMakeJobReport.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_int, ctypes.c_char_p,
            ctypes.POINTER(DSREPORTINFO)
        ]
        self.__api.DSMakeJobReport.restype = ctypes.c_int

        reportInfo = DSREPORTINFO()
        res = self.__api.DSMakeJobReport(handleJob, reportType,
                                         encode_string(lineSeparator),
                                         ctypes.pointer(reportInfo))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSMakeJobReport",
                                                 self.DSGetLastError())
        else:
            return reportInfo.info.reportText, None
Exemple #20
0
    def DSGetLogEventIds(self, handleJob, runNumber=0, filter=''):
        self.__api.DSGetLogEventIds.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_int, ctypes.c_char_p,
            ctypes.POINTER(ctypes.POINTER(ctypes.c_char))
        ]
        self.__api.DSGetLogEventIds.restype = ctypes.c_int

        eventsPointer = ctypes.POINTER(ctypes.c_char)()
        res = self.__api.DSGetLogEventIds(handleJob, runNumber,
                                          encode_string(filter),
                                          ctypes.pointer(eventsPointer))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetLogEventIds",
                                                 self.DSGetLastError())
        else:
            return convert_char_p_to_list(eventsPointer), None
Exemple #21
0
    def DSGetReposUsage(self,
                        handleProj,
                        relationshipType,
                        objectName,
                        recursive=0):
        self.__api.DSGetReposUsage.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_int, ctypes.c_char_p,
            ctypes.c_int,
            ctypes.POINTER(DSREPOSUSAGE)
        ]
        self.__api.DSGetReposUsage.restype = ctypes.c_int

        reposUsage = DSREPOSUSAGE()
        res = self.__api.DSGetReposUsage(handleProj, relationshipType,
                                         encode_string(objectName), recursive,
                                         ctypes.pointer(reposUsage))

        if res > 0:
            return reposUsage.info.jobs.contents, None
        if res == 0:
            return None, None

        return None, DSAPIERROR.create_error("DSGetReposUsage",
                                             self.DSGetLastError())