forked from vhoulbreque/ironcar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
33 lines (23 loc) · 884 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
class ConfigException(Exception):
"""Handles the Exceptions concerning the Configuration file such as :
- absence of the file
- absence of one of the necessary fields
"""
def __init__(self, error_message=None):
if not error_message:
error_message = 'The config file is missing some necessary fields'
def __repr__(self):
return colored_message(error_message, FAIL)
class CameraException(Exception):
"""Handles the Exceptions concerning the PiCamera"""
def __init__(self, error_message=None):
if not error_message:
error_message = 'The camera cannot be loaded'
def __repr__(self):
return colored_message(error_message, FAIL)
def colored_message(s, color):
return '{}{}{}'.format(color, s, ENDC)