Source code for odoo_xmlrpc_twisted.support.support_get_picture_string

"""
Supporting program to test the module :func:`odoo_xmlrpc_twisted.functions.get_picture_string`.
"""

import sys
import os
import base64

# Add functions directory to path for importing custom modules
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'functions'))
from get_picture_string import get_picture_string

# Set the name and path of the resulting image file
current_path = os.path.dirname(os.path.realpath(__file__))
filename = 'picture_get_picture_string.png'
fullpath = os.path.join(current_path, filename)


[docs] def support_get_picture_string(custom_product_id, custom_res_field, custom_name): """ Function to test the module "get_picture_string" The result from that function will be save as a "PNG" image file to check if "get_picture_string" works as expected. """ # call the function "get_picture_string" to get the picture string removed_custom_datas = get_picture_string(custom_product_id, custom_res_field, custom_name) # converting the picture from a base64 string image_str = base64.b64decode(removed_custom_datas) # save it as a picture in the actual path with open(fullpath, 'wb') as imageFile: imageFile.write(image_str) return(filename)