-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (42 loc) · 1.35 KB
/
main.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
53
#!/usr/bin/env python3
from parse import PlaybookParser
from render import render_playbook
import sys, os, logging
import coloredlogs, logging
import error_handling
def setup_loggers(level):
logger = logging.getLogger('lib')
field_styles = {'asctime': {'color': 'yellow'}, 'hostname': {'color': 'magenta'}, 'levelname': {'bold': True, 'color': 'magenta'}, 'name': {'color': 'blue'}, 'programname': {'color': 'cyan'}, 'username': {'color': 'yellow'}}
coloredlogs.install(
fmt='%(levelname)s: %(message)s',
level=level,
field_styles=field_styles,
logger=logger
)
logger = logging.getLogger('main')
coloredlogs.install(
fmt='\n%(asctime)s -> %(message)s\n',
level=level,
field_styles=field_styles,
logger=logger
)
return logger
def main():
from datetime import datetime
error_handling.STRICT = True
logger = setup_loggers("DEBUG")
pb_path = os.path.realpath(os.path.expanduser(sys.argv[1]))
from parse import PlaybookParser
pb = PlaybookParser(pb_path)
logger.info("RENDERING")
final_video = render_playbook(pb)
logger.info("WRITING")
final_video.write_videofile(os.path.basename(pb_path)+".mp4", fps=30)
logger.info("FINISH")
def profiling():
import profile, pstats
profile.run('main()', 'stats')
p = pstats.Stats('stats')
p.sort_stats(pstats.SortKey.TIME, pstats.SortKey.CUMULATIVE).print_stats(20)
if __name__=='__main__':
main()