Ejemplo n.º 1
0
    def __init__(self, conn=None, output=None, after_status=None):
        """Initialize class.
        conn is an mpd.MPDClient() instance, if None a new one will be created.
        if output is False, no output is printed (used by mpd console)
        if after_status is True, commands like clear, next, previous will call
        status() after execution to print status."""
        if conn:
            self.mpc = conn
        else:
            self.mpc = SmartMPDClient()

        if after_status is not None:
            self.after_status = after_status
        elif config_data.has_option("ui", "after_status"):
            self.after_status = config_data.getboolean("ui", "after_status")
        else:
            self.after_status = True

        if output is not None:
            self.output = output
        elif config_data.has_option("console", "output"):
            self.output = config_data.getboolean("console", "output")
        else:
            self.output = True

        # Commands with common argument & return values
        self._common_commands = {
                "commands" : "commands",
                "notcommands" : "notcommands",
                "outputs" : "outputs",
                "stats" : "stats",
                "tagtypes" : "tagtypes",
                "urlhandlers" : "urlhandlers",
                "list" : "results",
                "listall" : "results",
                "listallinfo" : "results",
                "listplaylist" : "results",
                "listplaylistinfo" : "results",
                "lsinfo" : "results",
                "currentsong" : "song",
                "plchangesposid" : "results",
                }
        # Commands that return none
        # Template is rendered before real function is called.
        self._none_commands = ["deleteid", "kill", "load", "rename", "move",
                "moveid", "rm", "save", "swap", "swapid", "playlistadd",
                "playlistclear", "playlistdelete", "playlistmove",]
        # Search commands
        self._search_commands = ["count", "find", "search", "playlistfind",
                "playlistsearch",]
        # Commands that print status after execution.
        self._status_commands = ["clear", "shuffle", "next", "play", "playid",
                "previous", "stop",]
Ejemplo n.º 2
0
    def __init__(self):
        """Initialize defaults."""
        if config_data.has_option("console", "ping"):
            self.__ping = config_data.getboolean("console", "ping")
        else:
            self.__ping = True

        if config_data.has_option("console", "ping_interval"):
            self.__ping_interval = config_data.getint("console", "ping_interval")
        else:
            self.__ping_interval = 50

        if config_data.has_option("console", "return"):
            self.__ret = config_data.getboolean("console", "return")
        else:
            self.__ret = False