Exemplo n.º 1
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
Exemplo n.º 2
0
    def connect(self, host=None, port=None):
        if host is not None:
            mpd_host = host
        elif "MPD_HOST" in os.environ:
            mpd_host = os.environ["MPD_HOST"]
        elif config_data.has_option("mpd", "host"):
            mpd_host = config_data.get("mpd", "host")
        else:
            mpd_host = "localhost"

        if port is not None:
            mpd_port = port
        elif "MPD_PORT" in os.environ:
            mpd_port = int(os.environ["MPD_PORT"])
        elif config_data.has_option("mpd", "port"):
            mpd_port = config_data.getint("mpd", "port")
        else:
            mpd_port = 6600

        self.mpc.connect(mpd_host, mpd_port)