Example #1
0
 def authenticate(self, funcname):
     """authenticate with the server if not allowed to execute funcname."""
     if funcname in self.mpd_notcommands:
         authfunc = self.__super.__getattr__("password")
         if config_data.has_option("mpd", "password"):
             authfunc(config_data.get("mpd", "password"))
         else:
             import getpass
             printByName("askpass", command=funcname)
             authfunc(getpass.getpass(_("Password: "******"notcommands")()
Example #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)