Commit 7bd79e3d authored by Ayush Tiwari's avatar Ayush Tiwari

Removed hardcoded url for ERP5Kernel jinja file and moved to the instance file

parent d21fc169
......@@ -133,9 +133,11 @@ monitor_url = $${monitor-parameters:url}
recipe = slapos.recipe.template:jinja2
template = ${erp5-kernel:location}/${erp5-kernel:filename}
rendered = $${directory:erp5_kernel_dir}/ERP5kernel.py
erp5_url = https://softinst60318.host.vifib.net/erp5/Base_executePython
mode = 0744
context =
raw python_executable ${buildout:bin-directory}/pythonwitheggs
key erp5_url :erp5_url
[kernel-json]
recipe = slapos.recipe.template:jinja2
......
......@@ -55,7 +55,7 @@ output = ${buildout:directory}/instance.cfg
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/${:filename}
download-only = true
md5sum = c74ced2f5e20f5509a3aca8d00952499
md5sum = 0e9c5070725c3a10125a9b658bd4eb5c
destination = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = ERP5kernel.py.jinja
mode = 0644
......
#!{{python_executable}}
#!{{ python_executable }}
from IPython.kernel.zmq.kernelbase import Kernel
from IPython.core.display import HTML
......@@ -6,6 +6,8 @@ from IPython.core.display import HTML
import requests
import logging
global erp5_url = "{{ erp5_url }}"
class ERP5Kernel(Kernel):
implementation = 'ERP5'
implementation_version = '1.0'
......@@ -14,11 +16,12 @@ class ERP5Kernel(Kernel):
language_info = {'mimetype': 'text/plain', 'name':'python'}
banner = "ERP5 integration with ipython notebook"
def __init__(self, user=None, pwd=None, url=None, status_code=None, *args, **kwargs):
def __init__(self, user=None, pwd=None, url=None, status_code=None,
*args, **kwargs):
super(ERP5Kernel, self).__init__(*args, **kwargs)
self.user = user
self.pwd = pwd
self.url = url
self.url = erp5_url
self.status_code = status_code
def do_execute(self, code, silent, store_history=True, user_expressions=None,
......@@ -33,11 +36,10 @@ class ERP5Kernel(Kernel):
elif code.startswith('%erp5_password'):
self.pwd = code.split()[1]
self.url = 'softinst60318.host.vifib.net/erp5/manage_main'
if self.user:
url = 'https://%s:%s@%s' %(self.user, self.pwd, self.url)
try:
res = requests.get(url, verify=False)
res = requests.get(self.url, verify=False,
auth=(self.user, self.pwd))
self.status_code = res.status_code
if self.status_code != 200:
resp = 'Incorrect username or password'
......@@ -52,8 +54,9 @@ class ERP5Kernel(Kernel):
else:
if self.status_code == 200:
url = 'https://%s:%s@softinst60318.host.vifib.net/erp5/data_set_module/wendelin_1/Base_executePython' %(self.user, self.pwd)
res = requests.get(url, verify=False, params={'python_expression': code})
res = requests.get(self.url, verify=False,
auth=(self.user, self.pwd),
params={'python_expression': code})
code_result = res.text
else:
......@@ -76,4 +79,4 @@ if __name__ == '__main__':
from IPython.kernel.zmq.kernelapp import IPKernelApp
IPKernelApp.launch_instance(kernel_class=ERP5Kernel)
else:
from IPython.kernel.zmq.kernelapp import IPKernelApp
from IPython.kernel.zmq.kernelapp import IPKernelApp
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment