예제 #1
0
파일: server.py 프로젝트: yaoml/quodlibet
    def __request(self, line, raw=False, want_reply=True):
        """
        Send a request to the server, if connected, and return its response
        """
        line = line.strip()

        if not (self.is_connected or line.split()[0] == 'login'):
            print_d("Can't do '%s' - not connected" % line.split()[0], self)
            return None

        if self._debug:
            print_(">>>> \"%s\"" % line)
        try:
            self.telnet.write((line + "\n").encode('utf-8'))
            if not want_reply:
                return None
            raw_response = self.telnet.read_until(b"\n").decode('utf-8')
        except socket.error as e:
            print_w("Couldn't communicate with squeezebox (%s)" % e)
            self.failures += 1
            if self.failures >= self._MAX_FAILURES:
                print_w("Too many Squeezebox failures. Disconnecting")
                self.is_connected = False
            return None
        response = (raw_response if raw else unquote(raw_response)).strip()
        if self._debug:
            print_("<<<< \"%s\"" % (response, ))
        return (response[len(line) -
                         1:] if line.endswith("?") else response[len(line) +
                                                                 1:])
예제 #2
0
    def __request(self, line, raw=False, want_reply=True):
        """
        Send a request to the server, if connected, and return its response
        """
        line = line.strip()

        if not (self.is_connected or line.split()[0] == 'login'):
            print_d("Can't do '%s' - not connected" % line.split()[0], self)
            return None

        if self._debug:
            print_(">>>> \"%s\"" % line)
        try:
            self.telnet.write((line + "\n").encode('utf-8'))
            if not want_reply:
                return None
            raw_response = self.telnet.read_until(b"\n").decode('utf-8')
        except socket.error as e:
            print_w("Couldn't communicate with squeezebox (%s)" % e)
            self.failures += 1
            if self.failures >= self._MAX_FAILURES:
                print_w("Too many Squeezebox failures. Disconnecting")
                self.is_connected = False
            return None
        response = (raw_response if raw else unquote(raw_response)).strip()
        if self._debug:
            print_("<<<< \"%s\"" % (response,))
        return response[len(line) - 1:] if line.endswith("?")\
            else response[len(line) + 1:]
예제 #3
0
파일: path.py 프로젝트: elfalem/quodlibet
def unescape_filename(s):
    """Unescape a string in a manner suitable for a filename.

    Args:
        filename (fsnative)
    Returns:
        text_type
    """

    assert isinstance(s, fsnative)

    return fsn2text(unquote(s))
예제 #4
0
def unescape_filename(s):
    """Unescape a string in a manner suitable for a filename.

    Args:
        filename (fsnative)
    Returns:
        text_type
    """

    assert isinstance(s, fsnative)

    return fsn2text(unquote(s))
예제 #5
0
파일: server.py 프로젝트: yaoml/quodlibet
 def demunge(string):
     s = unquote(string)
     cpos = s.index(":")
     return s[0:cpos], s[cpos + 1:]
예제 #6
0
 def demunge(string):
     s = unquote(string)
     cpos = s.index(":")
     return s[0:cpos], s[cpos + 1:]