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


Python MPDClient.idletimeout方法代码示例

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


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

示例1: print_files

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
def print_files():
    sync_files = open('/media/satellite_mpds/files2sync.txt','a')
    client=MPDClient()
    mopidyAddress = 'localhost'
    mopidyPort = 6600

    client.timeout = 10
    client.idletimeout = None
    client.connect(mopidyAddress,mopidyPort)
    #client.password('IlPits2013')
    files = client.playlistinfo()
#    files = client.lsinfo(foldername)
    files = [x['file'] for x in files]
    files = sorted(files)
    outfiles=[]
    for f in files:
        real_path=os.path.join(music_dir,f)
        if os.path.exists(real_path):
            if os.path.islink(real_path):
                target_path = os.readlink(real_path)
                abs_target_path = os.path.realpath(real_path)
                target_path_rel_to_music_dir = os.path.relpath(abs_target_path, music_dir)
                print target_path_rel_to_music_dir
                sync_files.write(target_path_rel_to_music_dir+'\n')
                outfiles.append(target_path_rel_to_music_dir)
            sync_files.write(f+'\n')
            outfiles.append(f)
            print('ADDED')
            print f
    sync_files.close()
    #print(files)
    client.disconnect()
开发者ID:NilsNoreyson,项目名称:phoneBookServer,代码行数:34,代码来源:get_phonebook_files.py

示例2: yoinkMPD

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
def yoinkMPD(cod):
    mpd = MPDClient(use_unicode=True)
    mpd.timeout = None
    mpd.idletimeout = None
    mpd.connect(cod.config["mpd"]["host"], cod.config["mpd"]["port"])

    return mpd
开发者ID:Xe,项目名称:code,代码行数:9,代码来源:mpdclient.py

示例3: mpd_status

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
def mpd_status():
    client = MPDClient()
    client.timeout = 10
    client.idletimeout = None
    client.connect("lounge.mpd.shack", 6600)
    answer = client.currentsong()
    state = client.status()
    client.close()
    client.disconnect()
    if 'artist' in answer:
        return jsonify(artist = answer['artist'],
                   title = answer['title'],
                   status = state['state'],
                   stream = 'false')
    elif 'name' in answer:
        return jsonify(name=answer['name'],
                       title=answer['title'],
                       stream='true',
                       status = state['state'])
    elif 'file' in answer:
        return jsonify(title=answer['file'],
                       status = state['state'],
                       stream='undef')
    else:
        return jsonify(error='unknown playback type')
    return jsonify(error='unknown playback type')
开发者ID:shackspace,项目名称:gobbelz,代码行数:28,代码来源:routes.py

示例4: delegateInput

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
    def delegateInput(self, texts):
        """A wrapper for querying brain."""

        # check if input is meant to start the music module
        for text in texts:
            if any(x in text.upper() for x in ["SPOTIFY", "MUSIC"]):
                self._logger.debug("Preparing to start music module")
                # check if mpd client is running
                try:
                    client = MPDClient()
                    client.timeout = None
                    client.idletimeout = None
                    client.connect("localhost", 6600)
                except:
                    self._logger.critical("Can't connect to mpd client, cannot start music mode.", exc_info=True)
                    self.mic.say(
                        "I'm sorry. It seems that Spotify is not enabled. Please read the documentation to learn how to configure Spotify.")
                    return

                self.mic.say("Please give me a moment, I'm loading your Spotify playlists.")
                self._logger.debug("Starting music mode")
                music_mode = MusicMode(self.persona, self.mic)
                music_mode.handleForever()
                self._logger.debug("Exiting music mode")
                return

        self.brain.query(texts)
开发者ID:gregnorth,项目名称:jasper-client,代码行数:29,代码来源:conversation.py

示例5: connect

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
	def connect(self,port):
		global client
		connection = False
		retry = 2
		while retry > 0:
			client = MPDClient()	# Create the MPD client
			try:
				client.timeout = 10
				client.idletimeout = None
				client.connect("localhost", port)
				log.message("Connected to MPD port " + str(port), log.INFO)
				connection = True
				retry = 0
			except:
				log.message("Failed to connect to MPD on port " + str(port), log.ERROR)
				time.sleep(0.5)	# Wait for interrupt in the case of a shutdown
				log.message("Restarting MPD",log.DEBUG)
				if retry < 2:
					self.execCommand("service mpd restart") 
				else:
					self.execCommand("service mpd start") 
				time.sleep(2)	# Give MPD time to restart
				retry -= 1

		return connection
开发者ID:MicroSDHC,项目名称:piradio,代码行数:27,代码来源:radio_class.py

示例6: __enter__

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
 def __enter__(self):
     client = MPDClient(use_unicode=True)
     self.client = client
     client.timeout = 1
     client.idletimeout = None
     client.connect("131.urlab.be", 6600)
     return client
开发者ID:UrLab,项目名称:api,代码行数:9,代码来源:views.py

示例7: delegateInput

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
 def delegateInput(self, text):
     """A wrapper for querying brain."""
     got_hit = False
     # check if input is meant to start the music module
     if any(x in text.upper() for x in ["SPOTIFY", "MUSIC"]):
         # check if mpd client is running
         try:
             client = MPDClient()
             client.timeout = None
             client.idletimeout = None
             client.connect("localhost", 6600)
         except:
             self.logger.warning("Failed to init MPDClient")
             self.mic.say("Wybacz, ale najwyraźniej usługa Spotify nie działa")
             return
         
         self.logger.info("waiting for Spotify playlist")
         self.mic.say("Poczekaj chwilę, wczytuję listę utworów Spotify")
         music_mode = MusicMode(self.persona, self.mic, self.logger)
         music_mode.handleForever()
         return
     else:
       if " następnie " in lowerUTF8(text):
         l_text = text.split(" następnie ")
         for text in l_text:
           new_got_hit = self.brain.query(text)
           got_hit = got_hit or new_got_hit
       else:
         got_hit = self.brain.query(text)
     return got_hit
开发者ID:HubertReX,项目名称:jasper-client,代码行数:32,代码来源:conversation.py

示例8: play_id

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
 def play_id(play_id):
     client = MPDClient()
     client.connect(app.config['MPD']['host'], app.config['MPD']['port'])
     client.timeout = None
     client.idletimeout = None
     client.playid(play_id)
     return redirect(url_for('player'))
开发者ID:thepartyplatypus,项目名称:Touchscreen-Automation,代码行数:9,代码来源:run.py

示例9: play_playlist

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
def play_playlist(name):
    client=MPDClient()
    mopidyAddress = 'localhost'
    mopidyPort = 6600

    client.timeout = 10
    client.idletimeout = None
    client.connect(mopidyAddress,mopidyPort)
    #client.password('IlPits2013')
    client.clear()
    if playlist_exists(name):
        client.load(name)
    spotify_lists = get_spotify_playlists()
    name = name.encode('utf-8')
    print name
    #print spotify_lists
    if name in spotify_lists:
        add_spotify_directory(name)
    #time.sleep(1)
    if name == 'Pierre':
        client.shuffle()

    #client.setvol(50)
    #client.play()
    client.disconnect()
    return
开发者ID:NilsNoreyson,项目名称:phoneBookServer,代码行数:28,代码来源:get_phonebook_files.py

示例10: excuteCommand

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
    def excuteCommand(con, channel, user, message, isMod, isSub):
	    client = MPDClient()
	    client.timeout = 10
	    client.idletimeout = None
	    client.connect("bluesnogbox.duckdns.org", 6600)
	    send_message(con, channel, 'mpd version: ' + client.mpd_version)
	    client.close()
	    client.disconnect()
开发者ID:janusnic,项目名称:Twitch-Chat-Bot,代码行数:10,代码来源:Commands.py

示例11: play

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
def play():
    client = MPDClient()
    client.timeout = 10
    client.idletimeout = None
    client.connect(mpdurl, 6600)
    client.play()
    client.close()
    client.disconnect()
    return jsonify(status='success', action='play')
开发者ID:shackspace,项目名称:kiosk,代码行数:11,代码来源:routes.py

示例12: mpdInit

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
def mpdInit():
    global client
    client = MPDClient()                        
    client.timeout = 10                          
    client.idletimeout = None                   
    client.connect("localhost", 6600)   
    client.password("1234")
    client.setvol(20)
    return client
开发者ID:DipoChiang,项目名称:Personal-Assistant,代码行数:11,代码来源:spotifyPi.py

示例13: item_chosen

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
def item_chosen(button, choice):

    client = MPDClient()               # create client object
    client.timeout = 10                # network timeout in seconds (floats allowed), default: None
    client.idletimeout = None          # timeout for fetching the result of the idle command is handled seperately, default: None
    host = os.environ.get('MPD_HOST','localhost')
    client.connect(host, 6600)  # connect to localhost:6600

    client.add(choice)
开发者ID:kstock,项目名称:mu,代码行数:11,代码来源:bran.py

示例14: pause

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
def pause():
    client = MPDClient()
    client.timeout = 10
    client.idletimeout = None
    client.connect("lounge.mpd.shack", 6600)
    client.pause()
    client.close()
    client.disconnect()
    return jsonify(status='success', action='pause')
开发者ID:shackspace,项目名称:gobbelz,代码行数:11,代码来源:routes.py

示例15: startClient

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import idletimeout [as 别名]
def startClient():
    client = MPDClient()               # create client object
    # network timeout in seconds (floats allowed), default: None
    client.timeout = 10
    # timeout for fetching the result of the idle command is handled
    # seperately, default: None
    client.idletimeout = None
    client.connect("localhost", 6600)  # connect to localhost:6600
    return client
开发者ID:rbn42,项目名称:mpd-script,代码行数:11,代码来源:util.py


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