Skip to content

Commit

Permalink
Handle individual Blink device with dynamic instance
Browse files Browse the repository at this point in the history
  • Loading branch information
redaxmedia committed Aug 20, 2019
1 parent 3cc5f85 commit d086081
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions chroma_feedback/consumer/thingm_blink/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ def get_api():
global API

if not API:
API = api_factory()
API = api_factory(None)
return API


def api_factory():
def api_factory(device):
api = None

try:
from blink1.blink1 import Blink1, Blink1ConnectionFailed

try:
api = Blink1()
api = Blink1(device)
except Blink1ConnectionFailed:
exit(wording.get('connection_no').format('THINGM BLINK') + wording.get('exclamation_mark'))
return api
Expand Down
1 change: 1 addition & 0 deletions chroma_feedback/consumer/thingm_blink/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def init(program):
def run(status):
api = get_api()
devices = get_devices(api.list(), ARGS.thingm_blink_device)
api.close()

if not devices:
exit(wording.get('device_no') + wording.get('exclamation_mark'))
Expand Down
14 changes: 7 additions & 7 deletions chroma_feedback/consumer/thingm_blink/device.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import copy
from chroma_feedback import color
from .api import get_api
from .api import api_factory


def get_devices(devices, device_names):
Expand All @@ -23,7 +23,7 @@ def process_devices(status, devices):
'consumer': 'thingm_blink',
'type': 'device',
'name': device,
'active': static_device(color.get_passed()),
'active': static_device(device, color.get_passed()),
'status': status
})
if status == 'process':
Expand All @@ -32,7 +32,7 @@ def process_devices(status, devices):
'consumer': 'thingm_blink',
'type': 'device',
'name': device,
'active': static_device(color.get_process()),
'active': static_device(device, color.get_process()),
'status': status
})
if status == 'errored':
Expand All @@ -41,7 +41,7 @@ def process_devices(status, devices):
'consumer': 'thingm_blink',
'type': 'device',
'name': device,
'active': static_device(color.get_errored()),
'active': static_device(device, color.get_errored()),
'status': status
})
if status == 'failed':
Expand All @@ -50,13 +50,13 @@ def process_devices(status, devices):
'consumer': 'thingm_blink',
'type': 'device',
'name': device,
'active': static_device(color.get_failed()),
'active': static_device(device, color.get_failed()),
'status': status
})
return result


def static_device(state):
api = get_api()
def static_device(device, state):
api = api_factory(device)

return api is not None and api.fade_to_rgb(100, state['rgb'][0], state['rgb'][1], state['rgb'][2]) is None
2 changes: 1 addition & 1 deletion chroma_feedback/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
'name': 'chroma-feedback',
'description': 'Turn your RGB powered hardware into an extreme feedback device for continuous integration',
'version': '5.0.0',
'version': '5.0.1',
'license': 'GPL-3.0',
'keywords': 'appveyor circle github gitlab jenkins teamcity travis ci notification indication',
'author': 'Henry Ruhs',
Expand Down

0 comments on commit d086081

Please sign in to comment.