Skip to content

Commit

Permalink
Rename provider to producer (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Ruhs committed Dec 30, 2019
1 parent abd5b7e commit 55fa631
Show file tree
Hide file tree
Showing 60 changed files with 132 additions and 132 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ apt install openrazer-meta
Usage
-----

Combine providers and consumers as needed:
Combine producers and consumers as needed:

```
chroma-feedback [options]
-V, --version
-P, --provider <provider>
-P, --producer <producer>
-C, --consumer <consumer>
-I, --background-interval <background-interval>
-B, --background-run
Expand All @@ -59,7 +59,7 @@ chroma-feedback [options]
```


Providers
Producers
=========


Expand All @@ -75,15 +75,15 @@ AppVeyor
Monitor a single project:

```
chroma-feedback --provider=appveyor
chroma-feedback --producer=appveyor
--appveyor-slug <username/repository>
```

Monitor multiple projects:

```
chroma-feedback --provider=appveyor
chroma-feedback --producer=appveyor
--appveyor-token <token>
```
Expand Down Expand Up @@ -135,15 +135,15 @@ Circle
Monitor a single project:

```
chroma-feedback --provider=circle
chroma-feedback --producer=circle
--circle-slug <username/repository>
```

Monitor multiple projects:

```
chroma-feedback --provider=circle
chroma-feedback --producer=circle
--circle-token <token>
```
Expand All @@ -162,7 +162,7 @@ Codeship
Monitor a single project:

```
chroma-feedback --provider=codeship
chroma-feedback --producer=codeship
--codeship-slug <project-id>
--codeship-username <username>
Expand All @@ -172,7 +172,7 @@ chroma-feedback --provider=codeship
Monitor multiple projects:

```
chroma-feedback --provider=codeship
chroma-feedback --producer=codeship
--codeship-username <username>
--codeship-password <password>
Expand All @@ -192,7 +192,7 @@ GitHub
Monitor a single project:

```
chroma-feedback --provider=github
chroma-feedback --producer=github
--github-slug <username/repository>
--github-username <username>
Expand All @@ -202,7 +202,7 @@ chroma-feedback --provider=github
Monitor multiple projects:

```
chroma-feedback --provider=github
chroma-feedback --producer=github
--github-slug <username/repository>
--github-slug <username/repository>
Expand All @@ -223,7 +223,7 @@ GitLab
Monitor a single project:

```
chroma-feedback --provider=gitlab
chroma-feedback --producer=gitlab
--gitlab-slug <project-id>
--gitlab-token <token>
Expand All @@ -232,7 +232,7 @@ chroma-feedback --provider=gitlab
Monitor multiple projects:

```
chroma-feedback --provider=gitlab
chroma-feedback --producer=gitlab
--gitlab-slug <project-id>
--gitlab-slug <project-id>
Expand All @@ -253,7 +253,7 @@ Jenkins
Monitor a single project:

```
chroma-feedback --provider=jenkins
chroma-feedback --producer=jenkins
--jenkins-host <host>
--jenkins-slug <job>
Expand All @@ -264,7 +264,7 @@ chroma-feedback --provider=jenkins
Monitor multiple projects:

```
chroma-feedback --provider=jenkins
chroma-feedback --producer=jenkins
--jenkins-host <host>
--jenkins-slug <job>
Expand All @@ -286,7 +286,7 @@ TeamCity
Monitor a single project:

```
chroma-feedback --provider=teamcity
chroma-feedback --producer=teamcity
--teamcity-slug <project-id>
--teamcity-token<token>
Expand All @@ -295,7 +295,7 @@ chroma-feedback --provider=teamcity
Monitor multiple projects:

```
chroma-feedback --provider=teamcity
chroma-feedback --producer=teamcity
--teamcity-token <token>
```
Expand All @@ -312,15 +312,15 @@ Travis
Monitor a single project:

```
chroma-feedback --provider=travis
chroma-feedback --producer=travis
--travis-slug <username/repository>
```

Monitor multiple projects:

```
chroma-feedback --provider=travis
chroma-feedback --producer=travis
--travis-slug <username>
```
Expand Down
4 changes: 2 additions & 2 deletions bin/chroma-feedback
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ from argparse import ArgumentParser
from chroma_feedback.core import run, destroy
from chroma_feedback import metadata
from chroma_feedback.consumer import __all__ as consumer
from chroma_feedback.provider import __all__ as provider
from chroma_feedback.producer import __all__ as producer

signal.signal(signal.SIGINT, destroy)

program = ArgumentParser()
program.add_argument('-V', '--version', action = 'version', version = metadata.get('name') + ' ' + metadata.get('version'))
program.add_argument('-P', '--provider', action = 'append', choices = provider, required = True)
program.add_argument('-P', '--producer', action = 'append', choices = producer, required = True)
program.add_argument('-C', '--consumer', action = 'append', choices = consumer, required = True)
program.add_argument('-I', '--background-interval', default = 60, type = int)
program.add_argument('-B', '--background-run', action = 'store_true')
Expand Down
18 changes: 9 additions & 9 deletions chroma_feedback/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import sys
import threading
from chroma_feedback import consumer, helper, provider, reporter, wording
from chroma_feedback import consumer, helper, producer, reporter, wording


def run(program : ArgumentParser) -> None:
Expand All @@ -17,20 +17,20 @@ def run(program : ArgumentParser) -> None:
reporter.print_header()
print()

# process provider
# process producer

provider_result = provider.process(program)
producer_result = producer.process(program)

# handle exit

if not provider_result:
if not producer_result:
exit(wording.get('result_no') + wording.get('exclamation_mark'))

# report provider
# report producer

provider_report = reporter.create_provider_report(provider_result)
if provider_report:
reporter.print_report(provider_report)
producer_report = reporter.create_producer_report(producer_result)
if producer_report:
reporter.print_report(producer_report)
print()

# handle dry run
Expand All @@ -40,7 +40,7 @@ def run(program : ArgumentParser) -> None:

# process consumer

status = helper.get_provider_status(provider_result)
status = helper.get_producer_status(producer_result)
consumer_result = consumer.process(program, status)

# report consumer
Expand Down
14 changes: 7 additions & 7 deletions chroma_feedback/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
from requests import Response


def get_provider_status(provider_result : List[Dict[str, Any]]) -> str:
def get_producer_status(producer_result : List[Dict[str, Any]]) -> str:
status = 'passed'

# process provider
# process producer

for provider in provider_result:
if provider['active'] is True:
if provider['status'] == 'process':
for producer in producer_result:
if producer['active'] is True:
if producer['status'] == 'process':
if status not in ['errored', 'failed']:
status = 'process'
if provider['status'] == 'errored':
if producer['status'] == 'errored':
if status != 'failed':
status = 'errored'
if provider['status'] == 'failed':
if producer['status'] == 'failed':
status = 'failed'
return status

Expand Down
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 build indicator for continuous integration',
'version': '6.2.0',
'version': '7.0.0',
'license': 'GPL-3.0',
'keywords': 'appveyor bamboo circle codeship github gitlab jenkins teamcity travis',
'author': 'Henry Ruhs',
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def normalize_data(project : Dict[str, Any], build : Dict[str, Any]) -> Dict[str, Any]:
return\
{
'provider': 'appveyor',
'producer': 'appveyor',
'slug': project['accountName'] + '/' + project['slug'],
'active': True,
'status': normalize_status(build['status'].lower())
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def normalize_data(project : Dict[str, Any]) -> Dict[str, Any]:
return\
{
'provider': 'bamboo',
'producer': 'bamboo',
'slug': project['key'],
'active': True,
'status': normalize_status(project['buildState'].lower())
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def normalize_data(project : Dict[str, Any]) -> Dict[str, Any]:
return\
{
'provider': 'circle',
'producer': 'circle',
'slug': project['username'] + '/' + project['reponame'],
'active': True,
'status': normalize_status(project['status'].lower())
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def normalize_data(build : Dict[str, Any]) -> Dict[str, Any]:
return\
{
'provider': 'codeship',
'producer': 'codeship',
'slug': str(build['project_id']),
'active': True,
'status': normalize_status(build['status'].lower())
Expand Down
22 changes: 22 additions & 0 deletions chroma_feedback/producer/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from typing import Any, Dict, List
from argparse import ArgumentParser
import importlib
from chroma_feedback import helper, wording


def process(program : ArgumentParser) -> List[Dict[str, Any]]:
args = helper.get_first(program.parse_known_args())
result = []

for producer_name in args.producer:
producer = load_producer(producer_name)
producer.init(program)
result.extend(producer.run())
return result


def load_producer(producer_name : str) -> Any:
try:
return importlib.import_module('chroma_feedback.producer.' + producer_name)
except ImportError:
exit(wording.get('producer_no') + wording.get('exclamation_mark'))
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def normalize_data(project : Dict[str, Any]) -> Dict[str, Any]:
return\
{
'provider': 'github',
'producer': 'github',
'slug': project['repository']['full_name'],
'active': True,
'status': normalize_status(project['state'].lower())
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def normalize_data(project : Dict[str, Any]) -> Dict[str, Any]:
return\
{
'provider': 'gitlab',
'producer': 'gitlab',
'slug': project['slug'] + '/' + project['name'],
'active': True,
'status': normalize_status(project['status'].lower())
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def normalize_data(project : Dict[str, Any]) -> Dict[str, Any]:
return\
{
'provider': 'jenkins',
'producer': 'jenkins',
'slug': project['displayName'],
'active': True,
'status': normalize_status(project['color'].lower())
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def normalize_data(build : Dict[str, Any]) -> Dict[str, Any]:
return\
{
'provider': 'teamcity',
'producer': 'teamcity',
'slug': build['buildType']['projectName'],
'active': True,
'status': normalize_status(build['running'], build['status'].lower())
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def normalize_data(project : Dict[str, Any]) -> Dict[str, Any]:
return\
{
'provider': 'travis',
'producer': 'travis',
'slug': project['slug'],
'active': project['active'],
'status': normalize_status(project['last_build_state'].lower())
Expand Down
22 changes: 0 additions & 22 deletions chroma_feedback/provider/core.py

This file was deleted.

Loading

0 comments on commit 55fa631

Please sign in to comment.