Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ install:
- pip install --upgrade tox

script:
- tox -e py26
- tox -e py27
- tox -e py34
- tox -e lint
Expand Down
10 changes: 4 additions & 6 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ In order to add a feature to ``gcloud-python``:
- The feature must be documented in both the API and narrative
documentation (in ``docs/``).

- The feature must work fully on the following CPython versions: 2.6,
and 2.7 on both UNIX and Windows.
- The feature must work fully on the following CPython versions: 2.7,
3.4, and 3.5 on both UNIX and Windows.

- The feature must not add unnecessary dependencies (where
"unnecessary" is of course subjective, but new dependencies should
Expand Down Expand Up @@ -357,12 +357,10 @@ Supported Python Versions

We support:

- `Python 2.6`_
- `Python 2.7`_
- `Python 3.4`_
- `Python 3.5`_

.. _Python 2.6: https://docs.python.org/2.6/
.. _Python 2.7: https://docs.python.org/2.7/
.. _Python 3.4: https://docs.python.org/3.4/
.. _Python 3.5: https://docs.python.org/3.5/
Expand All @@ -378,7 +376,7 @@ and lack of continuous integration `support`_.
.. _decreased usage: https://caremad.io/2013/10/a-look-at-pypi-downloads/
.. _support: http://blog.travis-ci.com/2013-11-18-upcoming-build-environment-updates/

We may `drop 2.6`_ as a supported version as well since Python 2.6 is no
We have `dropped 2.6`_ as a supported version as well since Python 2.6 is no
longer supported by the core development team.

We also explicitly decided to support Python 3 beginning with version
Expand All @@ -392,7 +390,7 @@ We also explicitly decided to support Python 3 beginning with version
.. _prominent: https://docs.djangoproject.com/en/1.9/faq/install/#what-python-version-can-i-use-with-django
.. _projects: http://flask.pocoo.org/docs/0.10/python3/
.. _Unicode literal support: https://www.python.org/dev/peps/pep-0414/
.. _drop 2.6: https://github.com/GoogleCloudPlatform/gcloud-python/issues/995
.. _dropped 2.6: https://github.com/GoogleCloudPlatform/gcloud-python/issues/995

Versioning
----------
Expand Down
31 changes: 0 additions & 31 deletions gcloud/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import os
import re
import socket
import sys
from threading import local as Local

from google.protobuf import timestamp_pb2
Expand Down Expand Up @@ -336,36 +335,6 @@ def _millis_from_datetime(value):
return _millis(value)


def _total_seconds_backport(offset):
"""Backport of timedelta.total_seconds() from python 2.7+.

:type offset: :class:`datetime.timedelta`
:param offset: A timedelta object.

:rtype: int
:returns: The total seconds (including microseconds) in the
duration.
"""
seconds = offset.days * 24 * 60 * 60 + offset.seconds
return seconds + offset.microseconds * 1e-6


def _total_seconds(offset):
"""Version independent total seconds for a time delta.

:type offset: :class:`datetime.timedelta`
:param offset: A timedelta object.

:rtype: int
:returns: The total seconds (including microseconds) in the
duration.
"""
if sys.version_info[:2] < (2, 7): # pragma: NO COVER Python 2.6
return _total_seconds_backport(offset)
else:
return offset.total_seconds()


def _rfc3339_to_datetime(dt_str):
"""Convert a microsecond-precision timetamp to a native datetime.

Expand Down
3 changes: 1 addition & 2 deletions gcloud/bigtable/column_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from google.protobuf import duration_pb2

from gcloud._helpers import _total_seconds
from gcloud.bigtable._generated import (
table_pb2 as table_v2_pb2)
from gcloud.bigtable._generated import (
Expand All @@ -40,7 +39,7 @@ def _timedelta_to_duration_pb(timedelta_val):
:rtype: :class:`google.protobuf.duration_pb2.Duration`
:returns: A duration object equivalent to the time delta.
"""
seconds_decimal = _total_seconds(timedelta_val)
seconds_decimal = timedelta_val.total_seconds()
# Truncate the parts other than the integer.
seconds = int(seconds_decimal)
if seconds_decimal < 0:
Expand Down
3 changes: 1 addition & 2 deletions gcloud/bigtable/happybase/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from gcloud._helpers import _datetime_from_microseconds
from gcloud._helpers import _microseconds_from_datetime
from gcloud._helpers import _to_bytes
from gcloud._helpers import _total_seconds
from gcloud.bigtable.column_family import GCRuleIntersection
from gcloud.bigtable.column_family import MaxAgeGCRule
from gcloud.bigtable.column_family import MaxVersionsGCRule
Expand Down Expand Up @@ -653,7 +652,7 @@ def _gc_rule_to_dict(gc_rule):
if gc_rule is None:
result = {}
elif isinstance(gc_rule, MaxAgeGCRule):
result = {'time_to_live': _total_seconds(gc_rule.max_age)}
result = {'time_to_live': gc_rule.max_age.total_seconds()}
elif isinstance(gc_rule, MaxVersionsGCRule):
result = {'max_versions': gc_rule.max_num_versions}
elif isinstance(gc_rule, GCRuleIntersection):
Expand Down
9 changes: 4 additions & 5 deletions gcloud/error_reporting/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,10 @@ def _send_error_report(self, message,
if http_context:
http_context_dict = http_context.__dict__
# strip out None values
# once py26 support is dropped this can use dict comprehension
payload['context']['httpContext'] = dict(
(k, v) for (k, v) in six.iteritems(http_context_dict)
if v is not None
)
payload['context']['httpContext'] = {
key: value for key, value in six.iteritems(http_context_dict)
if value is not None
}

if user:
payload['context']['user'] = user
Expand Down
3 changes: 1 addition & 2 deletions gcloud/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class GCloudError(Exception):
"""

def __init__(self, message, errors=()):
super(GCloudError, self).__init__()
# suppress deprecation warning under 2.6.x
super(GCloudError, self).__init__(message)
self.message = message

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

self._errors = errors

Expand Down
28 changes: 0 additions & 28 deletions gcloud/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,34 +494,6 @@ def test_it(self):
self.assertEqual(self._callFUT(NOW_MICROS), NOW)


class Test__total_seconds_backport(unittest2.TestCase):

def _callFUT(self, *args, **kwargs):
from gcloud._helpers import _total_seconds_backport
return _total_seconds_backport(*args, **kwargs)

def test_it(self):
import datetime
offset = datetime.timedelta(seconds=3,
microseconds=140000)
result = self._callFUT(offset)
self.assertEqual(result, 3.14)


class Test__total_seconds(unittest2.TestCase):

def _callFUT(self, *args, **kwargs):
from gcloud._helpers import _total_seconds
return _total_seconds(*args, **kwargs)

def test_it(self):
import datetime
offset = datetime.timedelta(seconds=1,
microseconds=414000)
result = self._callFUT(offset)
self.assertEqual(result, 1.414)


class Test__rfc3339_to_datetime(unittest2.TestCase):

def _callFUT(self, dt_str):
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
Expand Down
10 changes: 0 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ deps =
{[testing]deps}
{[grpc]deps}

[testenv:py26]
basepython =
python2.6
deps =
{[testing]deps}
# ordereddict needed for google.protobuf, which doesn't declare it.
ordereddict
setenv =
PYTHONPATH = {toxinidir}/_testing

[testenv:py27-pandas]
basepython =
python2.7
Expand Down