Ejemplo n.º 1
0
def renderPageWithPlugin(pluginRawIdentifier, pluginVersion="latest"):
    user = userManager.getUser()

    if pluginVersion is "latest":
        resp = requests.get(config.catalogRootUri + "/plugin/" +
                            pluginRawIdentifier)
    #if resp.status_code == 404:
    #return redirect(url_for('notFoundPage', pluginRawIdentifier=pluginRawIdentifier))
    else:
        resp = requests.get(config.catalogRootUri + "/plugin/" +
                            pluginRawIdentifier + "/version/" + pluginVersion)
        if resp.status_code == 404:
            return redirect(
                url_for('getPlugin', pluginRawIdentifier=pluginRawIdentifier))

    if resp.status_code != 200:
        abort(resp.status_code)
    previewGallery = requests.get(config.renderRootUri + '/resource/').json()

    if pluginRawIdentifier == 'tuttle.ctl':
        return render_template('scriptEditor.html',
                               plugin=resp.json(),
                               user=user,
                               resources=previewGallery)

    return render_template('editor.html',
                           plugin=resp.json()['plugin'],
                           versions=resp.json()['versions'],
                           user=user,
                           resources=previewGallery)
Ejemplo n.º 2
0
def setWiki(pluginId, pluginVersion="latest"):
    user = userManager.getUser()
    header = {'content-type': 'application/json'}
    req = requests.post(config.catalogRootUri + "/wiki/update/" + pluginId,
                        data=request.data,
                        headers=header)
    return req.content
Ejemplo n.º 3
0
def downloadPluginTemplate():
    pluginTemplatePath = ''
    try:
        pluginTemplatePath = downloadPluginTemplateRepo(True)

        shutil.make_archive(pluginTemplatePath, 'zip', pluginTemplatePath)
        # Delete cloned repo
        shutil.rmtree(pluginTemplatePath)

        return send_file(pluginTemplatePath + '.zip',
                         as_attachment=True,
                         attachment_filename="OpenFX_plugin_template.zip")
    except CalledProcessError:
        user = userManager.getUser()
        provider = userManager.getOAuthProvider()
        status = 'error'
        message = 'There was an error creating your customized plugin, please try again.'

        # Ensure to clean even if the process has failed
        if os.path.isdir(pluginTemplatePath):
            shutil.rmtree(pluginTemplatePath)

        return render_template("createPlugin.html",
                               user=user,
                               provider=provider,
                               status=status,
                               message=message)
Ejemplo n.º 4
0
def createUserRepo():
    user = userManager.getUser()
    provider = userManager.getOAuthProvider()
    githubToken = session['github_token'][0]
    if githubToken is None:
        status = 'error'
        message = 'You are trying to create a repository without being logged using Github.'

    pluginTemplatePath = ''
    try:
        pluginTemplatePath = downloadPluginTemplateRepo(False)
        pluginName = request.form['pluginName']
        #Create user's repo
        req = config.github.post('/user/repos',
                                 data={
                                     "name": pluginName,
                                     "private": False,
                                 },
                                 format='json')

        owner = req.data['owner']['login']

        # Enable Travis
        check_call(['travis', 'login', '--github-token',
                    str(githubToken)],
                   cwd=pluginTemplatePath)
        check_call(['travis', 'enable', '-r', owner + '/' + pluginName],
                   cwd=pluginTemplatePath)
        check_call([
            'travis', 'env', 'set', 'TOKEN',
            str(githubToken), '--private', '-r', owner + '/' + pluginName
        ])

        # Push on user's repo
        url = 'https://' + owner + ':' + session['github_token'][
            0] + '@github.com' + '/' + owner + '/' + pluginName + '.git'
        check_call(['git', 'remote', 'add', 'origin', url],
                   cwd=pluginTemplatePath)
        check_call(['git', 'remote', '-v'], cwd=pluginTemplatePath)
        check_call(['git', 'push', 'origin', 'master'], cwd=pluginTemplatePath)

        # Delete cloned repo
        shutil.rmtree(pluginTemplatePath)

        return render_template("createPluginSuccess.html",
                               userGithubAlias=owner,
                               repoName=request.form['pluginName'])
    except CalledProcessError:
        status = 'error'
        message = 'There was an error creating your repository, please try again.'
        # Ensure to clean even if the process has failed
        if os.path.isdir(pluginTemplatePath):
            shutil.rmtree(pluginTemplatePath)

        return render_template("createPlugin.html",
                               user=user,
                               provider=provider,
                               status=status,
                               message=message)
Ejemplo n.º 5
0
def getPlugins():
    user = userManager.getUser()
    try:
        resp = requests.get(config.catalogRootUri+"/plugin", params=request.args)
    except:
        return render_template('plugins.html', dico=None, user=user)

    return render_template('plugins.html', dico=resp.json(), user=user)
Ejemplo n.º 6
0
def addComment(pluginId, pluginVersion="latest"):
    user = userManager.getUser()
    header = {'content-type': 'application/json'}
    req = requests.post(config.catalogRootUri + "/plugin/" + pluginId +
                        "/comments/update",
                        data=request.data,
                        headers=header)
    return req.content
Ejemplo n.º 7
0
def getPlugins():
    user = userManager.getUser()
    try:
        resp = requests.get(config.catalogRootUri + "/plugin",
                            params=request.args)
    except:
        return render_template('plugins.html', dico=None, user=user)

    return render_template('plugins.html', dico=resp.json(), user=user)
Ejemplo n.º 8
0
def getPluginComments(pluginRawIdentifier, pluginVersion="latest"):
    user = userManager.getUser()
    if pluginVersion is "latest":
        resp = requests.get(config.catalogRootUri+"/plugin/"+pluginRawIdentifier)
    else:
        resp = requests.get(config.catalogRootUri+"/plugin/"+pluginRawIdentifier+"/version/"+pluginVersion)
        if resp.status_code == 404:
            return redirect(url_for('getPlugin', pluginRawIdentifier=pluginRawIdentifier))
    if resp.status_code != 200:
        if resp.status_code == 404:
            return render_template('notFound.html', user=user)
        abort(resp.status_code)
    return render_template('comments.html', plugin=resp.json()['plugin'], versions=resp.json()['versions'], user=user)
Ejemplo n.º 9
0
def createUserRepo():
    user = userManager.getUser()
    provider = userManager.getOAuthProvider()
    githubToken = session['github_token'][0]
    if githubToken is None:
        status = 'error'
        message = 'You are trying to create a repository without being logged using Github.'

    pluginTemplatePath = ''
    try:
        pluginTemplatePath = downloadPluginTemplateRepo(False)
        pluginName = request.form['pluginName']
        #Create user's repo
        req = config.github.post('/user/repos', data={
            "name": pluginName,
            "private": False,
        }, format='json')

        owner = req.data['owner']['login']

        # Enable Travis
        check_call(['travis', 'login', '--github-token', str(githubToken)], cwd=pluginTemplatePath)
        check_call(['travis', 'enable', '-r', owner +'/'+ pluginName ], cwd=pluginTemplatePath)
        check_call(['travis', 'env', 'set', 'TOKEN', str(githubToken), '--private', '-r', owner +'/'+ pluginName])

        # Push on user's repo
        url = 'https://' + owner + ':' + session['github_token'][0] + '@github.com' +'/'+ owner +'/'+ pluginName + '.git'
        check_call(['git', 'remote', 'add', 'origin', url], cwd=pluginTemplatePath)
        check_call(['git', 'remote', '-v'], cwd=pluginTemplatePath)
        check_call(['git', 'push', 'origin', 'master'], cwd=pluginTemplatePath)

        # Delete cloned repo
        shutil.rmtree(pluginTemplatePath)


        return render_template("createPluginSuccess.html", userGithubAlias=owner, repoName=request.form['pluginName'])
    except CalledProcessError:
        status = 'error'
        message = 'There was an error creating your repository, please try again.'
        # Ensure to clean even if the process has failed
        if os.path.isdir(pluginTemplatePath):
            shutil.rmtree(pluginTemplatePath)

        return render_template("createPlugin.html", user=user, provider=provider, status=status, message=message)
Ejemplo n.º 10
0
def getPluginComments(pluginRawIdentifier, pluginVersion="latest"):
    user = userManager.getUser()
    if pluginVersion is "latest":
        resp = requests.get(config.catalogRootUri + "/plugin/" +
                            pluginRawIdentifier)
    else:
        resp = requests.get(config.catalogRootUri + "/plugin/" +
                            pluginRawIdentifier + "/version/" + pluginVersion)
        if resp.status_code == 404:
            return redirect(
                url_for('getPlugin', pluginRawIdentifier=pluginRawIdentifier))
    if resp.status_code != 200:
        if resp.status_code == 404:
            return render_template('notFound.html', user=user)
        abort(resp.status_code)
    return render_template('comments.html',
                           plugin=resp.json()['plugin'],
                           versions=resp.json()['versions'],
                           user=user)
Ejemplo n.º 11
0
def renderPageWithPlugin(pluginRawIdentifier, pluginVersion="latest"):
    user = userManager.getUser()

    if pluginVersion is "latest":
        resp = requests.get(config.catalogRootUri+"/plugin/"+pluginRawIdentifier)
       #if resp.status_code == 404:
            #return redirect(url_for('notFoundPage', pluginRawIdentifier=pluginRawIdentifier))
    else:
        resp = requests.get(config.catalogRootUri+"/plugin/"+pluginRawIdentifier+"/version/"+pluginVersion)
        if resp.status_code == 404:
            return redirect(url_for('getPlugin', pluginRawIdentifier=pluginRawIdentifier))

    if resp.status_code != 200:
        abort(resp.status_code)
    previewGallery = requests.get(config.renderRootUri + '/resource/').json()

    if pluginRawIdentifier == 'tuttle.ctl':
        return render_template('scriptEditor.html', plugin=resp.json(), user=user, resources=previewGallery)

    return render_template('editor.html', plugin=resp.json()['plugin'], versions=resp.json()['versions'], user=user, resources=previewGallery)
Ejemplo n.º 12
0
def downloadPluginTemplate():
    pluginTemplatePath = ''
    try:
        pluginTemplatePath = downloadPluginTemplateRepo(True)

        shutil.make_archive(pluginTemplatePath, 'zip', pluginTemplatePath)
        # Delete cloned repo
        shutil.rmtree(pluginTemplatePath)

        return send_file(pluginTemplatePath + '.zip', as_attachment=True, attachment_filename="OpenFX_plugin_template.zip")
    except CalledProcessError:
        user = userManager.getUser()
        provider = userManager.getOAuthProvider()
        status = 'error'
        message = 'There was an error creating your customized plugin, please try again.'

        # Ensure to clean even if the process has failed
        if os.path.isdir(pluginTemplatePath):
            shutil.rmtree(pluginTemplatePath)

        return render_template("createPlugin.html", user=user, provider=provider, status=status, message=message)
Ejemplo n.º 13
0
def page_not_found(e):
    user = userManager.getUser()
    if user is not None:
        return render_template("notFound.html", user=user), 404
    return render_template("notFound.html"), 404
Ejemplo n.º 14
0
def index():
    user = userManager.getUser()
    if user is not None:
        return render_template("home.html", user=user)
    return render_template("home.html")
Ejemplo n.º 15
0
def createPlugin():
    user = userManager.getUser()
    provider = userManager.getOAuthProvider()
    return render_template("createPlugin.html", user=user, provider=provider)
Ejemplo n.º 16
0
def page_not_found(e):
    user = userManager.getUser()
    if user is not None:
        return render_template("notFound.html", user=user), 404
    return render_template("notFound.html"), 404
Ejemplo n.º 17
0
def index():
    user = userManager.getUser()
    if user is not None:
        return render_template("home.html", user=user)
    return render_template("home.html")
Ejemplo n.º 18
0
def addComment(pluginId, pluginVersion="latest"):
    user = userManager.getUser()
    header = {'content-type' : 'application/json'}
    req = requests.post(config.catalogRootUri + "/plugin/" + pluginId + "/comments/update", data=request.data, headers=header)
    return req.content
Ejemplo n.º 19
0
def upload():
    user = userManager.getUser()
    return render_template("upload.html", user=user, uploaded=None)
Ejemplo n.º 20
0
def upload():
    user = userManager.getUser()
    return render_template("upload.html", user=user, uploaded=None)
Ejemplo n.º 21
0
    def decorated_function(*args, **kwargs):

        user = userManager.getUser()
        if user is None:
            return redirect(url_for('login', next=request.url))
        return f(*args, **kwargs)
Ejemplo n.º 22
0
def setWiki(pluginId, pluginVersion="latest"):
    user = userManager.getUser()
    header = {'content-type' : 'application/json'}
    req = requests.post(config.catalogRootUri + "/wiki/update/" + pluginId, data=request.data, headers=header)
    return req.content
Ejemplo n.º 23
0
def getInfo():
    user = userManager.getUser()
    if user is not None:
        return render_template('whatIsOFX.html', user=user)
    return render_template('whatIsOFX.html', user=user)
Ejemplo n.º 24
0
def getInfo():
    user = userManager.getUser()
    if user is not None:
        return render_template('whatIsOFX.html', user=user)
    return render_template('whatIsOFX.html', user=user)
Ejemplo n.º 25
0
def searchPlugins():
    user = userManager.getUser()

    resp = requests.get(config.catalogRootUri + "/plugin", params=request.args)

    return render_template('plugins.html', dico=resp.json(), user=user)
Ejemplo n.º 26
0
def createPlugin():
    user = userManager.getUser()
    provider = userManager.getOAuthProvider()
    return render_template("createPlugin.html", user=user, provider=provider)
Ejemplo n.º 27
0
def searchPlugins():
    user = userManager.getUser()

    resp = requests.get(config.catalogRootUri+"/plugin", params=request.args)

    return render_template('plugins.html', dico=resp.json(), user=user)
Ejemplo n.º 28
0
    def decorated_function(*args, **kwargs):

        user = userManager.getUser()
        if user is None:
            return redirect(url_for('login', next=request.url))
        return f(*args, **kwargs)