Access to Muster python API from inside Nuke 13

Viewing 6 posts - 1 through 6 (of 6 total)
  • 11th May 2021 at 10:50 am #34375

    Hi,

    We are trying to migrate our internal submitter to work with newer versinos of nuke and therefore newer versions of python 3.x instead of 2.x

    Im trying to run this(I know indentation is wrong but that’s copy past issue here in the forum and not in the code):
    And I keep getting the error:
    File “//fs/data/_pipeline/_bin/nuke/assetsystem2D/src/nuke\muster.py”, line 197, in submit
    contents = urlreq.urlopen(req,context=context).read()
    File “C:\Program Files\Nuke13.0v2\lib\urllib\request.py”, line 222, in urlopen
    return opener.open(url, data, timeout)
    File “C:\Program Files\Nuke13.0v2\lib\urllib\request.py”, line 531, in open
    response = meth(req, response)
    File “C:\Program Files\Nuke13.0v2\lib\urllib\request.py”, line 641, in http_response
    ‘http’, request, response, code, msg, hdrs)
    File “C:\Program Files\Nuke13.0v2\lib\urllib\request.py”, line 569, in error
    return self._call_chain(*args)
    File “C:\Program Files\Nuke13.0v2\lib\urllib\request.py”, line 503, in _call_chain
    result = func(*args)
    File “C:\Program Files\Nuke13.0v2\lib\urllib\request.py”, line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
    urllib.error.HTTPError: HTTP Error 400: Bad Request

    I’m not super familiar with debudding these http errors and a blank 400 error is a brick wall for me right now.
    I’ve tried to verify that the JSON I’m sending is correct and it seems correct. It’s the same JSON we sent using python 2.7 and it worked then.

    The code is grabbed from the vvmuster.py shipping with muster 9 for the houdini pdg submitter

    try:
    if is_json(cmd):
    url = self.url + “/api/queue/actions?” + urllib.parse.urlencode({‘name’:’submit’,’authToken’:authToken})
    cmd = base64.b64encode(cmd.encode())
    req = urlreq.Request(url,cmd)

    req.add_header(‘Content-Type’, ‘application/json’)
    req.add_header(‘User-Agent’, ‘Houdini (PDG)’)

    context = ssl._create_unverified_context()
    contents = urlreq.urlopen(req,context=context).read()
    res = json.loads(contents)

    if ‘ResponseStatus’ in res:
    if ‘Code’ in res[‘ResponseStatus’]:
    retCode = int(res[“ResponseStatus”][“Code”])
    description = res[“ResponseStatus”][“Description”]
    if retCode == 200:
    job_id = res[“ResponseStatus”][“objectId”]
    self.jobs_lock.acquire()
    self.active_jobs[job_id] = { ‘name’ : item_name , ‘index’ : item_id }
    self.jobs_lock.release()
    logger.debug(‘Scheduling: {} {} successfully’.format(node_name, item_name))
    work_item.data.setInt(“muster_jobid”, job_id, 0)
    return 0
    else:
    logger.error(“Scheduling failed: {}:{}”.format(retCode,description))
    else:
    logger.error(“Scheduling failed: Invalid response from server”)
    else:
    logger.error(“Scheduling failed: Invalid response from server”)

    else:
    print(‘JSON fail’)

    except:
    logger.error(“Failed to connect to the Dispatcher service REST APIs endpoint ” +self.url)
    import traceback
    traceback.print_exc()
    sys.stderr.flush()
    return 1

    Any help in how to approach this, or any idea of what I might be doing wrong here would be very appreciated

    Regards,
    /Christian

    11th May 2021 at 11:14 am #34376

    Now I’m getting this. might be a little bit more specific but cant find any docs about it:

    contacting url: http://10.10.10.194:9890/api/queue/actions?name=submit&authToken=4525587D301B4ED27B5007817B04222609A499C

    still erroring on this line:
    contents = urlreq.urlopen(req,context=context).read()

    Giving me this now:
    ERROR 11:11:13.531:muster(33024): Failed to connect to the Dispatcher service REST APIs endpoint

    11th May 2021 at 12:21 pm #34378

    not 100% sure but you switched to v3 , and it’s possible http requests are no longer valid. you should try with https on port 9891 , it’s clearly stated that there’s no active REST API’s endpoint on this address

    regards.

    11th May 2021 at 2:29 pm #34379

    hmm.. when I try and go through 9081 I get this:

    ERROR 14:24:47.840:muster(33024): Failed to connect to the Dispatcher service REST APIs endpoint http://10.10.10.194:9891/api/queue/actions?name=submit&authToken=790C75161C680863A6077505FFDEBD7609A76FB

    and now switching back 9080 gives me this again:
    urllib.error.HTTPError: HTTP Error 400: Bad Request

    12th May 2021 at 9:04 am #34380

    A very clever individual just found a fix.
    ———————————————————————-
    #cmd = base64.b64encode(cmd.encode()) # I started out doing this.
    cmd_encoded = cmd.encode() #This was the fix for some reason, not sure why
    request = urlreq.Request(self.url + ‘/api/queue/actions?name=submit&authToken=’ + authToken, cmd_encoded)
    contents = urlreq.urlopen(request).read()
    response = json.loads(contents)

    if ‘ResponseStatus’ in response and ‘objectId’ in response[‘ResponseStatus’]:
    jobID = response[‘ResponseStatus’][‘objectId’]

    ———————————————————————-

    12th May 2021 at 2:08 pm #34381

    Correction. That didnt solve it.
    Seems like it has to do with how some strings are paresed.

    encodestring = ‘Default\n’ + self.outputMask.replace(‘/’, ‘\\’) + ‘\n’
    encoded = base64.b64encode(encodestring.encode()).decode() # here is the secret sauce

    We have to encode the strings to encoded b64 and then decode it to get the command to be interpreted alright. no clue why but now it works

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.