Exemple #1
0
def import_repository(task_id, user_initiated=False):
    LOG.info(u"Starting task: {:d}".format(int(task_id)))

    try:
        import_task = models.ImportTask.objects.get(id=task_id)
    except models.ImportTask.DoesNotExist:
        LOG.error(u"Failed to get task id: {:d}".format(int(task_id)))
        raise

    import_task.start()

    logger = logging.getLogger('galaxy.worker.tasks.import_repository')
    logger = logutils.ImportTaskAdapter(logger, task=import_task)

    try:
        _import_repository(import_task, logger)
        user_notifications.repo_import.delay(import_task.id, user_initiated)
    except exc.LegacyTaskError as e:
        user_notifications.repo_import.delay(
            import_task.id,
            user_initiated,
            has_failed=True
        )
        import_task.finish_failed(
            reason='Task "{}" failed: {}'.format(import_task.id, str(e)))
    except Exception as e:
        user_notifications.repo_import.delay(
            import_task.id,
            user_initiated,
            has_failed=True
        )
        LOG.exception(e)
        import_task.finish_failed(
            reason='Task "{}" failed: {}'.format(import_task.id, str(e)))
        raise
Exemple #2
0
def _get_task_logger(task):
    logger = logging.getLogger('galaxy.worker.tasks.import_collection')
    return logutils.ImportTaskAdapter(logger, task=task)