Exemplo n.º 1
0
def job_view(request, uid):
    '''
    Views the state of a single job.
    '''
    job = Job.objects.filter(uid=uid).first()
    project = job.project

    stdout = job.stdout_log
    stderr = job.stderr_log
    if job.is_running():
        # Pass the most current stderr and stdout
        stdout_path = os.path.join(job.path, settings.JOB_STDOUT)
        stderr_path = os.path.join(job.path, settings.JOB_STDERR)
        stdout = open(stdout_path, 'r').read()
        stderr = open(stderr_path, 'r').read()

    paths = auth.listing(root=job.get_data_dir())
    context = dict(job=job,
                   project=project,
                   stderr=stderr,
                   stdout=stdout,
                   uid=job.uid,
                   show_all=True,
                   activate='View Result',
                   paths=paths,
                   serve_view="job_serve")

    counts = get_counts(project)
    context.update(counts)

    return render(request, "job_view.html", context=context)
Exemplo n.º 2
0
def import_files(request, path=""):
    """
    Import files mounted on IMPORT_ROOT_DIR in settings
    """
    user = request.user
    if not user.profile.trusted:
        messages.error(request, 'Only trusted users may views this page.')
        return redirect(reverse('project_list'))

    root = settings.IMPORT_ROOT_DIR
    path = os.path.abspath(os.path.join(root, path))
    if not path.startswith(root):
        messages.error(request, 'Outside root directory')
        path = ''

    if not os.path.exists(path):
        messages.error(request, 'File path does not exist')
        path = ''

    # Set the current node we are traversing.
    node = path if os.path.isdir(path) else None

    # Walk through the /root/node/ and collect paths.
    # Directories are not walked through because show_all=False.
    paths = auth.listing(root=root, node=node, show_all=False)

    context = dict(paths=paths, active="import", show_all=False)

    return render(request, 'import_files.html', context=context)
Exemplo n.º 3
0
def data_view(request, uid):
    "Show information specific to each data."

    data = Data.objects.filter(uid=uid).first()
    project = data.project
    paths = auth.listing(root=data.get_data_dir())

    context = dict(data=data, project=project, paths=paths, serve_view="data_serve",
                   activate='Selected Data', uid=data.uid, show_all=True)
    counts = get_counts(project)
    context.update(counts)

    return render(request, "data_view.html", context)
Exemplo n.º 4
0
def files_list(context, rel_path):
    # Limit to the first 100 files.
    root = os.path.abspath(os.path.join(settings.IMPORT_ROOT_DIR, rel_path))
    paths = auth.listing(root=root)
    user = context['request'].user
    return dict(paths=paths, user=user, root=root)