Skip to content

Commit bff7ca9

Browse files
authored
Merge branch 'master' into dataframeclient_chunked_queries
2 parents 1a7c56c + 87683f4 commit bff7ca9

39 files changed

+834
-546
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ matrix:
1212
include:
1313
- python: 2.7
1414
env: TOX_ENV=py27
15+
- python: 2.7
16+
env: TOX_ENV=pep257
1517
- python: pypy-5.3.1
1618
env: TOX_ENV=pypy
1719
- python: 3.4

docs/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
22
#
3+
"""InfluxDB documentation build configuration file."""
4+
35
# InfluxDB documentation build configuration file, created by
46
# sphinx-quickstart on Thu Oct 16 00:33:06 2014.
57
#

examples/tutorial.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
"""Tutorial on using the InfluxDB client."""
3+
14
import argparse
25

36
from influxdb import InfluxDBClient
47

58

69
def main(host='localhost', port=8086):
10+
"""Instantiate a connection to the InfluxDB."""
711
user = 'root'
812
password = 'root'
913
dbname = 'example'
@@ -54,9 +58,11 @@ def main(host='localhost', port=8086):
5458

5559

5660
def parse_args():
61+
"""Parse the args."""
5762
parser = argparse.ArgumentParser(
5863
description='example code to play with InfluxDB')
59-
parser.add_argument('--host', type=str, required=False, default='localhost',
64+
parser.add_argument('--host', type=str, required=False,
65+
default='localhost',
6066
help='hostname of InfluxDB http API')
6167
parser.add_argument('--port', type=int, required=False, default=8086,
6268
help='port of InfluxDB http API')

examples/tutorial_pandas.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
"""Tutorial for using pandas and the InfluxDB client."""
3+
14
import argparse
25
import pandas as pd
36

47
from influxdb import DataFrameClient
58

69

710
def main(host='localhost', port=8086):
11+
"""Instantiate the connection to the InfluxDB client."""
812
user = 'root'
913
password = 'root'
1014
dbname = 'demo'
11-
# Temporarily used to avoid line protocol time conversion issues #412, #426, #431.
15+
# Temporarily avoid line protocol time conversion issues #412, #426, #431.
1216
protocol = 'json'
1317

1418
client = DataFrameClient(host, port, user, password, dbname)
@@ -25,7 +29,8 @@ def main(host='localhost', port=8086):
2529
client.write_points(df, 'demo', protocol=protocol)
2630

2731
print("Write DataFrame with Tags")
28-
client.write_points(df, 'demo', {'k1': 'v1', 'k2': 'v2'}, protocol=protocol)
32+
client.write_points(df, 'demo',
33+
{'k1': 'v1', 'k2': 'v2'}, protocol=protocol)
2934

3035
print("Read DataFrame")
3136
client.query("select * from demo")
@@ -35,6 +40,7 @@ def main(host='localhost', port=8086):
3540

3641

3742
def parse_args():
43+
"""Parse the args from main."""
3844
parser = argparse.ArgumentParser(
3945
description='example code to play with InfluxDB')
4046
parser.add_argument('--host', type=str, required=False,

examples/tutorial_serieshelper.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
"""
2-
Tutorial/Example how to use the class helper `SeriesHelper`
3-
"""
1+
# -*- coding: utf-8 -*-
2+
"""Tutorial how to use the class helper `SeriesHelper`."""
43

54
from influxdb import InfluxDBClient
65
from influxdb import SeriesHelper
@@ -20,18 +19,28 @@
2019

2120

2221
class MySeriesHelper(SeriesHelper):
23-
# Meta class stores time series helper configuration.
22+
"""Instantiate SeriesHelper to write points to the backend."""
23+
2424
class Meta:
25+
"""Meta class stores time series helper configuration."""
26+
2527
# The client should be an instance of InfluxDBClient.
2628
client = myclient
27-
# The series name must be a string. Add dependent fields/tags in curly brackets.
29+
30+
# The series name must be a string. Add dependent fields/tags
31+
# in curly brackets.
2832
series_name = 'events.stats.{server_name}'
33+
2934
# Defines all the fields in this time series.
3035
fields = ['some_stat', 'other_stat']
36+
3137
# Defines all the tags for the series.
3238
tags = ['server_name']
33-
# Defines the number of data points to store prior to writing on the wire.
39+
40+
# Defines the number of data points to store prior to writing
41+
# on the wire.
3442
bulk_size = 5
43+
3544
# autocommit must be set to True when using bulk_size
3645
autocommit = True
3746

examples/tutorial_server_data.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
"""Tutorial on using the server functions."""
13

24
from __future__ import print_function
35
import argparse
46

5-
from influxdb import InfluxDBClient
6-
from influxdb.client import InfluxDBClientError
77
import datetime
88
import random
99
import time
1010

11+
from influxdb import InfluxDBClient
12+
from influxdb.client import InfluxDBClientError
1113

1214
USER = 'root'
1315
PASSWORD = 'root'
1416
DBNAME = 'tutorial'
1517

1618

1719
def main(host='localhost', port=8086, nb_day=15):
18-
20+
"""Instantiate a connection to the backend."""
1921
nb_day = 15 # number of day to generate time series
2022
timeinterval_min = 5 # create an event every x minutes
2123
total_minutes = 1440 * nb_day
@@ -30,15 +32,15 @@ def main(host='localhost', port=8086, nb_day=15):
3032
hostName = "server-%d" % random.randint(1, 5)
3133
# pointValues = [int(past_date.strftime('%s')), value, hostName]
3234
pointValues = {
33-
"time": int(past_date.strftime('%s')),
34-
"measurement": metric,
35-
'fields': {
36-
'value': value,
37-
},
38-
'tags': {
39-
"hostName": hostName,
40-
},
41-
}
35+
"time": int(past_date.strftime('%s')),
36+
"measurement": metric,
37+
"fields": {
38+
"value": value,
39+
},
40+
"tags": {
41+
"hostName": hostName,
42+
},
43+
}
4244
series.append(pointValues)
4345

4446
print(series)
@@ -62,7 +64,8 @@ def main(host='localhost', port=8086, nb_day=15):
6264

6365
time.sleep(2)
6466

65-
query = "SELECT MEAN(value) FROM {} WHERE time > now() - 10d GROUP BY time(500m)".format(metric)
67+
query = "SELECT MEAN(value) FROM {} WHERE \
68+
time > now() - 10d GROUP BY time(500m)".format(metric)
6669
result = client.query(query, database=DBNAME)
6770
print(result)
6871
print("Result: {0}".format(result))
@@ -72,9 +75,11 @@ def main(host='localhost', port=8086, nb_day=15):
7275

7376

7477
def parse_args():
78+
"""Parse the args."""
7579
parser = argparse.ArgumentParser(
7680
description='example code to play with InfluxDB')
77-
parser.add_argument('--host', type=str, required=False, default='localhost',
81+
parser.add_argument('--host', type=str, required=False,
82+
default='localhost',
7883
help='hostname influxdb http API')
7984
parser.add_argument('--port', type=int, required=False, default=8086,
8085
help='port influxdb http API')

examples/tutorial_sine_wave.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
"""Tutorial using all elements to define a sine wave."""
3+
14
import argparse
25

3-
from influxdb import InfluxDBClient
46
import math
57
import datetime
68
import time
79

10+
from influxdb import InfluxDBClient
811

912
USER = 'root'
1013
PASSWORD = 'root'
1114
DBNAME = 'tutorial'
1215

1316

1417
def main(host='localhost', port=8086):
15-
"""
16-
main function to generate the sin wave
17-
"""
18+
"""Define function to generate the sin wave."""
1819
now = datetime.datetime.today()
1920
points = []
2021

@@ -36,7 +37,7 @@ def main(host='localhost', port=8086):
3637
client.create_database(DBNAME)
3738
client.switch_database(DBNAME)
3839

39-
#Write points
40+
# Write points
4041
client.write_points(points)
4142

4243
time.sleep(3)
@@ -47,9 +48,9 @@ def main(host='localhost', port=8086):
4748
print("Result: {0}".format(result))
4849

4950
"""
50-
You might want to comment the delete and plot the result on InfluxDB Interface
51-
Connect on InfluxDB Interface at http://127.0.0.1:8083/
52-
Select the database tutorial -> Explore Data
51+
You might want to comment the delete and plot the result on InfluxDB
52+
Interface. Connect on InfluxDB Interface at http://127.0.0.1:8083/
53+
Select the database tutorial -> Explore Data
5354
5455
Then run the following query:
5556
@@ -61,9 +62,11 @@ def main(host='localhost', port=8086):
6162

6263

6364
def parse_args():
65+
"""Parse the args."""
6466
parser = argparse.ArgumentParser(
6567
description='example code to play with InfluxDB')
66-
parser.add_argument('--host', type=str, required=False, default='localhost',
68+
parser.add_argument('--host', type=str, required=False,
69+
default='localhost',
6770
help='hostname influxdb http API')
6871
parser.add_argument('--port', type=int, required=False, default=8086,
6972
help='port influxdb http API')

influxdb/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
"""Initialize the influxdb package."""
23

34
from __future__ import absolute_import
45
from __future__ import division

0 commit comments

Comments
 (0)