Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

added support for python 2.6.6 #443

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0af8be4
Sending via UDP line protocol throws
h0bot Dec 14, 2016
422f144
added support for python 2.6.6
eorochena Apr 26, 2017
4e7e8da
pep8
eorochena May 2, 2017
6c2a3c9
Merge branch 'master' into master
aviau Jun 3, 2017
23e5f44
merge influxdb/client.py
eorochena Aug 17, 2017
c2cd126
updating to master
eorochena Aug 17, 2017
b88caf5
dealing with merge conflicts
eorochena Aug 17, 2017
c6f8261
fixing beyond compare addons
eorochena Aug 17, 2017
086b9dd
addding test and updated travis.yml for legacy python 2.6
eorochena Aug 24, 2017
2c7921b
Merge branch 'master' into master
eorochena Aug 24, 2017
a4774a2
addding test and updated travis.yml for legacy python 2.6
eorochena Aug 24, 2017
03da1ae
checking travis.yml parameters
eorochena Aug 24, 2017
62d62a7
removed python2.6 from travis.yml for testing purposes
eorochena Aug 24, 2017
4ede30f
removed python2.6 from travis.yml for testing purposes
eorochena Aug 24, 2017
9d2e317
reverted travis.yml and tox.ini
eorochena Aug 24, 2017
9a8b8f8
Merge branch 'master' into master
sebito91 Sep 8, 2017
817f4d9
implemented requested changes
eorochena Sep 16, 2017
62464a8
Merge remote-tracking branch 'origin/master'
eorochena Sep 16, 2017
0fc916b
Merge branch 'master' into master
eorochena Sep 16, 2017
5e386bb
Replaced py26_test.py with new version as suggested
eorochena Sep 21, 2017
0d9026b
Merge remote-tracking branch 'origin/master'
eorochena Sep 21, 2017
c1513a3
Replaced py26_test.py with new version as suggested and fix flake8
eorochena Sep 21, 2017
fc7bc5f
Merge branch 'master' into master
eorochena Oct 26, 2017
7b8b188
Merge branch 'master' into master
xginn8 Nov 15, 2017
9846e27
Merge branch 'master' into master
eorochena Nov 23, 2017
bfdcf39
Merge branch 'master' into master
xginn8 Nov 25, 2017
03cf581
Merge branch 'master' into master
eorochena Dec 31, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ cache: false
# directories:
# - $HOME/.cache/pip
#before_cache:
# - rm -f $HOME/.cache/pip/log/debug.log
# - rm -f $HOME/.cache/pip/log/debug.log
13 changes: 7 additions & 6 deletions influxdb/line_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from __future__ import print_function
from __future__ import unicode_literals

from datetime import datetime
import datetime
from numbers import Integral

from pytz import UTC
from dateutil.parser import parse
from six import iteritems, binary_type, text_type, integer_types, PY2

EPOCH = UTC.localize(datetime.utcfromtimestamp(0))
EPOCH = UTC.localize(datetime.datetime.utcfromtimestamp(0))


def _convert_timestamp(timestamp, precision=None):
Expand All @@ -22,12 +22,14 @@ def _convert_timestamp(timestamp, precision=None):

if isinstance(_get_unicode(timestamp), text_type):
timestamp = parse(timestamp)

if isinstance(timestamp, datetime):
if isinstance(timestamp, datetime.datetime):
if not timestamp.tzinfo:
timestamp = UTC.localize(timestamp)
ns_no_total = (timestamp - EPOCH)
ns = ((ns_no_total.microseconds + (
ns_no_total.seconds + ns_no_total.days * 24 * 3600) *
10 ** 6) / 10 ** 6) * 1e9

ns = (timestamp - EPOCH).total_seconds() * 1e9
if precision is None or precision == 'n':
return ns
elif precision == 'u':
Expand All @@ -40,7 +42,6 @@ def _convert_timestamp(timestamp, precision=None):
return ns / 1e9 / 60
elif precision == 'h':
return ns / 1e9 / 3600

raise ValueError(timestamp)


Expand Down
91 changes: 91 additions & 0 deletions influxdb/tests/server_tests/py26_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# -*- coding: utf-8 -*-
"""Define the resultset test package."""

from __future__ import unicode_literals

import datetime
import os
import socket
import subprocess
import time
import unittest

from influxdb.tests.server_tests.base import SingleTestCaseWithServerMixin

THIS_DIR = os.path.abspath(os.path.dirname(__file__))

# hack in check_output if it's not defined, like for python 2.6
if "check_output" not in dir(subprocess):
def f(*popenargs, **kwargs):
"""Check for output."""
if 'stdout' in kwargs:
raise ValueError(
'stdout argument not allowed, it will be overridden.'
)
process = subprocess.Popen(stdout=subprocess.PIPE,
*popenargs,
**kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
raise subprocess.CalledProcessError(retcode, cmd)
return output
subprocess.check_output = f


class TestPython26Set(SingleTestCaseWithServerMixin, unittest.TestCase):
"""Define the Python26Set test object."""

influxdb_template_conf = os.path.join(THIS_DIR, 'influxdb.conf.template')

def test_write_points(self):
"""Test write points for Python26Set object."""
self.host_name = socket.gethostname()
self.assertTrue(self.cli.create_database('db') is None)

# System Load
self.lf = ["cat", "/proc/loadavg"]

c = 0

while c < 5:
d = subprocess.check_output(self.lf).strip().split()

load_1 = [
{
"measurement": "Load_1_minute",
"tags": {"hosts": self.host_name},
"time": datetime.datetime.now(),
"fields": {"load_avg_1": float(d[0])}
}
]
self.cli.write_points(load_1)

load_5 = [
{
"measurement": "Load_5_minutes",
"tags": {"hosts": self.host_name},
"time": datetime.datetime.now(),
"fields": {"load_avg_5": float(d[1])}
}
]
self.cli.write_points(load_5)

load_15 = [
{
"measurement": "Load_15_minute",
"tags": {"hosts": self.host_name},
"time": datetime.datetime.now(),
"fields": {"load_avg_15": float(d[2])}
}
]
self.cli.write_points(load_15)

c += 1
time.sleep(1)

result = self.cli.query("select load_avg_1 from Load_1_minute;")
self.assertTrue(result is not None)