-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from soda480/0.3.0
0.3.0
- Loading branch information
Showing
16 changed files
with
748 additions
and
389 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
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,47 @@ | ||
# counter example | ||
|
||
import random | ||
import namegenerator | ||
import logging | ||
from time import sleep | ||
|
||
from mpcurses import MPcurses | ||
from screen_layouts.example_counter import get_screen_layout | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_items(): | ||
items = [] | ||
for count in range(0, 1000): | ||
items.append(namegenerator.gen()) | ||
return items | ||
|
||
|
||
def do_work(*args): | ||
items = get_items() | ||
logger.debug(f'{len(items)} total items') | ||
for item in items: | ||
logger.debug(f'processing item "{item}"') | ||
# simulate work being done | ||
sleep(random.choice([0.015])) | ||
if item.count('e') > 4: | ||
# simulate warning | ||
logger.debug(f'warning processing item "{item}"') | ||
elif item.count('g') > 3: | ||
# simulate error | ||
logger.debug(f'error processing item "{item}"') | ||
else: | ||
# simulate success | ||
logger.debug(f'item "{item}" was processed') | ||
logger.debug('processing complete') | ||
|
||
|
||
def main(): | ||
screen_layout = get_screen_layout() | ||
MPcurses(function=do_work, screen_layout=screen_layout).execute() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,15 @@ | ||
# counter example - with modulus | ||
from example_counter1 import do_work | ||
from mpcurses import MPcurses | ||
from screen_layouts.example_counter import get_screen_layout | ||
|
||
|
||
def main(): | ||
screen_layout = get_screen_layout() | ||
screen_layout['_counter_']['modulus'] = 20 | ||
screen_layout['_counter_']['color'] = 7 | ||
MPcurses(function=do_work, screen_layout=screen_layout).execute() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,16 @@ | ||
# counter example - with progress bar | ||
from example_counter1 import do_work | ||
from mpcurses import MPcurses | ||
from screen_layouts.example_counter import get_screen_layout | ||
|
||
|
||
def main(): | ||
screen_layout = get_screen_layout() | ||
screen_layout['_counter_']['modulus'] = 20 | ||
screen_layout['_counter_']['color'] = 7 | ||
screen_layout['_counter_']['regex'] = r'^(?P<value>\d+) total items$' | ||
MPcurses(function=do_work, screen_layout=screen_layout).execute() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,59 @@ | ||
|
||
def get_screen_layout(): | ||
return { | ||
'total': { | ||
'position': (1, 9), | ||
'text': 'Total: 0', | ||
'text_color': 0, | ||
'color': 15, | ||
'regex': r'^(?P<value>\d+) total items$' | ||
}, | ||
'successful': { | ||
'position': (2, 4), | ||
'text': 'Successful: -', | ||
'text_color': 0, | ||
'color': 2, | ||
'keep_count': True, | ||
'regex': r'^item ".*" was processed$' | ||
}, | ||
'warnings': { | ||
'position': (3, 6), | ||
'text': 'Warnings: -', | ||
'text_color': 0, | ||
'color': 3, # 232, | ||
'keep_count': True, | ||
'regex': r'^warning processing item ".*"$' | ||
}, | ||
'errors': { | ||
'position': (4, 8), | ||
'text': 'Errors: -', | ||
'text_color': 0, | ||
'color': 1, # 237, | ||
'keep_count': True, | ||
'regex': r'^error processing item ".*"$' | ||
}, | ||
'processing': { | ||
'position': (5, 4), | ||
'text': 'Processing: -', | ||
'text_color': 0, | ||
'color': 14, | ||
'clear': True, | ||
'regex': r'^processing item "(?P<value>.*)"$' | ||
}, | ||
'processing_done': { | ||
'position': (5, 4), | ||
'replace_text': ' ', | ||
'clear': True, | ||
'regex': r'^processing complete$' | ||
}, | ||
'_counter_': { | ||
'position': (6, 0), | ||
'categories': [ | ||
'successful', | ||
'warnings', | ||
'errors' | ||
], | ||
'counter_text': '|', | ||
'width': 100 | ||
} | ||
} |
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 |
---|---|---|
|
@@ -16,3 +16,4 @@ | |
|
||
from .handler import queue_handler | ||
from .mpcurses import MPcurses | ||
from .mpcontroller import MPcontroller |
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
Oops, something went wrong.