-
Notifications
You must be signed in to change notification settings - Fork 0
/
typo.py
executable file
·35 lines (28 loc) · 946 Bytes
/
typo.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
#!/usr/bin/env python3
import asyncio
import logging
from client import WebClient
from common import utils
from client import Controller
from plumbum.cli import Application, SwitchAttr
from srv.Database import JsonDatabase
import os
DB_FILE = "typo.json"
class App(Application):
config_dir = SwitchAttr(
"config", str, help="directory for storing config", default=".")
def make_config_dir(self):
if not os.path.isdir(self.config_dir):
os.mkdir(self.config_dir)
def main(self):
self.make_config_dir()
utils.setupLogger()
logging.info("client started")
loop = asyncio.get_event_loop()
client = WebClient.WebClient(loop)
db = JsonDatabase(os.path.join(self.config_dir, DB_FILE))
db.load()
client_controller = Controller.Controller(client, db, loop)
loop.create_task(client_controller.main())
loop.run_forever()
App.run()