【问题标题】:Load Url on Pepper's Tablet在 Pepper 的平板电脑上加载 URL
【发布时间】:2019-07-24 14:20:55
【问题描述】:

我正在尝试在 Pepper 上加载一个网站,例如“www.google.com”

我确定我们连接在同一个网络上。我也试过在 ShowApp Dialog 上做“http://www.google.com”。

我看过这个指南:http://kokorobot.com/2016/08/08/how-to-use-pepper-tablet

class MyClass(GeneratedClass):

    def __init__(self):
        GeneratedClass.__init__(self)

    def onLoad(self):
        self.isRunning = False

    def onUnload(self):
        self.isRunning = False

    def _getTabletService(self):
        tabletService = None
        try:
            tabletService = self.session().service("ALTabletService")
        except Exception as e:
            self.logger.error(e)
        return tabletService

    def onInput_onStart(self):
        if self.isRunning:
            return # already running, nothing to do
        self.isRunning = True
        # We create TabletService here in order to avoid
        # problems with connections and disconnections of the tablet during the life of the application
        tabletService = self._getTabletService()
        appName = self.packageUid()
        state = False
        if appName:
            if tabletService:
                if tabletService.loadApplication(appName):
                    tabletService.loadUrl("www.google.com")                    self.logger.info("Successfully set application: %s" % appName)
                    tabletService.showWebview()
                    state = True
                else:
                    self.logger.warning("Got tablet service, but failed to set application: %s" % appName)
            else:
                self.logger.warning("Couldn't find tablet service, so can't set application: %s" % appName)
        if state:
            self.onSuccess()
        else:
            self.onFailure()

【问题讨论】:

  • 您遇到了什么问题?平板电脑是否出现错误、显示白屏或黑屏?你的控制台输出是什么?
  • 白屏,404错误未找到nginx

标签: pepper


【解决方案1】:

如果您想显示网页,请考虑使用“显示网页视图”框。我发现 Show App 带来的麻烦多于它的价值。

class MyClass(GeneratedClass):

    def __init__(self):
        GeneratedClass.__init__(self)

    def onLoad(self):
        pass

    def onUnload(self):
        pass

    def _getTabletService(self):
        tabletService = None
        try:
            tabletService = self.session().service("ALTabletService")
        except Exception as e:
            self.logger.error(e)
        return tabletService

    def _getAbsoluteUrl(self, partial_url):
        import os
        subPath = os.path.join(self.packageUid(), os.path.normpath(partial_url).lstrip("\\/"))
        # We create TabletService here in order to avoid
        # problems with connections and disconnections of the tablet during the life of the application
        return "http://%s/apps/%s" %(self._getTabletService().robotIp(), subPath.replace(os.path.sep, "/"))

    def onInput_onStart(self):
         # We create TabletService here in order to avoid
        # problems with connections and disconnections of the tablet during the life of the application
        tabletService = self._getTabletService()
        if tabletService:
            try:
                url = "http://www.google.com/"
                if url == '':
                    self.logger.error("URL of the image is empty")
                if not url.startswith('http'):
                    url = self._getAbsoluteUrl(url)
                self.logger.info(url)
                tabletService.showWebview(url)
            except Exception as err:
                self.logger.error("Error during ShowImage : %s " % err)
                self.onStopped()
        self.onStopped()

【讨论】:

    猜你喜欢
    • 2021-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    • 1970-01-01
    • 1970-01-01
    • 2020-07-02
    • 1970-01-01
    相关资源
    最近更新 更多