Skip to content

Commit

Permalink
v2.0.1
Browse files Browse the repository at this point in the history
a beautiful pypi release
  • Loading branch information
markusressel committed Jul 13, 2018
1 parent 63b2fb6 commit dc5e367
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:target: https://badge.fury.io/py/sunix-ledstrip-controller-client

sunix-ledstrip-controller-client |pypi_version|
================================
================================================

A python 3.4+ library for controlling the Sunix® RGB / RGBWWCW WiFi LED Strip controller.

Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
construct
typing;python_version<"3.5"
40 changes: 34 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup, find_packages

VERSION_NUMBER = "2.0.0"
VERSION_NUMBER = "2.0.1"

GIT_BRANCH = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"])
GIT_BRANCH = GIT_BRANCH.decode() # convert to standard string
Expand All @@ -22,14 +22,44 @@
DEVELOPMENT_STATUS = "Development Status :: 2 - Pre-Alpha"
VERSION_NAME = "%s-%s" % (VERSION_NUMBER, GIT_BRANCH)


def readme_type() -> str:
import os
if os.path.exists("README.rst"):
return "text/x-rst"
if os.path.exists("README.md"):
return "text/markdown"


def readme() -> [str]:
with open('README.rst') as f:
return f.read()


def install_requirements() -> [str]:
return read_requirements_file("requirements.txt")


def test_requirements() -> [str]:
return read_requirements_file("test_requirements.txt")


def read_requirements_file(file_name: str):
with open(file_name, encoding='utf-8') as f:
requirements_file = f.readlines()
return [r.strip() for r in requirements_file]


setup(
name='sunix_ledstrip_controller_client',
version=VERSION_NAME,
description='A library for controlling the Sunix RGB / RGBWWCW WiFi LED Strip controller',
long_description=readme(),
long_description_content_type=readme_type(),
license='GPLv3+',
author='Markus Ressel',
author_email='mail@markusressel.de',
url='https://www.markusressel.de',
url='https://github.com/markusressel/sunix-ledstrip-controller-client',
packages=find_packages(),
classifiers=[
DEVELOPMENT_STATUS,
Expand All @@ -40,8 +70,6 @@
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
],
install_requires=[
'construct',
'typing;python_version<"3.5"'
]
install_requires=install_requirements(),
tests_require=test_requirements()
)
14 changes: 10 additions & 4 deletions sunix_ledstrip_controller_client/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,22 @@ def extract_timer_pattern(data: dict, idx: int) -> datetime:

timers = []
for idx in range(1, 7):
enabled = Timer.STATE_ENABLED == timers_data["is_active_%d" % idx]

time = extract_timer_time(timers_data, idx)
pattern = extract_timer_pattern(timers_data, idx)

red = timers_data["red_%d" % idx]
green = timers_data["green_%d" % idx]
blue = timers_data["blue_%d" % idx]

timer = Timer(
enabled=timers_data["is_active_%d" % idx],
enabled=enabled,
execution_time=time,
pattern=pattern,
red=timers_data["red_%d" % idx],
green=timers_data["green_%d" % idx],
blue=timers_data["blue_%d" % idx],
red=red,
green=green,
blue=blue,
)

timers.append(timer)
Expand Down
7 changes: 7 additions & 0 deletions sunix_ledstrip_controller_client/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class Timer:
Representation of a single timer configuration
"""

STATE_ENABLED = 0xf0
STATE_DISABLED = 0x00

def __init__(self, enabled: bool,
execution_time: datetime, pattern: any,
red: int, green: int, blue: int):
Expand Down Expand Up @@ -61,6 +64,10 @@ class Weekday(Enum):


class Mode(Enum):
"""
Constants for specific action modes of a timer
"""

TurnOn = 0xf0
TurnOff = 0x00
Color = 0x61
Empty file added test_requirements.txt
Empty file.

0 comments on commit dc5e367

Please sign in to comment.