Skip to content

Commit

Permalink
Merge 37383ca into d086081
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Ruhs committed Nov 4, 2019
2 parents d086081 + 37383ca commit ff3bb5d
Show file tree
Hide file tree
Showing 20 changed files with 278 additions and 112 deletions.
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
disable =
bad-continuation,
bad-whitespace,
consider-using-sys-exit,
cyclic-import,
duplicate-code,
global-statement,
import-outside-toplevel,
missing-docstring,
protected-access,
unused-argument
Expand Down
238 changes: 137 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Chroma Feedback
[![Build Status Travis](https://img.shields.io/travis/redaxmedia/chroma-feedback.svg)](https://travis-ci.org/redaxmedia/chroma-feedback)
[![Build Status AppVeyor](https://img.shields.io/appveyor/ci/redaxmedia/chroma-feedback.svg)](https://ci.appveyor.com/project/redaxmedia/chroma-feedback)
[![Build Status Circle](https://img.shields.io/circleci/project/github/redaxmedia/chroma-feedback.svg)](https://circleci.com/gh/redaxmedia/chroma-feedback)
[![Build Status Codeship](https://img.shields.io/codeship/chroma-feedback.svg)](https://app.codeship.com/projects/372431)
[![Coverage Status](https://img.shields.io/coveralls/redaxmedia/chroma-feedback.svg)](https://coveralls.io/r/redaxmedia/chroma-feedback)
[![PyPI](https://img.shields.io/pypi/v/chroma-feedback.svg)](https://pypi.org/project/chroma-feedback)
[![License](https://img.shields.io/pypi/l/chroma-feedback.svg)](https://pypi.org/project/chroma-feedback)
Expand Down Expand Up @@ -62,107 +63,6 @@ chroma-feedback [options]
```


Consumers
=========


Lifx Light
----------

| Name | Mandatory |
|----------|-----------|
| Light | optional |
| Group | optional |

Indicate status via lights:

```
chroma-feedback --consumer=lifx_light
--lifx-light-light <light-name>
```

Indicate status via groups:

```
chroma-feedback --consumer=lifx_light
--lifx-light-group <group-name>
```


Philips Hue
-----------

| Name | Mandatory |
|----------|-----------|
| IP | optional |
| Light | optional |
| Group | optional |

Indicate status via lights:

```
chroma-feedback --consumer=philips_hue
--philips-hue-light <light-name>
```

Indicate status via groups:

```
chroma-feedback --consumer=philips_hue
--philips-hue-group <group-name>
```


Razer Chroma
------------

| Name | Mandatory |
|--------|-----------|
| Device | optional |

Indicate status via devices:

```
chroma-feedback --consumer=razer_chroma
--razer-chrome-device <device-name>
```


ThingM Blink
------------

| Name | Mandatory |
|--------|-----------|
| Device | optional |

Indicate status via devices:

```
chroma-feedback --consumer=thingm_blink
--thingm-blink-device <device-serial>
```


Xiaomi Yeelight
---------------

| Name | Mandatory |
|----------|-----------|
| IP | optional |

Indicate status via lights:

```
chroma-feedback --consumer=xiaomi_yeelight
```


Providers
=========

Expand Down Expand Up @@ -219,6 +119,41 @@ chroma-feedback --provider=circle
```


Codeship
--------

| Name | Default | Mandatory |
|--------------|--------------------------|-----------|
| Host | https://api.codeship.com | optional |
| Organization | | required |
| Project | | required |
| Username | | required |
| Password | | required |

Monitor a single project:

```
chroma-feedback --provider=codeship
--codeship-oranization <oranization-uuid>
--codeship-project <project-uuid>
--codeship-username <username>
--codeship-password <password>
```

Monitor multiple projects:

```
chroma-feedback --provider=codeship
--codeship-oranization <oranization-uuid>
--codeship-project <project-uuid>
--codeship-project <project-uuid>
--codeship-username <username>
--codeship-password <password>
```


GitHub
------

Expand Down Expand Up @@ -361,3 +296,104 @@ chroma-feedback --provider=travis
--travis-slug <username>
```


Consumers
=========


Lifx Light
----------

| Name | Mandatory |
|----------|-----------|
| Light | optional |
| Group | optional |

Indicate status via lights:

```
chroma-feedback --consumer=lifx_light
--lifx-light-light <light-name>
```

Indicate status via groups:

```
chroma-feedback --consumer=lifx_light
--lifx-light-group <group-name>
```


Philips Hue
-----------

| Name | Mandatory |
|----------|-----------|
| IP | optional |
| Light | optional |
| Group | optional |

Indicate status via lights:

```
chroma-feedback --consumer=philips_hue
--philips-hue-light <light-name>
```

Indicate status via groups:

```
chroma-feedback --consumer=philips_hue
--philips-hue-group <group-name>
```


Razer Chroma
------------

| Name | Mandatory |
|--------|-----------|
| Device | optional |

Indicate status via devices:

```
chroma-feedback --consumer=razer_chroma
--razer-chrome-device <device-name>
```


ThingM Blink
------------

| Name | Mandatory |
|--------|-----------|
| Device | optional |

Indicate status via devices:

```
chroma-feedback --consumer=thingm_blink
--thingm-blink-device <device-serial>
```


Xiaomi Yeelight
---------------

| Name | Mandatory |
|----------|-----------|
| IP | optional |

Indicate status via lights:

```
chroma-feedback --consumer=xiaomi_yeelight
```
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.1',
'version': '5.1.0',
'license': 'GPL-3.0',
'keywords': 'appveyor circle github gitlab jenkins teamcity travis ci notification indication',
'author': 'Henry Ruhs',
Expand Down
1 change: 1 addition & 0 deletions chroma_feedback/provider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[
'appveyor',
'circle',
'codeship',
'github',
'gitlab',
'jenkins',
Expand Down
1 change: 1 addition & 0 deletions chroma_feedback/provider/codeship/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .core import init, run
67 changes: 67 additions & 0 deletions chroma_feedback/provider/codeship/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import base64
import requests
from chroma_feedback import helper
from .normalize import normalize_data

ARGS = None


def init(program):
global ARGS

if not ARGS:
program.add_argument('--codeship-host', default = 'https://api.codeship.com')
program.add_argument('--codeship-organization', required = True)
program.add_argument('--codeship-project', action = 'append', required = True)
program.add_argument('--codeship-username', required = True)
program.add_argument('--codeship-password', required = True)
ARGS = program.parse_known_args()[0]


def run():
result = []
token = fetch_token(ARGS.codeship_host, ARGS.codeship_username, ARGS.codeship_password)

if token:
for project in ARGS.codeship_project:
result.extend(fetch(ARGS.codeship_host, ARGS.codeship_organization, project, token))
return result


def fetch(host, organization, project, token):
response = None

if host and organization and project and token:
response = requests.get(host + '/v2/organizations/' + organization + '/projects/' + project + '/builds', headers =
{
'Authorization': 'Bearer ' + token
})

# process response

if response and response.status_code == 200:
data = helper.parse_json(response)

if 'builds' in data:
return normalize_data(data['builds'][0])
return []


def fetch_token(host, username, password):
response = None

if host and username and password:
username_token = username + ':' + password
response = requests.post(host + '/v2/auth', headers =
{
'Authorization': 'Basic ' + base64.b64encode(username_token.encode('utf-8')).decode('ascii')
})

# process response

if response and response.status_code == 200:
data = helper.parse_json(response)

if data['access_token']:
return data['access_token']
return None
20 changes: 20 additions & 0 deletions chroma_feedback/provider/codeship/normalize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def normalize_data(build):
return\
[
{
'provider': 'codeship',
'slug': build['project_id'],
'active': True,
'status': normalize_status(build['status'])
}
]


def normalize_status(status):
if status in ['initiated', 'waiting']:
return 'process'
if status in ['error', 'blocked', 'ignored']:
return 'errored'
if status in ['failed', 'infrastructure_failure']:
return 'failed'
return 'passed'
Loading

0 comments on commit ff3bb5d

Please sign in to comment.