API通用方法¶
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.
参数:
-
rayvision_api.utils.append_to_upload(files_paths, upload_path)¶ Add the asset information you need to upload to upload_info.
参数:
-
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_file_name(name)¶
-
rayvision_api.utils.check_upload_file(file_path, upload_info)¶ Check that the file is already in the upload list.
参数: 返回: bool.
-
rayvision_api.utils.convert_path(path)¶ Convert to the path the server will accept.
参数: path (str) -- Local file path. e.g.:
"D:/work/render/19183793/max/d/Work/c05/112132P-embery.jpg"返回: - Path to the server.
- e.g.:
- "/D/work/render/19183793/max/d/Work/c05/112132P-embery.jpg"
返回类型: 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).
参数: headers (dict) -- The headers of the
Post. e.g.:- {
- "taksId": "2",
"renderEnvs": [
- {
- "envId": 1,
- "pluginIds": [2, 3, 4]
}, {
- "envId": 3,
- "pluginIds": [7, 8, 10]
}
]
返回: Handled request header. 返回类型: 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.
参数: - 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.
返回: Stitched string.
返回类型:
-
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.
参数: 返回: Decoded string.
返回类型:
-
rayvision_api.utils.generate_timestamp()¶ str: The timestamp.
-
rayvision_api.utils.get_os()¶ Get system name.
返回: - The system/OS name.
- e.g.:
LinuxorWindows.
返回类型: 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.
参数: 返回: - Ordered dictionary object after request header and
request parameters are sorted.
返回类型:
-
rayvision_api.utils.hump2underline(hump_str)¶ Convert the hump name to a snake shape.
参数: hump_str (str) -- The name to be converted. 返回: Convert to a snake-like name. 返回类型: str
-
rayvision_api.utils.json_load(json_path, encoding='utf-8')¶ Load the data from the json file.
参数: 返回: - Data in the json file.
- e.g.:
- {
"task_info"
}
返回类型:
-
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.
参数:
-
rayvision_api.utils.to_bytes(string)¶ Convert string to bytes type.