-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.py
More file actions
53 lines (40 loc) · 1.52 KB
/
run.py
File metadata and controls
53 lines (40 loc) · 1.52 KB
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
import sys
import inspect
import logging
import asyncio
import PyXIVPlatform
async def main():
logging.basicConfig(
format="[%(levelname)s] %(asctime)s %(name)s> %(message)s",
level=logging.INFO,
datefmt='%y-%m-%d %H:%M:%S')
fileHandler = logging.FileHandler("platform.log", "a", "utf-8")
fileHandler.setLevel(logging.INFO)
fileHandler.setFormatter(logging.Formatter("[%(levelname)s] %(asctime)s %(name)s> %(message)s"))
logging.getLogger().addHandler(fileHandler)
old_logging = {
"debug": logging.debug,
"info": logging.info,
"warn": logging.warn,
"warning": logging.warning,
"critical": logging.critical,
"error": logging.error
}
for name, func in old_logging.items():
logging.__dict__[name] = (lambda n:
lambda *a, **b: getattr(logging.getLogger(
inspect.getmodule(inspect.stack()[1][0]).__name__), n)
(*a, **b))(name)
def exception_handler(loop, context):
logging.error("%s", context)
asyncio.get_event_loop().set_exception_handler(exception_handler)
sys.pycache_prefix = '__pycache__'
platform = PyXIVPlatform.XIVPlatform(sys.argv[1:])
PyXIVPlatform.instance = platform
platform.load_modules("plugins")
if __name__ == "__main__":
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main())
loop.run_forever()