Exemplo n.º 1
0
class ByteportPandas:
    """
    Provides base functionality for connecting and loading data into Pandas data formats

    Extend at will!
    """

    def __init__(self, username, password):
        self.client = ByteportHttpClient()
        self.client.login(username, password)
        print "Successfully logged in to Byteport!"

    def load_to_series(self, namespace, device_uid, field_name, from_time, to_time):
        timeseries_data = self.client.load_timeseries_data_range(namespace, device_uid, field_name, from_time, to_time)

        # create pandas data-frame
        timestamps = list()
        values = list()

        # Prepare by splitting the time series data into two arrays
        for row in timeseries_data['data']['ts_data']:
            try:
                dt = datetime.datetime.strptime(row['t'], ISO8601)
                fv = float(row['v'])

                timestamps.append(dt)
                values.append(fv)
            except Exception:
                print "Failed to parse data (%s), ignoring" % row

        return pandas.Series(values, timestamps)
Exemplo n.º 2
0
 def __init__(self, username, password):
     self.client = ByteportHttpClient()
     self.client.login(username, password)
     print "Successfully logged in to Byteport!"
Exemplo n.º 3
0
from byteport.http_clients import ByteportHttpClient

#
# NOTE: Needs a proxy set up on port 5000, first to this from shell:
#
# (venv-byteport-api) hans@Hanss-MacBook-Pro:~/Development/igw/git_clones/byteport-api$ ssh -i ./id_rsa -D 5000 -N [email protected] &
#

byteport_client = ByteportHttpClient('mloc', 'f5770ca3ac1ff64de7f0bc70', 'locator8',  proxy_port=5000)

byteport_client.store({'eth0_rx_mb': '10'})