def generate_context(config):
    """Creates the Flask app context and initializes any extensions such as Celery, Redis, SQLAlchemy, etc.

    Positional arguments:
    config -- partial Flask config dict from generate_config().

    Returns:
    The Flask app instance.
    """
    flask_app = Flask(__name__)
    flask_app.config.update(config)
    flask_app.config["TESTING"] = True
    flask_app.config["CELERY_ACCEPT_CONTENT"] = ["pickle"]

    if "SQLALCHEMY_DATABASE_URI" in flask_app.config:
        db = SQLAlchemy(flask_app)
        db.engine.execute("DROP TABLE IF EXISTS celery_tasksetmeta;")
    elif "REDIS_URL" in flask_app.config:
        redis = Redis(flask_app)
        redis.flushdb()

    Celery(flask_app)
    return flask_app
from urlparse import urlparse, urldefrag

from celery import Celery
from cwltool.load_tool import fetch_document, validate_document
from flask import Flask, render_template, request, redirect, jsonify, url_for
import easywebdav
import magic
import minio
import ruamel.yaml as yaml
from swiftclient.service import SwiftService, SwiftUploadObject

app = Flask(__name__)
app.config.from_pyfile("settings.cfg")
app.config["CELERY_TRACK_STARTED"] = True
app.config["CELERY_TASK_SERIALIZER"] = "json"
app.config["CELERY_ACCEPT_CONTENT"] = ["json"]
app.config["CELERY_RESULT_SERIALIZER"] = "json"

celery = Celery(app.name, broker=app.config["CELERY_BROKER_URL"])
celery.conf.update(app.config)

logger = logging.getLogger("onebuttoncompute")


class WebDAVClient(object):
    def __init__(self, root, username, password):
        self.root = root
        o = urlparse(root)
        logging.warning(o)
        logging.warning(o.path)
        self.path = o.path