2022-07-18 23:59:14 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2016-05-16 23:48:31 +00:00
|
|
|
import logging
|
2016-06-09 03:44:45 +00:00
|
|
|
import os
|
2019-11-10 21:42:04 +00:00
|
|
|
import configparser
|
2016-05-16 23:48:31 +00:00
|
|
|
|
|
|
|
class Context:
|
|
|
|
|
2016-12-15 07:28:00 +00:00
|
|
|
def __init__(self, db, logger, args):
|
2016-05-16 23:48:31 +00:00
|
|
|
self.db = db
|
|
|
|
self.log = logger
|
|
|
|
self.log.debug = logging.debug
|
2017-03-27 21:09:36 +00:00
|
|
|
self.log_folder_path = os.path.join(os.path.expanduser('~/.cme'), 'logs')
|
2016-05-16 23:48:31 +00:00
|
|
|
self.localip = None
|
|
|
|
|
2019-11-10 21:42:04 +00:00
|
|
|
self.conf = configparser.ConfigParser()
|
2016-06-09 03:44:45 +00:00
|
|
|
self.conf.read(os.path.expanduser('~/.cme/cme.conf'))
|
2016-05-16 23:48:31 +00:00
|
|
|
|
2019-11-10 23:12:35 +00:00
|
|
|
for key, value in vars(args).items():
|
2016-12-15 07:28:00 +00:00
|
|
|
setattr(self, key, value)
|