def perform_backup(): dbpath = get_dbpath() bpath = get_backup_path() try: btime = backup(dbpath, bpath) logging.debug('Database backup took %s seconds', btime) except AssertionError as err: # Translators, error message displayed if database backup fails base_msg = _('Database backup could not be completed. ' 'The following error occurred:') message = ' '.join(map(unicode, [base_msg, err.message])) status = 'error' url = i18n_url('dashboard:main') # Translators, redirection target if database backup was successful target = _('Dashboard') else: # Translators, message displayed if database backup was successful base_msg = _('Database backup has been completed successfully.') took_msg = lazy_ngettext('The operation took %s second', 'The operation took %s seconds', btime) % round(btime, 2) message = ' '.join(map(unicode, [base_msg, took_msg])) status = 'success' url = get_file_url() # Translators, redirection target if database backup was successful target = _('the backup folder') # Translators, used as page title title = _('Database backup') return dict(status=status, page_title=title, message=message, redirect_url=url, redirect_target=target)
def perform_backup(): dbpath = get_dbpath() bpath = get_backup_path() try: btime = backup(dbpath, bpath) logging.debug('Database backup took %s seconds', btime) except AssertionError as err: # Translators, error message displayed if database backup fails base_msg = _('Database backup could not be completed. ' 'The following error occurred:') message = ' '.join(map(unicode, [base_msg, err.message])) status = 'error' url = i18n_url('dashboard:main') # Translators, redirection target if database backup was successful target = _('Dashboard') else: # Translators, message displayed if database backup was successful base_msg = _('Database backup has been completed successfully.') took_msg = lazy_ngettext('The operation took {time} second', 'The operation took {time} seconds', btime).format(time=round(btime, 2)) message = ' '.join(map(unicode, [base_msg, took_msg])) status = 'success' url = get_file_url() # Translators, redirection target if database backup was successful target = _('the backup folder') # Translators, used as page title title = _('Database backup') return dict(status=status, page_title=title, message=message, redirect_url=url, redirect_target=target)
def delete(file_list): spooldir = request.app.config['content.spooldir'] removed_count = downloads.remove_downloads(spooldir, content_ids=file_list) # Translators, used as confirmation title after the chosen updates were # deleted on the updates page title = _("Updates deleted") # Translators, used as confirmation message after the chosen updates were # deleted on the updates page message = lazy_ngettext("An update has been deleted.", "{update_count} updates have been deleted.", removed_count).format(update_count=removed_count) return dict(page_title=title, message=message, redirect_url=i18n_url('downloads:list'), redirect_target=_("Updates"))
def add(file_list): archive = open_archive() added_count = archive.add_to_archive(file_list) notify_content_added(file_list) # Translators, used as confirmation title after the chosen updates were # successfully added to the library title = _("Updates added") # Translators, used as confirmation message after the chosen updates were # successfully added to the library message = lazy_ngettext( "An update has been added to the Library.", "{update_count} updates have been added to the Library.", added_count ).format(update_count=added_count) return dict(page_title=title, message=message, redirect_url=i18n_url('downloads:list'), redirect_target=_("Updates"))
def perform_rebuild(): try: rtime = rebuild() except Exception: logging.debug('DBMANAGE: Global lock could not be acquired') # Translators, error message displayed if database rebuild fails base_msg = _('Database could not be rebuilt. ' 'The following error occurred:') # Translators, error message displayed when locking fails during # database rebuild reason = _('Librarian could not enter maintenance mode and ' 'database rebuild was cancelled. Please make ' 'sure noone else is using Librarian and ' 'try again.') message = ' '.join(map(unicode, [base_msg, reason])) status = 'error' url = i18n_url('dashboard:main') # Translators, redirection target if database backup was successful target = _('Dashboard') else: # Translators, message displayed if database backup was successful base_msg = _('Content database has been rebuilt from scratch. A backup' ' copy of the original database has been created. ' 'You will find it in the files section.') # Translators, message displayed if database backup was successful took_msg = lazy_ngettext('The operation took %s second', 'The operation took %s seconds', rtime) % round(rtime, 2) message = ' '.join(map(unicode, [base_msg, took_msg])) # Translators, message displayed if database backup was successful status = 'success' url = i18n_url('content:list') # Translators, redirection target if database backup was successful target = _('Library') # Translators, used as page title title = _('Database rebuild') return dict(status=status, page_title=title, message=message, redirect_url=url, redirect_target=target)
def perform_rebuild(): try: rtime = rebuild() except LockFailureError: logging.debug('DBMANAGE: Global lock could not be acquired') # Translators, error message displayed if database rebuild fails base_msg = _('Database could not be rebuilt. ' 'The following error occurred:') # Translators, error message displayed when locking fails during # database rebuild reason = _('Librarian could not enter maintenance mode and ' 'database rebuild was cancelled. Please make ' 'sure noone else is using Librarian and ' 'try again.') message = ' '.join(map(unicode, [base_msg, reason])) status = 'error' url = i18n_url('dashboard:main') # Translators, redirection target if database backup was successful target = _('Dashboard') else: # Translators, message displayed if database backup was successful base_msg = _('Content database has been rebuilt from scratch. A backup' ' copy of the original database has been created. ' 'You will find it in the files section.') # Translators, message displayed if database backup was successful took_msg = lazy_ngettext('The operation took {time} second', 'The operation took {time} seconds', rtime).format(time=round(rtime, 2)) message = ' '.join(map(unicode, [base_msg, took_msg])) # Translators, message displayed if database backup was successful status = 'success' url = i18n_url(request.app.config['app.default_route']) # Translators, redirection target if database backup was successful target = _('Library') # Translators, used as page title title = _('Database rebuild') return dict(status=status, page_title=title, message=message, redirect_url=url, redirect_target=target)