Plotly& Python - HTTP 504网关超时

时间:2015-12-15 02:19:12

标签: python plotly

您好我正在尝试在maply中实时绘制python。它正常工作,直到此错误不断发生:引发HTTPError(http_error_msg,response = self) requests.exceptions.HTTPError:504服务器错误:网址为GATEWAY_TIMEOUT:https://plot.ly/clientresp。现在没有任何作用。

import socket
import sys
import ast, matplotlib.pyplot as plt
# (*) To communicate with Plotly's server, sign in with credentials file
import plotly.plotly as py # plotly library
import plotly.tools as tls
from plotly.graph_objs import * # plotly graph objects
import time


# stream_ids = tls.get_credentials_file()['stream_ids']
username = '**'
api_key = '**'
stream_token = '**'


# plt.use('GTKAgg')
py.sign_in(username, api_key)

trace1 = Scatter(
    x=[],
    y=[],
    stream=dict(
        token=stream_token,
        maxpoints=200
    )
)

layout = Layout(
    title='Raspberry Pi Streaming Sensor Data'
)

fig = Figure(data=[trace1], layout=layout)
print "I am here!"
print py.plot(fig, filename='Raspberry Pi Streaming Example Values')
print "I am here!"
stream = py.Stream(stream_token)
stream.open()
# Create a UDP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# Bind the socket to the port
server_address = ('192.168.0.108', 4000)
# print >>sys.stderr, 'starting up on %s port %s' % server_address
sock.bind(server_address)
# print >>sys.stderr, 'socket has binded on %s on port %s' % server_address

i = 0
# plt.xlim([])
# receiving data as long as it is coming
print >>sys.stderr, '\nsending'
while True:
    data, address = sock.recvfrom(4096)
    value = ast.literal_eval(data)
    if not (value == 'punch detected'):
        print "to stream"
        # stream.write({'x': i, 'y': float(value)})
    else:
        print >> sys.stderr, "not punching"
    # line.set_xdata(np.arange(len(yval)))
    # plt.scatter(value)

    i += 1
    time.sleep(0.1)
    #print >>sys.stderr, 'received %s bytes from %s' % (len(data), address)
    print >>sys.stderr, value
    if not(data):
        sock.close()
        print>>sys.stderr, "socket was closed"

请帮忙!

0 个答案:

没有答案