def _get_global_max_concurrent_config(config): if 'global' not in config: raise InvalidYAMLConfigException( 'Failed to find global parameter in the YAML.') if 'max_concurrent' not in config['global']: raise InvalidYAMLConfigException( 'Failed to find max_concurrent in the global parameter in the YAML.' ) max_concurrent = config['global']['max_concurrent'] if not isinstance(max_concurrent, int): raise Exception('global -> max_concurrent should be a integer value.') return max_concurrent
def _get_log_settings(config): if 'log' not in config: raise InvalidYAMLConfigException('Failed to find the log parameter in the YAML.') log = config['log'] expected_parameters = ['folder_path'] _check_parameters(parameter=log, expected_parameters=expected_parameters, parameter_type='log') return log['folder_path']
def _get_manager_settings(config): if 'manager' not in config: raise InvalidYAMLConfigException('Failed to find the log parameter in the YAML.') manager = config['manager'] expected_parameters = ['check_interval', 'log_level'] _check_parameters(parameter=manager, expected_parameters=expected_parameters, parameter_type='manager') return manager['check_interval'], manager['log_level']
def _get_view_settings(config): if 'view' not in config: raise InvalidYAMLConfigException('Failed to find view parameter in the YAML.') view = config['view'] expected_parameters = ['datetime_format', 'include_seconds_for_phase', 'include_drive_info', 'include_cpu', 'include_ram', 'include_plot_stats', 'check_interval'] _check_parameters(parameter=view, expected_parameters=expected_parameters, parameter_type='view') return view
def _check_parameters(parameter, expected_parameters, parameter_type): failed_checks = [] checks = expected_parameters for check in checks: if check in parameter: continue failed_checks.append(check) if failed_checks: raise InvalidYAMLConfigException(f'Failed to find the following {parameter_type} parameters: ' f'{", ".join(failed_checks)}')
def _get_notifications_settings(config): if 'notifications' not in config: raise InvalidYAMLConfigException( 'Failed to find notifications parameter in the YAML.') notifications = config['notifications'] expected_parameters = [ 'notify_discord', 'discord_webhook_url', 'notify_sound', 'song', 'notify_pushover', 'pushover_user_key', 'pushover_api_key' ] _check_parameters(parameter=notifications, expected_parameters=expected_parameters, parameter_type='notification') return notifications
def _get_global_config(config): if 'global' not in config: raise InvalidYAMLConfigException('Failed to find global parameter in the YAML.') global_config = config['global'] expected_parameters = ['max_concurrent', 'max_for_phase_1', 'minimum_minutes_between_jobs'] _check_parameters(parameter=global_config, expected_parameters=expected_parameters, parameter_type='global') max_concurrent = global_config['max_concurrent'] max_for_phase_1 = global_config['max_for_phase_1'] minimum_minutes_between_jobs = global_config['minimum_minutes_between_jobs'] if not isinstance(max_concurrent, int): raise Exception('global -> max_concurrent should be a integer value.') if not isinstance(max_for_phase_1, int): raise Exception('global -> max_for_phase_1 should be a integer value.') if not isinstance(minimum_minutes_between_jobs, int): raise Exception('global -> max_concurrent should be a integer value.') return max_concurrent, max_for_phase_1, minimum_minutes_between_jobs
def _get_jobs(config): if 'jobs' not in config: raise InvalidYAMLConfigException( 'Failed to find the jobs parameter in the YAML.') return config['jobs']
def _get_instrumentation_settings(config): if 'instrumentation' not in config: raise InvalidYAMLConfigException( 'Failed to find instrumentation parameter in the YAML.') instrumentation = config.get('instrumentation', {}) return instrumentation