-
Notifications
You must be signed in to change notification settings - Fork 0
/
rise_and_shine.py
46 lines (37 loc) · 1.48 KB
/
rise_and_shine.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
import argparse
import logging
import os
import sys
from tunes import get_tune
from hardware import play_tune, record
from brain import process_video
from contact_mothership import upload
from utils import be_patient, is_birthday
logging.basicConfig(
format="%(asctime)s [%(threadName)s] [%(levelname)s] %(message)s",
level=logging.INFO,
filename=os.path.join(os.path.dirname(__file__), 'daily.log')
)
parser = argparse.ArgumentParser(description='Become a better person'\
' via the medium of dance')
parser.add_argument('--debug', type=bool, default=False)
parser.add_argument('--christmas', type=bool, default=False)
args = parser.parse_args()
logging.info('Debug is {}'.format(args.debug))
db_path = os.environ.get('MORNING_PERSON_DB_PATH')
create_endpoint = os.environ.get('MORNING_PERSON_CREATE_ENDPOINT')
token = os.environ.get('MORNING_PERSON_REST_AUTH_TOKEN')
artist, name, url = get_tune(db_path, is_christmas=args.christmas)
if not args.debug:
be_patient(min=0, max=2*60)
play_tune(url)
if not args.debug:
# Happy Birthday Lisa song is short, so wait less on bday
max_wait = 60 if is_birthday() else 60 * 2.5
be_patient(min=30, max=60*2.5)
vid_fp, gif_fp, proc_vid_fp = record()
awakeness, happiness = process_video(vid_fp, gif_fp, proc_vid_fp)
process_metrics = (awakeness, happiness)
song_info = (artist, name, url)
upload(process_metrics, song_info, proc_vid_fp, create_endpoint, token)
logging.info('C\'est finit!')