1

我的目标是访问我存储在 Looker 文件夹中的视图或图表,并将它们自动添加到 power point 幻灯片中。我正在关注的教程是这个: https ://discourse.looker.com/t/generating-a-powerpoint-presentation-from-all-looks-in-a-space/8191 。

我的问题在于#Generate the PowerPoint(根据教程)。当我运行该命令时,失败消息指出:

    103 chart_test
    Look failed 103: chart_test
    Failed to add image to slide

This corresponds to this piece of code where it fails:

try:
    image = looker_client.LookApi(client).run_look(**look_request)
    image_file = ''.join([str(look.id), '.png'])
    shutil.move(image, image_file)
except:
    print(f'Look failed {look.id}: {look.title}')
    image_file = None

当我打印 'image_file' 时,它是空的('None'),尽管我在名为 'chart_test' 的文件夹 2703 中保存了一个折线图。

有人可以帮忙吗?

4

1 回答 1

1

检查您的参数示例

look_request = {
            "look_id": 21, 
            "result_format": 'png', 
            "image_width": 960, 
            "image_height": 540
        } 

尝试使用最后一个 sdk

import looker_sdk
import shutil 
from looker_sdk import models
sdk = looker_sdk.init40("looker.ini")
look_request = {
            "look_id": 21, 
            "result_format": 'html', 
            "image_width": 960, 
            "image_height": 540
        }

try:
    image1 = sdk.run_look(**look_request)
    image_file1 = '21.png'
    shutil.move(image1, image_file1)
except Exception as e:
    print(e)

您应该在 py 文件所在的文件夹中创建一个文件 looker.ini。

于 2020-06-02T17:06:19.463 回答