def __init__(self, bot, *args, **kwargs): super().__init__(*args, **kwargs) self.bot = bot self.name = kwargs.get('name') ## Build the filepaths for the various tracking files delete_request_queue_file_path = CONFIG_OPTIONS.get('delete_request_queue_file_path') if (delete_request_queue_file_path): self.delete_request_queue_file_path = Path(delete_request_queue_file_path) else: self.delete_request_queue_file_path = Path.joinpath(utilities.get_root_path(), 'privacy', 'delete_requests.txt') delete_request_meta_file_path = CONFIG_OPTIONS.get('delete_request_meta_file_path') if (delete_request_meta_file_path): self.delete_request_meta_file_path = Path(delete_request_meta_file_path) else: self.delete_request_meta_file_path = Path.joinpath(utilities.get_root_path(), 'privacy', 'meta.json') ## Make sure the file containing all delete requests is accessible. if (not self.is_file_accessible(self.delete_request_queue_file_path)): message = "Unable to access delete request queue file at: '{}'. Make sure that it exists and has r/w permissions applied to it".format(self.delete_request_queue_file_path) logger.error(message) raise RuntimeError(message) ## Make sure the file containing the delete request metadata is accessible. if (not self.is_file_accessible(self.delete_request_meta_file_path)): message = "Unable to access delete request queue file at: '{}'. Make sure that it exists and has r/w permissions applied to it".format(self.delete_request_meta_file_path) logger.error(message) raise RuntimeError(message) ## Make sure there's a dynamo manager available for database operations self.dynamo_db = dynamo_manager.DynamoManager() ## Delete request scheduling self.delete_request_scheduled_weekday = int(CONFIG_OPTIONS.get('delete_request_weekday_to_process', 0)) self.delete_request_scheduled_time = dateutil.parser.parse(CONFIG_OPTIONS.get('delete_request_time_to_process', "T00:00:00Z")) ## Keep a copy of all user ids that should be deleted in memory, so the actual file can't get spammed by repeats. self.queued_user_ids = self.get_all_queued_delete_request_ids() ## Load the delete request metadata to know when deletion operations last happened try: self.metadata = utilities.load_json(self.delete_request_meta_file_path) except json.decoder.JSONDecodeError: self.metadata = {} ## Perform or prepare the deletion process seconds_until_process_delete_request = self.get_seconds_until_process_delete_request_queue_is_due() if (seconds_until_process_delete_request <= 0): self.bot.loop.create_task(self.process_delete_request_queue()) else: self.bot.loop.create_task(self.schedule_process_delete_request_queue(seconds_until_process_delete_request))
def get_tts_executable_path() -> Path: tts_executable_path = CONFIG_OPTIONS.get('tts_executable_path') if (tts_executable_path is not None): return Path(tts_executable_path) else: return Path(utilities.get_root_path(), 'code', 'core', 'tts', CONFIG_OPTIONS.get('tts_executable', 'say.exe'))
def __init__(self, bot_controller, bot: commands.Bot): self.bot_controller = bot_controller self.bot = bot modules_dir_path = CONFIG_OPTIONS.get('modules_dir_path') if (modules_dir_path): self.modules_dir_path = Path(modules_dir_path) else: self.modules_dir_path = Path.joinpath( utilities.get_root_path(), CONFIG_OPTIONS.get('modules_dir', 'modules')) self.modules = OrderedDict() self.loaded_modules = {} # Keep non-cog modules loaded in memory self._dependency_graph = DependencyGraph()
def __init__(self, **kwargs): self.exe_path = TTSController.get_tts_executable_path() self.args = kwargs.get(self.ARGS_KEY, {}) self.audio_generate_timeout_seconds = CONFIG_OPTIONS.get("audio_generate_timeout_seconds", 3) self.prepend = kwargs.get(self.PREPEND_KEY, self.PREPEND) self.append = kwargs.get(self.APPEND_KEY, self.APPEND) self.char_limit = int(kwargs.get(self.CHAR_LIMIT_KEY, self.CHAR_LIMIT)) self.newline_replacement = kwargs.get(self.NEWLINE_REPLACEMENT_KEY, self.NEWLINE_REPLACEMENT) self.output_extension = kwargs.get(self.OUTPUT_EXTENSION_KEY, self.OUTPUT_EXTENSION) self.wine = kwargs.get(self.WINE_KEY, self.WINE) self.xvfb_prepend = kwargs.get(self.XVFB_PREPEND_KEY, self.XVFB_PREPEND) self.is_headless = kwargs.get(self.HEADLESS_KEY, self.HEADLESS) output_dir_path = CONFIG_OPTIONS.get('tts_output_dir_path') if (output_dir_path): self.output_dir_path = Path(output_dir_path) else: self.output_dir_path = Path.joinpath(utilities.get_root_path(), CONFIG_OPTIONS.get('tts_output_dir', 'temp')) self.paths_to_delete = [] self.async_os = aioify(obj=os, name='async_os') ## Prep the output directory self._init_output_dir()