# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # PYTHON 2 / 3 comptability : # bootstrap.py must be runnable with Python 2 and 3 # Remove interactive mode displayhook import sys import signal try: import StringIO as io except ImportError: import io as io sys.displayhook = lambda x: None def intHandler(signum, frame): # Set the signal handler print ("Paragraph interrupted") raise KeyboardInterrupt() signal.signal(signal.SIGINT, intHandler) def help(): print ('%html') print ('

Python Interpreter help

') print ('

Python 2 & 3 comptability

') print ('

The interpreter is compatible with Python 2 & 3.
') print ('To change Python version, ') print ('change in the interpreter configuration the python.path to the ') print ('desired version (example : python.path=/usr/bin/python3)

') print ('

Python modules

') print ('

The interpreter can use all modules already installed ') print ('(with pip, easy_install, etc)

') print ('

Forms

') print ('

Input form

') print ('
 print "${input_form(name)=defaultValue}"
') print ('

Selection form

') print ('
 print "${select_form(Selection Form)=o1,o1|o2}"
') print ('

Checkbox form

') print ('
 print "${checkbox:checkbox_form=o1,o1|o3}"
') print ('

Matplotlib graph

') print ('
The interpreter can display matplotlib graph with ') print ('the function zeppelin_show()
') print ('
You need to already have matplotlib module installed ') print ('to use this functionality !

') print ('''
import matplotlib.pyplot as plt
plt.figure()
(.. ..)
zeppelin_show(plt)
plt.close()
''') print ('

zeppelin_show function can take optional parameters ') print ('to adapt graph width and height
') print ("
example :") print('''
zeppelin_show(plt,width='50px')
zeppelin_show(plt,height='150px') 
''') # Matplotlib show function def zeppelin_show(p, width="0", height="0"): img = io.StringIO() p.savefig(img, format='svg') img.seek(0) style = "" if(width != "0"): style += 'width:'+width if(height != "0"): if(len(style) != 0): style += "," style += 'height:'+height print("%html
" + img.read() + "
")