当前位置: 首页>>代码示例>>Python>>正文


Python MPDClient._write_command方法代码示例

本文整理汇总了Python中mpd.MPDClient._write_command方法的典型用法代码示例。如果您正苦于以下问题:Python MPDClient._write_command方法的具体用法?Python MPDClient._write_command怎么用?Python MPDClient._write_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mpd.MPDClient的用法示例。


在下文中一共展示了MPDClient._write_command方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import _write_command [as 别名]

#.........这里部分代码省略.........
                result = self.sensors.detect_sound(False)
                # usb ports off (audio usb)
                if self.hub_ctrl != None:
                    self.mpd_client.disableoutput(0)
                    time.sleep(2)
                    self.power_off_usbs();
                    logging.info("Power off usbs")
                    self.off=True
                    # since we disabled output mpd_cliend.idle will issue new event with status stop again
                    self.just_off = True

            # usb ports on (audio usb)
            if state =='stop' and last_state=='stop':
                if self.just_off:
                    # just power off consuming dsiableoutput event
                    self.just_off = False;
                elif self.off and self.hub_ctrl != None:
                    # if this is a play command it will not work since power is off but will poweron usb for next command
                    self.power_on_usbs();
                    logging.info("Power on usbs")
                    self.off = False
                    time.sleep(2)
                    self.mpd_client.enableoutput(0)

            last_state = state
            if hasattr(self,'mpd_event'):
                self.mpd_event(result);
        logging.info("===Ending thread for mpd status listener===\n")

    def run(self):
        if not self.started:
            self.sensors.detect_all(True)
            self.worker_thread_mpd = threading.Thread(target=self.mpd_worker)
            self.worker_thread_mpd.start()
            self.started = True
            return True;
        else:
            return False;

    def stop(self):
        if self.started:
            self.sensors.detect_all(False)
            self.running_thread = False # signal thread end and wait for it
            self.mpd_client._write_command("noidle") # https://github.com/Mic92/python-mpd2/pull/26 instead of self.mpd_client.noidle()
            time.sleep(1)
            self.worker_thread_mpd.join()
            self.started = False
            return True
        else:
            return False

    def get_temp_graph(self):
        rrdtool.graph("./test.png",
                  '--imgformat', 'PNG',
                  '--width', '540',
                  '--height', '100',
                  #'--start', "-%i" % YEAR,
                  #'--end', "-1",
                  '--vertical-label', 'Humidity',
                  '--title', 'Temp/Humidity',
                  '--upper-limit', '100',
                  '--lower-limit', '0',
                  '--right-axis', '0.2:10',
                  '--right-axis-label','Temperature',
                  'DEF:temp='+self.rrd['path']+self.rrd['temp_file']+':living_room_temp:AVERAGE',
                  'DEF:humid='+self.rrd['path']+self.rrd['humidity_file']+':humidity:AVERAGE',
                  'CDEF:temp_scale=temp,10,-,5,*',
                  'LINE1:humid#0000ff:Humidity',
                  'LINE1:temp_scale#ff0000:Temperature',)
        photo = open('./test.png', 'rb')
        return photo

    def power_self(self):
        call("sudo poweroff", shell=True)

    def reboot_self(self):
        call("sudo reboot", shell=True)

    def power_on_usbs(self):
        #call(self.hub_ctrl['path']+"hub-ctrl -h 0 -P 2 -p 1", shell=True)
        pass

    def power_off_usbs(self):
        #call(self.hub_ctrl['path']+"hub-ctrl -h 0 -P 2 -p 0", shell=True)
        pass

    def power_samsung_tv(self, tv):
        try:
            myremote = remote.Remote(tv['ip'],tv['mac'],tv['model'])
            myremote.connect(3)
            myremote.sendkey('KEY_POWEROFF')
            myremote.close()
        except:
            pass

    def power_nas(self):
        pass

    def wol(self,mac):
        wol.send_magic_packet(mac)
开发者ID:Jacq,项目名称:RaspberryBot,代码行数:104,代码来源:helpers.py

示例2: _write_command

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import _write_command [as 别名]
 def _write_command(self, command, args=[]):
     args = [unicode(arg).encode(ENCODING) for arg in args]
     MPDClientBase._write_command(self, command, args)
开发者ID:tarmack,项目名称:Pythagora,代码行数:5,代码来源:mpdunicode.py


注:本文中的mpd.MPDClient._write_command方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。