示例#1
0
 def __init__(self, name, daemonize=False, hub=hub._defaulthub):
     threading.Thread.__init__(self)
     # as independent thread, we want our own event and request channel
     # and need at least respond to a quit event
     self.name = name
     self.setName("%s service" % name)
     self.channel = hub.newchannel()
     self.channel.subscribe(events.quit, self.quit)
     self.done = False
     self.setDaemon(daemonize)
     log.debug("started %s service" % self.name)
示例#2
0
    def handle(self):
        log.debug("starting handler")
	self.channel = hub.newchannel()
	self.done = False
	self.servernetworkreceiver = servernetworkreceiver(self.request, self)
	self.servernetworkreceiver.start()

        # Process events coming from the rest of the PyTone server.
        # This sends (via eventhandler) subscribed events to the client
	while not self.done:
	    self.channel.process(block=True)
	log.debug("terminating handler")
	self.channel.hub.disconnect(self.channel)
示例#3
0
    def __init__(self, screen, songdbids, playerids, plugins):
        self.screen = screen
        self.layout = config.general.layout
        self.h, self.w = self.getmaxyx()
        log.debug("h=%d, w=%d" % (self.h, self.w))
        self.channel = hub.newchannel()
        self.keybindings = config.keybindings.general
        self.done = False

        self.statusbar = statusbar.statusbar(screen, self.h-1, self.w, self.channel)

        # first we setup the input window in order to have it as first window
        # in the keypressed events lists.
        if config.inputwindow.type=="popup":
            self.inputwin = inputwin.popupinputwin(screen, self.h, self.w, self.channel)
        else:
            self.inputwin = inputwin.statusbarinputwin(screen, self.h, self.w, self.channel)

        # setup the four main windows
        windowslayout = self.calclayout()
        self.playerwin = playerwin.playerwin(screen, windowslayout["playerwin"], self.channel, playerids[0])
        self.iteminfowin = iteminfowin.iteminfowin(screen, windowslayout["iteminfowin"], self.channel, playerids, playerids[1])
        self.filelistwin = filelistwin.filelistwin(screen, windowslayout["filelistwin"], self.channel, songdbids)
        self.playlistwin = playlistwin.playlistwin(screen, windowslayout["playlistwin"], self.channel, "main")
        self.connectborders()

        # setup additional windows which appear on demand
        self.helpwin = helpwin.helpwin(screen, self.h, self.w, self.channel)

        self.logwin = logwin.logwin(screen, self.h, self.w, self.channel)
        self.statswin = statswin.statswin(screen, self.h, self.w, self.channel, len(songdbids))

        self.iteminfowinlong = iteminfowin.iteminfowinlong(screen, self.h, self.w, self.channel)
        self.lyricswin = lyricswin.lyricswin(screen, self.h, self.w, self.channel)

        self.mixerwin = None
        if config.mixer.device:
            try:
                if config.mixerwindow.type=="popup":
                    self.mixerwin = mixerwin.popupmixerwin(screen, self.h, self.w, self.channel)
                else:
                    self.mixerwin = mixerwin.statusbarmixerwin(screen, self.h, self.w, self.channel)

            except IOError, e:
                log.warning('error "%s" during mixer init - disabling mixer' % e)
示例#4
0
    def __init__(self, screen, songdbids, playerids, plugins):
        self.screen = screen
        self.layout = config.general.layout
        self.h, self.w = self.getmaxyx()
        log.debug("h=%d, w=%d" % (self.h, self.w))
        self.channel = hub.newchannel()
        self.keybindings = config.keybindings.general
        self.done = False

        self.statusbar = statusbar.statusbar(screen, self.h-1, self.w, self.channel)

        # first we setup the input window in order to have it as first window
        # in the keypressed events lists.
        if config.inputwindow.type=="popup":
            self.inputwin = inputwin.popupinputwin(screen, self.h, self.w, self.channel)
        else:
            self.inputwin = inputwin.statusbarinputwin(screen, self.h, self.w, self.channel)

        # setup the four main windows
        windowslayout = self.calclayout()
        self.playerwin = playerwin.playerwin(screen, windowslayout["playerwin"], self.channel, playerids[0])
        self.iteminfowin = iteminfowin.iteminfowin(screen, windowslayout["iteminfowin"], self.channel, playerids, playerids[1])
        self.filelistwin = filelistwin.filelistwin(screen, windowslayout["filelistwin"], self.channel, songdbids)
        self.playlistwin = playlistwin.playlistwin(screen, windowslayout["playlistwin"], self.channel, "main")
        self.connectborders()

        # setup additional windows which appear on demand
        self.helpwin = helpwin.helpwin(screen, self.h, self.w, self.channel)

        self.logwin = logwin.logwin(screen, self.h, self.w, self.channel)
        self.statswin = statswin.statswin(screen, self.h, self.w, self.channel, len(songdbids))

        self.iteminfowinlong = iteminfowin.iteminfowinlong(screen, self.h, self.w, self.channel)
        self.lyricswin = lyricswin.lyricswin(screen, self.h, self.w, self.channel)

        self.mixerwin = None
        if config.mixer.device:
            try:
                if config.mixerwindow.type=="popup":
                    self.mixerwin = mixerwin.popupmixerwin(screen, self.h, self.w, self.channel)
                else:
                    self.mixerwin = mixerwin.statusbarmixerwin(screen, self.h, self.w, self.channel)

            except IOError as e:
                log.warning('error "%s" during mixer init - disabling mixer' % e)
        else:
            # disbable keybindings to obtain correct help window contents
            del config.keybindings.general.volumeup
            del config.keybindings.general.volumedown

        # now we start the plugins
        for pluginmodule, pluginconfig in plugins:
            plugin_class = pluginmodule.plugin
            if plugin_class:
                plugin = plugin_class(self.channel, pluginconfig, self)
                plugin.start()

        self.channel.subscribe(events.keypressed, self.keypressed)
        self.channel.subscribe(events.activateplaylist, self.activateplaylist)
        self.channel.subscribe(events.activatefilelist, self.activatefilelist)
        self.channel.subscribe(events.quit, self.quit)

        hub.notify(events.activatefilelist())