Skip to content

Commit

Permalink
Add travis integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kentzo committed Oct 29, 2017
1 parent 0bbd766 commit d91ad8b
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 29 deletions.
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
language: python
sudo: false

os:
- linux

python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- pypy3

install:
- pip install .[tests] -c requirements.txt
- pip install codecov flake8

script:
- python setup.py test

after_success:
- flake8 power
- codecov

deploy:
provider: pypi
user: Ilya.Kulakov
password:
secure: "Lm2m4xqLGyqaSVtsHjyJKAjYxHAe+gB8TSmZZOkmSKfG+g61lAj3mtX8sAXiYzVcsFDe8cX4XvS3i/K2LoOh9dnc9EureDylvtfzjdKfLRqVjHAcHEeGLBck5tfgQXi3zKiB2EE3Pmu2pV+U0UvhpV40PgaFCroMJGJKI8shme8="
on:
tags: true
branch: master
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Power
=====
.. image:: https://travis-ci.org/Kentzo/Power.svg?branch=master
:target: https://travis-ci.org/Kentzo/Power
.. image:: https://codecov.io/gh/Kentzo/Power/branch/master/graph/badge.svg
:target: https://codecov.io/gh/Kentzo/Power
.. image:: https://img.shields.io/pypi/v/Power.svg
:target: https://pypi.python.org/pypi/Power
.. image:: https://pyup.io/repos/github/Kentzo/Power/shield.svg
:target: https://pyup.io/repos/github/Kentzo/Power/
:alt: Updates

Crossplatform (Windows, Linux, Mac OS X, FreeBSD) python module to access power capabilities of the system.

Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pyobjc-core==4.0; sys_platform == 'darwin'
pytest==3.2.3
pytest-cov==2.5.1
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool:pytest]
addopts= --cov=power --cov-report=term-missing --cov-report=html --cov-branch --ignore=setup.py
testpaths=tests
46 changes: 38 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
#!/usr/bin/env python
# coding=utf-8
__author__ = '[email protected]'
import sys

from setuptools import setup
from sys import platform
from setuptools.command.test import test as TestCommand


REQUIREMENTS = []


if platform.startswith('darwin'):
if sys.platform.startswith('darwin'):
REQUIREMENTS.append('pyobjc-core >= 2.5')


TEST_REQUIREMENTS = [
'pytest',
'pytest-cov',
]


class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")]

def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = ''

def run_tests(self):
import shlex
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(shlex.split(self.pytest_args))
sys.exit(errno)


setup(
name="power",
version="1.4",
version="1.5.dev0",
description="Cross-platform system power status information.",
long_description="Library that allows you get current power source type (AC, Battery or UPS), warning level (none, <22%, <10min) and remaining minutes. You can also observe changes of power source and remaining time.",
long_description="Library that allows you get current power source type (AC, Battery or UPS), "
"warning level (none, <22%, <10min) and remaining minutes. "
"You can also observe changes of power source and remaining time.",
author="Ilya Kulakov",
author_email="[email protected]",
url="https://github.com/Kentzo/Power",
Expand All @@ -32,9 +54,17 @@
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: System :: Monitoring',
'Topic :: System :: Power (UPS)',
],
install_requires=REQUIREMENTS
install_requires=REQUIREMENTS,
tests_require=TEST_REQUIREMENTS,
extras_require={
'tests': TEST_REQUIREMENTS
},
cmdclass={'test': PyTest}
)
Empty file added tests/__init__.py
Empty file.
23 changes: 23 additions & 0 deletions tests/observer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# coding=utf-8
import power


class TestObserver(power.PowerManagementObserver):
def on_power_sources_change(self, power_management):
print("on_power_sources_change")

def on_time_remaining_change(self, power_management):
print("on_time_remaining_change")


if __name__ == "__main__":
o = TestObserver()
p = power.PowerManagement()
p.add_observer(o)
try:
print("Power management observer is registered")
import time
while True:
time.sleep(1)
finally:
p.remove_observer(o)
21 changes: 0 additions & 21 deletions power/tests.py → tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,3 @@ def testGetProvidingPowerSource(self):
self.assertIsNotNone(type)
self.assertIsInstance(type, int)
self.assertIn(type, [power.POWER_TYPE_AC, power.POWER_TYPE_BATTERY, power.POWER_TYPE_UPS])


class TestObserver(power.PowerManagementObserver):
def on_power_sources_change(self, power_management):
print("on_power_sources_change")

def on_time_remaining_change(self, power_management):
print("on_time_remaining_change")


if __name__ == "__main__":
o = TestObserver()
p = power.PowerManagement()
p.add_observer(o)
try:
print("Power management observer is registered")
import time
while True:
time.sleep(1)
finally:
p.remove_observer(o)

0 comments on commit d91ad8b

Please sign in to comment.