diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..d1aba89 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,4 @@ +[MESSAGES CONTROL] +# import-error and no-name-in-module are false positives for six.moves, pylint +# really hates that. If it's really broken, we'll pick it up in tests. +disable=locally-disabled,import-error,no-name-in-module,invalid-name,missing-docstring,wrong-import-order diff --git a/.travis.yml b/.travis.yml index 8173623..76724d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,34 @@ language: python -python: 3.5 # 3.5 requires manual download, so it needs to be selected +cache: pip -env: - - TOXENV=py27 - - TOXENV=py34 - - TOXENV=py35 - - TOXENV=coverage +python: + - '2.7' + - '3.3' + - '3.4' + - '3.5' + - '3.6' + + # Allowed to fail + - '3.7-dev' + - 'nightly' install: pip install tox -script: tox + +script: + - 'tox' matrix: fast_finish: true + allow_failures: + - python: '3.7-dev' + - python: 'nightly' + include: + # One-off runs + - python: '3.6' + env: TOXENV=coverage + - python: '3.5' # 3.6 after https://github.com/PyCQA/pylint/issues/1113 + env: TOXENV=pylint # This is required to enable container based Travis CI infrastructure. # See http://docs.travis-ci.com/user/migrating-from-legacy/ sudo: false - -notifications: - email: - on_success: never - on_failure: always diff --git a/README.rst b/README.rst index 66edb8f..1351d7f 100644 --- a/README.rst +++ b/README.rst @@ -1,13 +1,17 @@ -|travis| |coveralls| +|travis| |coveralls| |libraries| -.. |travis| image:: https://travis-ci.org/cdown/tzupdate.svg?branch=develop +.. |travis| image:: https://img.shields.io/travis/cdown/tzupdate/develop.svg?label=tests :target: https://travis-ci.org/cdown/tzupdate - :alt: Test status + :alt: Tests -.. |coveralls| image:: https://coveralls.io/repos/cdown/tzupdate/badge.svg?branch=develop&service=github +.. |coveralls| image:: https://img.shields.io/coveralls/cdown/tzupdate/develop.svg?label=test%20coverage :target: https://coveralls.io/github/cdown/tzupdate?branch=develop :alt: Coverage +.. |libraries| image:: https://img.shields.io/librariesio/github/cdown/tzupdate.svg?label=dependencies + :target: https://libraries.io/github/cdown/tzupdate + :alt: Dependencies + tzupdate is a fully automated utility to set the system time using geolocation. Usage @@ -23,7 +27,6 @@ to pass an IP address to use, instead of geolocating you. $ sudo tzupdate Set system timezone to Europe/London. - Installation ------------ @@ -31,19 +34,22 @@ To install the latest stable version from PyPi: .. code:: - pip install -U tzupdate + $ pip install -U tzupdate To install the latest development version directly from GitHub: .. code:: - pip install -U git+https://github.com/cdown/tzupdate.git@develop + $ pip install -U git+https://github.com/cdown/tzupdate.git@develop Testing ------- .. code:: - tox -e quick - -.. _Tox: https://tox.readthedocs.org + $ pip install tox + $ tox + .......... + ---------------------------------------------------------------------- + Ran 10 tests in 4.088s + OK diff --git a/setup.py b/setup.py index f1686fb..a0504da 100755 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( name='tzupdate', - version='1.1.0', + version='1.2.0', description='Set the system timezone based on IP geolocation', long_description=README, url='https://github.com/cdown/tzupdate', diff --git a/tox.ini b/tox.ini index d5062ce..8847ad5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,22 +1,33 @@ [tox] -envlist = py27,py34,py35 +envlist = system [testenv] -deps= +basepython = python +deps = -rrequirements.txt -rtests/requirements.txt -commands= - nosetests +commands = + nosetests -v + +[testenv:system] [testenv:coverage] passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH -basepython=python3.5 -deps= - -rtests/requirements.txt +deps = + {[testenv]deps} coveralls -commands= - nosetests --with-coverage --cover-package=tzupdate +commands = + coverage erase + nosetests -v --with-coverage --cover-branches --cover-package=tzupdate coveralls -[testenv:quick] -basepython=python +[testenv:pylint] +skipsdist = True +deps = + {[testenv]deps} + pylint +commands = + pylint tzupdate.py + +[testenv:windows] +basepython = {env:PYTHON:}\python.exe diff --git a/tzupdate.py b/tzupdate.py index d0f00d6..e2a3cbb 100755 --- a/tzupdate.py +++ b/tzupdate.py @@ -35,7 +35,7 @@ 'GeoIPService', ['url', 'tz_keys', 'error_key'], ) -SERVICES = set([ +SERVICES = frozenset([ GeoIPService( 'http://ip-api.com/json/{ip}', ('timezone',), 'message', ), @@ -220,7 +220,7 @@ def main(argv=None, services=SERVICES): t.terminate() if args.print_only: - print('Detected timezone is %s.' % timezone) + print(timezone) else: link_localtime(timezone, args.zoneinfo_path, args.localtime_path) write_debian_timezone(timezone, args.debian_timezone_path) @@ -248,7 +248,7 @@ class DirectoryTraversalError(TimezoneUpdateException): class TimezoneAcquisitionError(TimezoneUpdateException): ''' - Raised when IP-API raises an internal error. + Raised when a timezone API raises an internal error. '''