def _execute_sync_action( self, job_interface: background_job.BackgroundProcessInterface, add_to_changelog: bool, enforce_sync: bool, load_users_func: Callable, save_users_func: Callable) -> bool: for connection_id, connection in active_connections(): try: if not enforce_sync and not connection.sync_is_needed(): continue job_interface.send_progress_update( _("[%s] Starting sync for connection") % connection_id) connection.do_sync(add_to_changelog=add_to_changelog, only_username=False, load_users_func=load_users, save_users_func=save_users) job_interface.send_progress_update( _("[%s] Finished sync for connection") % connection_id) except Exception as e: job_interface.send_exception( _("[%s] Exception: %s") % (connection_id, e)) logger.error('Exception (%s, userdb_job): %s', connection_id, traceback.format_exc()) job_interface.send_progress_update(_("Finalizing synchronization")) general_userdb_job() return True
def do_sync(self, job_interface: background_job.BackgroundProcessInterface, add_to_changelog: bool, enforce_sync: bool, load_users_func: Callable, save_users_func: Callable) -> None: job_interface.send_progress_update(_("Synchronization started...")) if self._execute_sync_action(job_interface, add_to_changelog, enforce_sync, load_users_func, save_users_func): job_interface.send_result_message(_("The user synchronization completed successfully.")) else: job_interface.send_exception(_("The user synchronization failed."))