Skip to content

Commit

Permalink
Adding version to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
otobrglez committed Jan 4, 2016
1 parent f73da36 commit 07c968e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
27 changes: 14 additions & 13 deletions databox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from os import getenv
from json import dumps as json_dumps

__version__ = "0.1.5"


class Client(object):
push_token = None
Expand Down Expand Up @@ -51,37 +53,36 @@ def _push_json(self, data=None, path="/"):
data = json_dumps(data)

response = requests.post(
self.push_host + path,
auth=HTTPBasicAuth(self.push_token, ''),
headers={'Content-Type': 'application/json'},
data=data
self.push_host + path,
auth=HTTPBasicAuth(self.push_token, ''),
headers={
'Content-Type': 'application/json',
'User-Agent': "Databox/" + __version__ + " (Python)"
},
data=data
)

return response.json()


def push(self, key, value, date=None, attributes=None):
self.last_push_content = self._push_json({
'data': [self.process_kpi(
key=key,
value=value,
date=date,
attributes=attributes
key=key,
value=value,
date=date,
attributes=attributes
)]
})

return self.last_push_content['status'] == 'ok'



def insert_all(self, rows):
self.last_push_content = self._push_json({
'data': [self.process_kpi(**row) for row in rows]
})

return self.last_push_content['status'] == 'ok'


def last_push(self, number=1):
return self._push_json(path='/lastpushes/{n}'.format(**{'n': number}))

Expand All @@ -95,4 +96,4 @@ def insert_all(rows=[], token=None):


def last_push(token=None):
return Client(token).last_push()
return Client(token).last_push()
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
from databox import __version__ as version

setup(
name="databox",
version="0.1.4",
version=version,
author="Databox",
author_email="[email protected]",
description="Push metrics to Databox.",
description="Python wrapper for Databox - Mobile Executive Dashboard.",
url="https://github.com/databox/databox-python",
license='MIT',
packages=find_packages(exclude=('databox test',)),
Expand Down

0 comments on commit 07c968e

Please sign in to comment.