-
Notifications
You must be signed in to change notification settings - Fork 1
/
blink.py
executable file
·52 lines (44 loc) · 1.63 KB
/
blink.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python
# -*- coding: utf-8 -*-
from peripheriques import cmucam
from mock import patch
import argparse, logging, sys
from time import sleep
def main():
testargs = ["verbose"]
with patch.object(sys, 'argv', testargs):
parser = argparse.ArgumentParser()
parser.add_argument('--scan',
action='store_true',
help="""Scanne la couleur devant la caméra au
démarrage. Sinon la dernière couleur sauvegardée
est chargée.""")
parser.add_argument('-v',
'--verbose',
action='store_true',
help="Augmente la verbosité du programme.")
parser.add_argument('-l',
'--logfile',
action='store',
default=None,
help="Spécifie le chemin du journal d'événement.")
args = parser.parse_args()
# Initialisation du journal d'événements
log_frmt = "%(asctime)s[%(levelname)s] %(message)s"
date_frmt = "%Y-%m-%d %H:%M:%S "
if args.verbose:
log_lvl = logging.DEBUG
else:
log_lvl = logging.INFO
logging.basicConfig(filename=args.logfile,
format=log_frmt,
datefmt=date_frmt,
level=log_lvl)
logging.info("Logger initié : {}".format(args.logfile))
c = cmucam.Cmucam(args)
while True:
c.blink()
sleep(0.5)
logging.debug("Blink")
if __name__ == '__main__':
main()