Beispiel #1
0
   res, err = dsapi.DSGetJobInfo(hjob, dsapi.DSJ_PARAMLIST)
   if err:
      raise Exception("DSJ_PARAMLIST. Can't get the job info: {}".format(err))
   print("DSJ_PARAMLIST = {}".format(res))

   print("Blocking the job {}".format(DS_JOB_NAME))
   res, err = dsapi.DSLockJob(hjob)
   if err:
      raise Exception("Can't block the job: {}".format(err))

   print("Setting launch parameters")
   job_param = DSPARAM()
   job_param.paramType = dsapi.DSJ_PARAMTYPE_STRING
   job_param.paramValue.pString = dsapi.encodeString('string value')
   res, err = dsapi.DSSetParam(hjob, 'param_str', job_param)
   if err:
      print("Can't set the parameter: {}".format(err))

   job_param = DSPARAM()
   job_param.paramType = dsapi.DSJ_PARAMTYPE_ENCRYPTED
   job_param.paramValue.pEncrypt = dsapi.encodeString('string encrypted value')
   res, err = dsapi.DSSetParam(hjob, 'param_encrypted', job_param)
   if err:
      print("Can't set the parameter: {}".format(err))

   print("Launching the job {}".format(DS_JOB_NAME))
   res, err = dsapi.DSRunJob(hjob, dsapi.DSJ_RUNNORMAL)
   if err:
      raise Exception("Can't launch the job: {}".format(err))
    if err:
        raise Exception("Can't open the job {}: {}".format(DS_JOB_NAME, err))

    print("Blocking the job {}".format(DS_JOB_NAME))
    res, err = dsapi.DSLockJob(hjob)
    if err:
        raise Exception("Can't block the job: {}".format(err))

    DS_JOB_STR_PARAM_NAME = 'p_str_fake'
    DS_JOB_STR_PARAM_VALUE = 'string fake param value'

    print("Setting launch parameters")
    job_param = DSPARAM()
    job_param.paramType = dsapi.DSJ_PARAMTYPE_STRING
    job_param.paramValue.pString = encode_string(DS_JOB_STR_PARAM_VALUE)
    _, err = dsapi.DSSetParam(hjob, DS_JOB_STR_PARAM_NAME, job_param)
    if err:
        print("Can't set the parameter: {}".format(err))

    last_err_code = err['code']

    print('Preparing message with your own template')
    res, err = dsapi.DSServerMessage(
        'Error calling DSSetParam(%1), code=%2[E]',
        [DS_JOB_STR_PARAM_NAME, last_err_code])
    if err:
        print("Can't prepare the message: {}".format(err))
    else:
        print(res)

    print(