forked from Kentzo/Power
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
109 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
@@ -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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters