Skip to content

Commit

Permalink
[TASK] Drop support for Python 2.6 and 3.3
Browse files Browse the repository at this point in the history
Removing support for python2.6 and the extra workarounds needed
to make code compliant given the age.

Several of the library dependencies are dropping support for
python3.3, so to avoid potential conflicts.
  • Loading branch information
shad7 committed Jun 8, 2015
1 parent 757849f commit a62a03d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 32 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
@@ -1,8 +1,6 @@
language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
- "pypy"
install:
Expand Down
9 changes: 1 addition & 8 deletions seedbox/common/timeutil.py
Expand Up @@ -212,18 +212,11 @@ def delta_seconds(before, after):
def total_seconds(delta):
"""Return the total seconds of datetime.timedelta object.
Compute total seconds of datetime.timedelta, datetime.timedelta
doesn't have method total_seconds in Python2.6, calculate it manually.
:param timedelta delta: a delta to convert
:returns: seconds
:rtype: int
"""
try:
return delta.total_seconds()
except AttributeError:
return ((delta.days * 24 * 3600) + delta.seconds +
float(delta.microseconds) / (10 ** 6))
return delta.total_seconds()


def is_soon(dt, window):
Expand Down
9 changes: 3 additions & 6 deletions seedbox/options.py
Expand Up @@ -7,20 +7,17 @@

from oslo_config import cfg

DEFAULT_LOG_FILENAME = '{0}.log'.format(__package__)
DEFAULT_LOG_LEVEL = 'info'

CLI_OPTS = [
cfg.BoolOpt('cron',
default=False,
help='Disable console output when running via cron'),
cfg.StrOpt('logfile',
metavar='LOG_FILE',
default=DEFAULT_LOG_FILENAME,
default='{0}.log'.format(__package__),
help='specify name of log file default: %(default)s'),
cfg.StrOpt('loglevel',
metavar='LOG_LEVEL',
default=DEFAULT_LOG_LEVEL,
default='info',
help='specify logging level to log messages: %(choices)s',
choices=['none',
'critical',
Expand Down Expand Up @@ -75,7 +72,7 @@
cfg.ListOpt('complete',
default=[],
help='name of tasks associated with complete phase'),
]
]

cfg.CONF.register_opts(PROC_OPTS, group='process')

Expand Down
10 changes: 1 addition & 9 deletions seedbox/service.py
Expand Up @@ -11,15 +11,7 @@
from seedbox import version


if hasattr(logging, 'NullHandler'):
NullHandler = logging.NullHandler
else:
# NullHandler added in Python 2.7
class NullHandler(logging.Handler):
def emit(self, record):
pass

logging.getLogger().addHandler(NullHandler())
logging.getLogger().addHandler(logging.NullHandler())

PROJECT = __package__
DEFAULT_LIBRARY_LOG_LEVEL = {'xworkflows': logging.ERROR,
Expand Down
8 changes: 4 additions & 4 deletions seedbox/tests/test_service.py
Expand Up @@ -88,7 +88,7 @@ def test_setup_logging(self):
matchers.MatchesAny(
matchers.IsInstance(logging.handlers.RotatingFileHandler),
matchers.IsInstance(logging.StreamHandler),
matchers.IsInstance(service.NullHandler)))
matchers.IsInstance(logging.NullHandler)))

def test_setup_logging_no_logfile(self):
self.CONF.set_override('logfile', None)
Expand All @@ -99,7 +99,7 @@ def test_setup_logging_no_logfile(self):
hndler,
matchers.MatchesAny(
matchers.IsInstance(logging.StreamHandler),
matchers.IsInstance(service.NullHandler)))
matchers.IsInstance(logging.NullHandler)))

def test_setup_logging_cron(self):
self.CONF.set_override('cron', True)
Expand All @@ -110,7 +110,7 @@ def test_setup_logging_cron(self):
hndler,
matchers.MatchesAny(
matchers.IsInstance(logging.handlers.RotatingFileHandler),
matchers.IsInstance(service.NullHandler)))
matchers.IsInstance(logging.NullHandler)))

def test_setup_logging_no_logging(self):
self.CONF.set_override('logfile', None)
Expand All @@ -121,7 +121,7 @@ def test_setup_logging_no_logging(self):
self.assertThat(
hndler,
matchers.MatchesAny(
matchers.IsInstance(service.NullHandler)))
matchers.IsInstance(logging.NullHandler)))

def test_setup_logging_via_file(self):
logfile = self.create_tempfiles([('seedbox',
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Expand Up @@ -17,10 +17,8 @@ classifier =
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: Implementation :: PyPy
Topic :: Internet
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
@@ -1,7 +1,7 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = py34,py33,py27,py26,pep8,cover
envlist = py34,py27,pep8,cover

[testenv]
whitelist_externals=bash
Expand Down

0 comments on commit a62a03d

Please sign in to comment.