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.
- 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_upload_file(file_path, upload_info)¶
Check that the file is already in the upload list.
- rayvision_api.utils.convert_path(path)¶
Convert to the path the server will accept.
- rayvision_api.utils.exists_or_create(folder)¶
- rayvision_api.utils.extract_file(files_path)¶
- Parameters:
files_path – upload a dir or files
Returns: []
- 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).
- 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:
- 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.
- rayvision_api.utils.generate_timestamp()¶
str: The timestamp.
- rayvision_api.utils.get_os()¶
Get system name.
- Returns:
- The system/OS name.
- e.g.:
Linux
orWindows
.
- Return type:
- 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:
- Returns:
- Ordered dictionary object after request header and
request parameters are sorted.
- Return type:
- rayvision_api.utils.hump2underline(hump_str)¶
Convert the hump name to a snake shape.
- rayvision_api.utils.json_load(json_path, encoding='utf-8')¶
Load the data from the json file.
- 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.
- rayvision_api.utils.update_task_info(update_info, task_path)¶
Update the task Settings.
- rayvision_api.utils.walk_files(folder, contains=True)¶
Get all files in directory recursively @param str folder: the root directory @param bool contains: Whether to include the folder in file path