def __init__(self, name, conf): self._conf = conf self._name = conf.get("name", name) self._log = logger.get_logger("wok.platform.{}".format(name)) if "work_path" not in self._conf: raise MissingConfigParamError("work_path") self._work_path = conf["work_path"] if not os.path.exists(self._work_path): os.makedirs(self._work_path) self._data = self._create_data_provider() self._storage = self._create_storage() self._job_manager = self._create_job_manager() self._callbacks = CallbackManager( delegates=[(events.JOB_UPDATE, self._job_manager.callbacks)])
def __init__(self, name, conf): self._name = name self._conf = conf self._log = logger.get_logger("wok.jobs.{}".format(name)) if "work_path" not in self._conf: raise MissingConfigParamError("work_path") self._work_path = conf["work_path"] if not os.path.exists(self._work_path): os.makedirs(self._work_path) db_path = os.path.join(self._work_path, "jobs.db") # TODO if not in recover_mode then delete jobs.db self._db = create_engine("sqlite:///{}".format(db_path)) self._session_factory = create_session_factory(self._db) self._callbacks = CallbackManager(valid_events=[events.JOB_UPDATE]) # Lock for database jobs state changes self._lock = threading.Lock()