Exemple #1
0
    def __init__(self, mpv_path, streamer_fifo_path, mpv_cmds_fifo_path, server_ip, mpd_port, http_port):

        self.streamer_fifo_path = streamer_fifo_path
        self.mpv_cmds_fifo_path = mpv_cmds_fifo_path

        # the command that Popen will call in a new process (the media player, 
        # controlled by writing commands to mpv_cmds_fifo_path, a handy feature
        # of mpv) 
        self.playercmd = [mpv_path, "--input-file=" + mpv_cmds_fifo_path, streamer_fifo_path]

        # create mpd client, connect it to the server
        self.remote = mpd_client.mpd_client(server_ip, mpd_port, REMOTE_DEBUGLEVEL)
        self.remote.connect_to_server()
        # get the status of the server 
        self.remote.retrieve_status()

        # create player
        self.player = player.player(self.playercmd, mpv_cmds_fifo_path, PLAYER_DEBUGLEVEL)

        # create http client
        self.streamer = http_client.http_client(server_ip, http_port, streamer_fifo_path, STREAMER_BUFFER_SIZE, STREAMER_DEBUGLEVEL)

        # if the mpd server is playing, initialize the http client's connetion 
        state = self.remote.status.state
        if state == "play":
            self.player.play()
            self.streamer.play()
            # check if the streamer successfully connected
            if not self.streamer.connected:
                self.print_debug("Error: could not connect to HTTP server!", 1) 
                self.quit()

        self.message = None
    def test_it_works(self):

        result = http_client(
            'http://api.openweathermap.org/data/2.5/forecast/daily?q=Nairobi&APPID=9e68c31e59d752247d58d439c50aaaff'
        )

        self.assertEqual(result, 'KE', "Not working")
def test_http_client_success():
    success_str = \
        "HTTP/1.1 200 OK\r\n" + \
        "Content-Type: text/plain\r\n" + \
        "\r\n" + \
        "/some/uri\r\n"
    assert http_client("/some/uri") == success_str
    def test_bad_url(self):

        r = http_client(
            'http://api.odsrmap.org/data/2.5/forecast/daily?q=Nairobi&APPID=9e68c31e59d752247d58d439c50aaaff'
        )

        self.assertDictEqual(
            r, {'Error': '<urlopen error [Errno 11001] getaddrinfo failed>'},
            "Not working")
Exemple #5
0
def _httpclient():
    c = http_client(api_url=api_url)
    return c
Exemple #6
0
def _httpclient():
    c = http_client(api_url=api_url)
    return c
def test_shutdown_server():
    http_client("secretstopmessage")