def import_suggestions(store): try: logging.info(u"Importing suggestions for %s if any.", store.real_path) store.import_pending() try: count = store.has_suggestions() except: count = store.get_suggestion_count() if count: text = u""" <li>%s</li> """ % ungettext('Imported %(count)d suggestion from %(store)s', 'Imported %(count)d suggestions from %(store)s', count, { 'count': count, 'store': store.pootle_path }) else: text = "" except: text = u""" <li class="error">%s</li> """ % _('Failed to import suggestions from %s', store.pootle_path) return text
def rq_stats(): queue = get_queue() failed_queue = get_failed_queue() try: workers = Worker.all(queue.connection) except ConnectionError: return None num_workers = len(workers) is_running = len(queue.connection.smembers(Worker.redis_workers_keys)) > 0 if is_running: # Translators: this refers to the status of the background job worker status_msg = ungettext('Running (%d worker)', 'Running (%d workers)', num_workers) % num_workers else: # Translators: this refers to the status of the background job worker status_msg = _('Stopped') result = { 'job_count': queue.count, 'failed_job_count': failed_queue.count, 'is_running': is_running, 'status_msg': status_msg, } return result
def parse_store(store): try: logging.info(u"Importing units from %s", store.real_path) store.require_units() count = store.getquickstats()['total'] text = u""" <li>%s</li> """ % ungettext('Imported %(count)d unit from %(store)s', 'Imported %(count)d units from %(store)s', count, {'count': count, 'store': store.pootle_path}) except: text = u""" <li class="error">%s</li> """ % _('Failed to import units from %s', store.pootle_path) return text
def import_suggestions(store): try: logging.info(u"Importing suggestions for %s if any.", store.real_path) store.import_pending() count = store.has_suggestions() if count: text = u""" <li>%s</li> """ % ungettext('Imported %(count)d suggestion from %(store)s', 'Imported %(count)d suggestions from %(store)s', count, {'count': count, 'store': store.pootle_path}) else: text = "" except: text = u""" <li class="error">%s</li> """ % _('Failed to import suggestions from %s', store.pootle_path) return text
def parse_store(store): try: logging.info(u"Importing units from %s", store.real_path) store.require_units() count = store.getquickstats()["total"] text = u""" <li>%s</li> """ % ungettext( "Imported %(count)d unit from %(store)s", "Imported %(count)d units from %(store)s", count, {"count": count, "store": store.pootle_path}, ) except: text = u""" <li class="error">%s</li> """ % _( "Failed to import units from %s", store.pootle_path ) return text