Exemple #1
0
    def callback(self, cmd, msg):
        self._home.publish_msg(cmd, u"正在截图...")

        Sound.notice(Res.get_res_path("sound/com_shoot"))

        save_path="data/capture/"
        save_name, thumbnail_name = CameraHelper().take_a_photo(save_path)
        # for test
        # save_name = "2015_05_02_164052.jpg"
        if save_name is None:
            self._home.publish_msg(cmd, u"截图失败")
            INFO("capture faild.")
            return True
        img_url, thumbnail_url = self._upload_image(
                save_path + save_name,
                save_path + thumbnail_name,
                )
        if img_url is None:
            self._home.publish_msg(cmd, u"截图失败")
            INFO("upload capture faild.")
            return True
        else:
            self._home.publish_msg(
                    cmd,
                    msg=img_url,
                    cmd_type="capture"
                    )
        return True
Exemple #2
0
    def callback(self, cmd, action, target, msg):
        if msg is None:
            self._home.publish_msg(cmd, u"时间格式错误")
            return False, None

        if msg.endswith(u'点') or \
           msg.endswith(u'分'):
            t = Util.gap_for_timestring(msg)
        elif msg.endswith(u"秒"):
            t = int(Util.cn2dig(msg[:-1]))
        elif msg.endswith(u"分钟"):
            t = int(Util.cn2dig(msg[:-2]))*60
        elif msg.endswith(u"小时"):
            t = int(Util.cn2dig(msg[:-2]))*60*60
        else:
            self._home.publish_msg(cmd, u"时间格式错误")
            return False
        if t is None:
            self._home.publish_msg(cmd, u"时间格式错误")
            return False, None
        DEBUG("thread wait for %d sec" % (t, ))
        self._home.publish_msg(cmd, action + target + msg)

        threading.current_thread().waitUtil(t)
        if threading.current_thread().stopped():
            return False
        self._home.setResume(True)
        count = 7
        Sound.notice( Res.get_res_path("sound/com_bell"), True, count)
        self._home.setResume(False)
        return True