Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show better error message for sevensegment demo #76

Merged
merged 6 commits into from
Dec 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/demo_opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
format='%(asctime)-15s - %(message)s'
)
# ignore PIL debug messages
logging.getLogger("PIL").setLevel(logging.ERROR)
logging.getLogger('PIL').setLevel(logging.ERROR)


def display_settings(args):
Expand Down Expand Up @@ -56,12 +56,12 @@ def get_device(actual_args=None):
config = cmdline.load_config(args.config)
args = parser.parse_args(config + actual_args)

print(display_settings(args))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense 👍


# create device
try:
device = cmdline.create_device(args)
except error.Error as e:
parser.error(e)

print(display_settings(args))

return device
6 changes: 6 additions & 0 deletions examples/sevensegment_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Example for seven segment displays.
"""

import sys
import time
from datetime import datetime

Expand Down Expand Up @@ -68,6 +69,11 @@ def show_message_alt(seg, msg, delay=0.1):
def main():
# create seven segment device
device = get_device()

if not hasattr(device, 'segment_mapper'):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm - thinking about it, this check would be better off in the sevensegment class instead

sys.exit('sevensegment is not supported on a {} device'.format(
device.__class__.__name__))

seg = sevensegment(device)

print('Simple text...')
Expand Down