API General methods

The utils function of the rayvision api.

rayvision_api.utils.append_to_task(additional_info, task_path, cover=True)

Add new field information in task_info.

Parameters:
  • additional_info (dict) – Information that needs to be added
  • cover (bool) – If the added field already exists, whether to overwrite it, The default is overwrite.
rayvision_api.utils.append_to_upload(files_paths, upload_path)

Add the asset information you need to upload to upload_info.

Parameters:
  • files_paths (str or list) – You need to add the uploaded asset path.
  • upload_path (str) – Upload json path.
rayvision_api.utils.assemble_api_url(domain, operators, protocol='https')

Assemble the requests api url.

rayvision_api.utils.check_and_read(json_path)
rayvision_api.utils.check_upload_file(file_path, upload_info)

Check that the file is already in the upload list.

Parameters:
  • file_path (str) – File path.
  • upload_info (dict) – Upload json info.
Returns:

bool.

rayvision_api.utils.convert_path(path)

Convert to the path the server will accept.

Parameters:path (str) –

Local file path. e.g.:

”D:/work/render/19183793/max/d/Work/c05/112132P-embery.jpg”
Returns:
Path to the server.
e.g.:
”/D/work/render/19183793/max/d/Work/c05/112132P-embery.jpg”
Return type:str
rayvision_api.utils.exists_or_create(folder)
rayvision_api.utils.formatted_headers(headers)

Please formatted dictionary.

Possible data types in the dictionary: numbers.Number, str, bytes, list, dict, None (json’s key can only be string, json’s value may be number, string, logical value, array, object, null).

Parameters:headers (dict) –

The headers of the Post. e.g.:

{
“taksId”: “2”, “renderEnvs”: [
{
“envId”: 1,
”pluginIds”: [2, 3, 4]

}, {

”envId”: 3,
”pluginIds”: [7, 8, 10]

}

]

Returns:Handled request header.
Return type:dict
rayvision_api.utils.generate_headers_body_str(domain_name, api_url, header, body)

Generate formatted strings.

Based on header and body for generating signatures (signature and Content-Type do not participate in signatures).

Format is Request Method + Domain Name + API URI + Request String.

Parameters:
  • domain_name (str) – Domain name.
  • api_url (str) – Requested path.
  • header (dict) –

    Request header. e.g.:

    {
    ‘accessId’: ‘xxx’, ‘channel’: ‘4’, ‘platform’: ‘2’, ‘UTCTimestamp’: ‘32166266’, ‘nonce’: ‘1465’, ‘signature’: ‘’, ‘version’: ‘1.0.0’, ‘Content-Type’: ‘application/json’,

    }

    e.g.:
    {
    ‘accessId’: ‘xxx’, ‘channel’: ‘4’, ‘platform’: ‘2’, ‘UTCTimestamp’: ‘32166266’, ‘nonce’: ‘1465’, ‘signature’: ‘’, ‘version’: ‘1.0.0’, ‘Content-Type’: ‘application/json’

    }

  • body (dict) – Request body.
Returns:

Stitched string.

Return type:

str

rayvision_api.utils.generate_nonce()

Generate random Numbers for verification.

rayvision_api.utils.generate_signature(key, msg)

Generate a signature string.

First use the sha256 algorithm to calculate the summary of the msg hashed key and then use the base64 algorithm to get the signature string.

Parameters:
  • key (str) – String added to the processing.
  • msg (str) – Source string.
Returns:

Decoded string.

Return type:

str

rayvision_api.utils.generate_timestamp()

str: The timestamp.

rayvision_api.utils.get_os()

Get system name.

Returns:
The system/OS name.
e.g.:
Linux or Windows.
Return type:str
rayvision_api.utils.headers_body_sort(header, body)

Generate a new processed dictionary.

The http request header and request parameters are sorted in ascending order by the lexicographic order (ASCII) of the parameter names.

Parameters:
  • header (dict) –

    Request header. e.g.:

    {
    ‘accessId’: ‘xxx’, ‘channel’: ‘4’, ‘platform’: ‘2’, ‘UTCTimestamp’: ‘32166266’, ‘nonce’: ‘1465’, ‘signature’: ‘’, ‘version’: ‘1.0.0’, ‘Content-Type’: ‘application/json’

    }

  • body (dict) – Request body.
Returns:

Ordered dictionary object after request header and

request parameters are sorted.

Return type:

dict

rayvision_api.utils.hump2underline(hump_str)

Convert the hump name to a snake shape.

Parameters:hump_str (str) – The name to be converted.
Returns:Convert to a snake-like name.
Return type:str
rayvision_api.utils.json_load(json_path, encoding='utf-8')

Load the data from the json file.

Parameters:
  • json_path (str) – Json file path.
  • encoding (str) – Encoding, default is utf-8.
Returns:

Data in the json file.
e.g.:
{

“task_info”

}

Return type:

dict

rayvision_api.utils.json_save(json_path, data, encoding='utf-8', ensure_ascii=True)

Will save to the json file according to the specified encoded data.

Parameters:
  • json_path (str) – Json file path.
  • data (dict) –

    Asset information data. e.g.:

    {
    “scene_info”: {
    “defaultRenderLayer”:{
    “renderable”: “1”, “is_default_camera”: “1”,

    }

    }

    }

  • encoding (str) – Encoding, default is utf-8.
  • ensure_ascii (bool) – Whether to ignore the error, default True.
rayvision_api.utils.to_bytes(string)

Convert string to bytes type.

rayvision_api.utils.update_task_info(update_info, task_path)

Update the task Settings.

Parameters:
  • update_info (dict) – Information that needs to be updated.
  • task_path (str or dict) – task.json absolute path or dict info.