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)
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
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)
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)
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)
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
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)
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)
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)
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)
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)
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)
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
def index(): user = userManager.getUser() if user is not None: return render_template("home.html", user=user) return render_template("home.html")
def createPlugin(): user = userManager.getUser() provider = userManager.getOAuthProvider() return render_template("createPlugin.html", user=user, provider=provider)
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
def index(): user = userManager.getUser() if user is not None: return render_template("home.html", user=user) return render_template("home.html")
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
def upload(): user = userManager.getUser() return render_template("upload.html", user=user, uploaded=None)
def upload(): user = userManager.getUser() return render_template("upload.html", user=user, uploaded=None)
def decorated_function(*args, **kwargs): user = userManager.getUser() if user is None: return redirect(url_for('login', next=request.url)) return f(*args, **kwargs)
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
def getInfo(): user = userManager.getUser() if user is not None: return render_template('whatIsOFX.html', user=user) return render_template('whatIsOFX.html', user=user)
def getInfo(): user = userManager.getUser() if user is not None: return render_template('whatIsOFX.html', user=user) return render_template('whatIsOFX.html', user=user)
def searchPlugins(): user = userManager.getUser() resp = requests.get(config.catalogRootUri + "/plugin", params=request.args) return render_template('plugins.html', dico=resp.json(), user=user)
def createPlugin(): user = userManager.getUser() provider = userManager.getOAuthProvider() return render_template("createPlugin.html", user=user, provider=provider)
def searchPlugins(): user = userManager.getUser() resp = requests.get(config.catalogRootUri+"/plugin", params=request.args) return render_template('plugins.html', dico=resp.json(), user=user)
def decorated_function(*args, **kwargs): user = userManager.getUser() if user is None: return redirect(url_for('login', next=request.url)) return f(*args, **kwargs)