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


Python Scheduler.setLocalQuota方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Scheduler import Scheduler [as 别名]
# 或者: from Scheduler.Scheduler import setLocalQuota [as 别名]
class Ghoul:
    def __init__(self):
        configStream = file('config.yaml', 'r')
        config = yaml.load(configStream)

        self.libraryDB = psycopg2.connect(host = config['music_database']['host'],
                                     user = config['music_database']['user'],
                                     password = config['music_database']['password'],
                                     database = config['music_database']['database'])
        
        try:
            self.messageDB = psycopg2.connect(host = config['msg_database']['host'],
                                     user = config['msg_database']['user'],
                                     password = config['msg_database']['password'],
                                     database = config['msg_database']['database'])
        
            self.messages = MessageLibrary(self.messageDB)
            self.messages.setStingCategories(config['messages']['sting_categories'])
            PlayItem.Message.basePath = config['file_manager']['message_base_path']
        except TypeError:
            self.messages = None
        
        if config['file_manager']['mode'] == "external":
            self.fm = ExternalFileManager(config['file_manager']['user_id'], 
                             config['file_manager']['password'],
                             config['file_manager']['httpUser'],
                             config['file_manager']['httpPass'])

        elif config['file_manager']['mode'] == 'local':
            self.fm = LocalFileManager(config['file_manager']['music_base_path'])


        self.library = MusicLibrary(self.libraryDB)
        self.library.setAustralianNames(config['music']['aus_names'])
        self.library.setMaxSongLength(config['music']['max_song_length'])
        PlayItem.Song.ausNames = config['music']['aus_names']
        
        self.logger = PlaylistLogger(config['logger']['auth'], config['logger']['baseURL'],config['logger']['showID'])
        
        self.playQueue = Queue(5)
       
        self.scheduler = Scheduler(self.library, self.messages, self.fm, self.playQueue)
        self.scheduler.setDemoQuota(config['scheduler']['quotas']['demo'])
        self.scheduler.setLocalQuota(config['scheduler']['quotas']['local'])
        self.scheduler.setAusQuota(config['scheduler']['quotas']['aus'])
        self.scheduler.setFemaleQuota(config['scheduler']['quotas']['female'])
        self.scheduler.setConsecutiveSongs(config['scheduler']['consecutive_songs']['min'],
                                      config['scheduler']['consecutive_songs']['max'])

        self.scheduler.addListener(self)

        self.player = Player.Player()
        self.playThread = Player.PlayThread(self.player, self.playQueue)
        self.playThread.addListener(self)

        self.paused = False

        self.listeners = list()

    def addListener(self, listener):
        self.listeners.append(listener)


    def play(self):
        if self.paused:
            self.paused = False
            self.player.togglePause()
        else:
            self.logger.startNewPlaylist()
            self.scheduler.start()
            self.playThread.start()

    def pause(self):
        self.paused = True
        self.player.togglePause()

    def getElapsedTime(self):
        return self.player.getElapsedTime()

    def getQueuedItems(self):
        items = list()
        for elem in list(self.playQueue.queue):
            items.append(elem)
        return items


    def itemPlaying(self, item):
        if isinstance(item, PlayItem.Song):
            self.logger.submitSong(item)
        for l in self.listeners:
            l.itemPlaying(item)

    def itemQueued(self, item):
        for l in self.listeners:
            l.itemQueued(item)
开发者ID:ThreeDRadio,项目名称:GraveyardGhoul,代码行数:97,代码来源:Ghoul.py


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