Commit 269e18b6 authored by birk's avatar birk
Browse files

program logging added

parent 8e8c2a3e
import asyncio
import os
from datetime import datetime
from pathlib import Path
import simplejson as json
import click
......@@ -40,6 +42,11 @@ class Main(object):
screen3 = self._machine.create_screen()
self._dispatcher = Dispatcher((screen1, screen2, screen3))
# log start
if not os.path.exists(self._config.log_dir):
os.makedirs(self._config.log_dir)
self.log_program('*** Start ***')
# defining programs
self._programs = []
......@@ -97,6 +104,7 @@ class Main(object):
self._api.complete_session()
if program.valid:
try:
self.log_program(program.name)
self._dispatcher.set_program(program)
self._dispatcher.start()
except AssertionError:
......@@ -104,6 +112,9 @@ class Main(object):
else:
print("---- invalid program ----")
def log_program(self, name_):
with open(str(Path(self._config.log_dir,'programs_{}.txt'.format(datetime.now().strftime('%Y-%m-%d')))), 'a') as f:
f.write('{} {}\n'.format(datetime.now().strftime('%H:%M:%S'),name_))
if __name__ == '__main__':
m = Main()
from pathlib import Path
def get_green():
return 122, 157, 41, 255
......@@ -59,6 +62,11 @@ class Config:
def dev_mode(self):
return self.__dev_mode
@property
def log_dir(self):
return str(Path(Path.home(), 'player_log'))
def __init__(self):
if not Config.instance:
Config.instance = Config.__Config()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment