def __init__(self): client_path = Database.get_client_dir() log_conf = '_'.join([self.NAME, 'logging.ini']) log_path = os.path.join(client_path, 'conf', log_conf) logging.config.fileConfig(log_path) project_path = Database.get_project_dir() self.logger = Logger.get_logger(__name__) self.pid_file = '/tmp/upgradeclient/{0}.pid'.format(self.NAME) self.out_file = '/tmp/upgradeclient/{0}.out'.format(self.NAME) self.err_file = '/tmp/upgradeclient/{0}.err'.format(self.NAME) self.ctx_yaml = os.path.join(project_path, '{0}.yaml'.format(self.NAME))
#! -*- coding: utf-8 -*- import os import time from threading import Thread from upgradeclient.domain.common.logger import Logger from upgradeclient.domain.model.event.event import Event from upgradeclient.service.base_service import BaseService logger = Logger.get_logger(__name__) class DownloadHandlerThread(Thread): def __init__(self, json_data, service): super(DownloadHandlerThread, self).__init__() self.service = service self.json_data = json_data def run(self): event = Event.from_json(self.json_data) self.service.handle(event) class DownloadService(BaseService): def __init__(self, cache=None, handler_factory=None, abstruct_path=None, relative_path=None, check_interval=15): self.cache = cache self.sub_threads = []