Beispiel #1
0
def file_browser(username, root_wf_id, wf_id):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        if os.path.isdir(submit_dir):
            init_file = request.args.get("init_file", None)
            return render_template(
                "file-browser.html",
                root_wf_id=root_wf_id,
                wf_id=wf_id,
                init_file=init_file,
            )
        else:
            raise ServiceError(
                ErrorResponse(
                    "SUBMIT_DIR_NOT_FOUND",
                    "%r is not a valid directory" % str(submit_dir),
                )
            )

    except NoResultFound:
        return render_template("error/workflow/workflow_details_missing.html")

    return "Error", 500
Beispiel #2
0
def file_list(username, root_wf_id, wf_id, path=""):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        if os.path.isdir(submit_dir):
            dest = os.path.join(submit_dir, path)

            if os.path.isfile(dest):
                return "", 204

            folders = {"dirs": [], "files": []}

            for entry in os.listdir(dest):
                if os.path.isdir(os.path.join(dest, entry)):
                    folders["dirs"].append(os.path.normpath(os.path.join(path, entry)))
                else:
                    folders["files"].append(os.path.normpath(os.path.join(path, entry)))

            return serialize(folders), 200, {"Content-Type": "application/json"}

        else:
            raise ServiceError(
                ErrorResponse(
                    "SUBMIT_DIR_NOT_FOUND",
                    "%r is not a valid directory" % str(submit_dir),
                )
            )

    except NoResultFound:
        return render_template("error/workflow/workflow_details_missing.html")

    return "Error", 500
Beispiel #3
0
def file_list(username, root_wf_id, wf_id, path=""):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        if os.path.isdir(submit_dir):
            dest = os.path.join(submit_dir, path)

            if os.path.isfile(dest):
                return "", 204

            folders = {"dirs": [], "files": []}

            for entry in os.listdir(dest):
                if os.path.isdir(os.path.join(dest, entry)):
                    folders["dirs"].append(os.path.normpath(os.path.join(path, entry)))
                else:
                    folders["files"].append(os.path.normpath(os.path.join(path, entry)))

            return json.dumps(folders), 200, {"Content-Type": "application/json"}

        else:
            raise ServiceError(ErrorResponse("SUBMIT_DIR_NOT_FOUND", "%r is not a valid directory" % str(submit_dir)))

    except NoResultFound:
        return render_template("error/workflow/workflow_details_missing.html")

    return "Error", 500
Beispiel #4
0
def file_list(username, root_wf_id, wf_id):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        if os.path.isdir(submit_dir):
            folders = {}

            for folder, sub_folders, files in os.walk(submit_dir):
                folder = '/' + folder.replace(submit_dir, '', 1).lstrip('/')
                folders[folder] = {'D': [], 'F': files}

                for sub_folder in sub_folders:
                    full_sub_folder = os.path.normpath(os.path.join(folder, sub_folder))
                    folders[folder]['D'].append(full_sub_folder)

            return json.dumps(folders), 200, {'Content-Type': 'application/json'}

        else:
            raise ServiceError(ErrorResponse('SUBMIT_DIR_NOT_FOUND', '%r is not a valid directory' % str(submit_dir)))

    except NoResultFound:
        return render_template('error/workflow/workflow_details_missing.html')

    return 'Error', 500
Beispiel #5
0
def file_list(username, root_wf_id, wf_id, path=''):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        if os.path.isdir(submit_dir):
            dest = os.path.join(submit_dir, path)

            if os.path.isfile(dest):
                return '', 204

            folders = {
                'dirs': [],
                'files': []
            }

            for entry in os.listdir(dest):
                if os.path.isdir(os.path.join(dest, entry)):
                    folders['dirs'].append(os.path.normpath(os.path.join(path, entry)))
                else:
                    folders['files'].append(os.path.normpath(os.path.join(path, entry)))

            return json.dumps(folders), 200, {'Content-Type': 'application/json'}

        else:
            raise ServiceError(ErrorResponse('SUBMIT_DIR_NOT_FOUND', '%r is not a valid directory' % str(submit_dir)))

    except NoResultFound:
        return render_template('error/workflow/workflow_details_missing.html')

    return 'Error', 500
Beispiel #6
0
def file_browser(username, root_wf_id, wf_id):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        if os.path.isdir(submit_dir):
            init_file = request.args.get('init_file', None)
            return render_template(
                'file-browser.html',
                root_wf_id=root_wf_id,
                wf_id=wf_id,
                init_file=init_file
            )
        else:
            raise ServiceError(
                ErrorResponse(
                    'SUBMIT_DIR_NOT_FOUND',
                    '%r is not a valid directory' % str(submit_dir)
                )
            )

    except NoResultFound:
        return render_template('error/workflow/workflow_details_missing.html')

    return 'Error', 500
Beispiel #7
0
def file_list(username, root_wf_id, wf_id):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        if os.path.isdir(submit_dir):
            folders = {}

            for folder, sub_folders, files in os.walk(submit_dir):
                folder = '/' + folder.replace(submit_dir, '', 1).lstrip('/')
                folders[folder] = {'D': [], 'F': files}

                for sub_folder in sub_folders:
                    full_sub_folder = os.path.normpath(
                        os.path.join(folder, sub_folder))
                    folders[folder]['D'].append(full_sub_folder)

            return json.dumps(folders), 200, {
                'Content-Type': 'application/json'
            }

        else:
            raise ServiceError(
                ErrorResponse('SUBMIT_DIR_NOT_FOUND',
                              '%r is not a valid directory' % str(submit_dir)))

    except NoResultFound:
        return render_template('error/workflow/workflow_details_missing.html')

    return 'Error', 500
Beispiel #8
0
def file_browser(username, root_wf_id, wf_id):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        if os.path.isdir(submit_dir):
            init_file = request.args.get('init_file', None)
            return render_template('file-browser.html', root_wf_id=root_wf_id, wf_id=wf_id, init_file=init_file)

    except NoResultFound:
        return render_template('error/workflow/workflow_details_missing.html')

    return 'Error', 500
Beispiel #9
0
def file_view(username, root_wf_id, wf_id, path):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        file_path = os.path.join(submit_dir, path)
        if not os.path.isfile(file_path):
            return "File not found", 404

        return send_from_directory(submit_dir, path)
    except NoResultFound:
        return render_template("error/workflow/workflow_details_missing.html")

    return "Error", 500
Beispiel #10
0
def file_view(username, root_wf_id, wf_id, path):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        file_path = os.path.join(submit_dir, path)
        if not os.path.isfile(file_path):
            return "File not found", 404

        return send_from_directory(submit_dir, path)
    except NoResultFound:
        return render_template("error/workflow/workflow_details_missing.html")

    return "Error", 500
Beispiel #11
0
def file_list(username, root_wf_id, wf_id, path=''):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        if os.path.isdir(submit_dir):
            dest = os.path.join(submit_dir, path)

            if os.path.isfile(dest):
                return '', 204

            folders = {'dirs': [], 'files': []}

            for entry in os.listdir(dest):
                if os.path.isdir(os.path.join(dest, entry)):
                    folders['dirs'].append(
                        os.path.normpath(os.path.join(path, entry))
                    )
                else:
                    folders['files'].append(
                        os.path.normpath(os.path.join(path, entry))
                    )

            return json.dumps(folders), 200, {
                'Content-Type': 'application/json'
            }

        else:
            raise ServiceError(
                ErrorResponse(
                    'SUBMIT_DIR_NOT_FOUND',
                    '%r is not a valid directory' % str(submit_dir)
                )
            )

    except NoResultFound:
        return render_template('error/workflow/workflow_details_missing.html')

    return 'Error', 500
Beispiel #12
0
def file_list(username, root_wf_id, wf_id):
    try:
        dashboard = Dashboard(g.master_db_url, root_wf_id, wf_id=wf_id)
        details = dashboard.get_workflow_details(wf_id)
        submit_dir = details.submit_dir

        if os.path.isdir(submit_dir):
            folders = {}

            for folder, sub_folders, files in os.walk(submit_dir):
                folder = '/' + folder.replace(submit_dir, '', 1).lstrip('/')
                folders[folder] = {'D': [], 'F': files}

                for sub_folder in sub_folders:
                    full_sub_folder = folder + sub_folder
                    folders[folder]['D'].append(full_sub_folder)

            return json.dumps(folders), 200, {'Content-Type': 'application/json'}

    except NoResultFound:
        return render_template('error/workflow/workflow_details_missing.html')

    return 'Error', 500