Пример #1
0
def check_path(path):
    """Проверка существования папки для временных изображений"""
    path = BaseUtils.win_encode_path(path)
    if not os.path.isdir(path):
        try:
            os.makedirs(path)
        except OSError as err:
            logger.error("Can't make dir '%s': %s", path, err)
            raise OSError("Can't make dir '{}': {}".format(path, err))
    return path
Пример #2
0
    def _get_base64(image_path):
        """Returns base64 image

        Args:
            image_path (str): Image full path
        """
        base64_image = ""
        image_path = BaseUtils.win_encode_path(image_path)
        if os.path.isfile(image_path):
            with open(image_path, "rb") as image_file:
                base64_image = base64.b64encode(image_file.read())

        return base64_image