mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
[ZEPPELIN-502] Indent as pep8 convention
This commit is contained in:
parent
9bdb192812
commit
60d2956d2e
1 changed files with 52 additions and 46 deletions
|
|
@ -13,69 +13,75 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#PYTHON 2 / 3 comptability :
|
||||
# PYTHON 2 / 3 comptability :
|
||||
# bootstrap.py must be runnable with Python 2 and 3
|
||||
|
||||
#Remove interactive mode displayhook
|
||||
# Remove interactive mode displayhook
|
||||
import sys
|
||||
import signal
|
||||
try:
|
||||
import StringIO as io
|
||||
except ImportError:
|
||||
import io as io
|
||||
|
||||
sys.displayhook = lambda x: None
|
||||
|
||||
|
||||
# Set the signal handler
|
||||
import signal
|
||||
def intHandler(signum, frame):
|
||||
print ("Paragraph interrupted")
|
||||
raise KeyboardInterrupt()
|
||||
def intHandler(signum, frame): # Set the signal handler
|
||||
print ("Paragraph interrupted")
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
signal.signal(signal.SIGINT, intHandler)
|
||||
|
||||
|
||||
|
||||
def help():
|
||||
print ('%html')
|
||||
print ('<h2>Python Interpreter help</h2>')
|
||||
print ('<h3>Python 2 & 3 comptability</h3>')
|
||||
print ('<div>The interpreter is compatible with Python 2 & 3.<br/> To change Python version, change in the interpreter configuration the python.path to the desired version (example : python.path=/usr/bin/python3)</div>')
|
||||
print ('<h3>Python modules</h3>')
|
||||
print ('<div>The interpreter can use all modules already installed (with pip, easy_install etc) </div>')
|
||||
print ('<h3>Forms</h3>')
|
||||
print ('<h4>Input form</h4>')
|
||||
print ('<pre> print "${input_form(name)=defaultValue}"</pre>')
|
||||
print ('<h4>Selection form</h4>')
|
||||
print ('<pre> print "${select_form(Selection Form)=op1,op1|op2(Option 2)|op3}"</pre>')
|
||||
print ('<h4>Checkbox form</h4>')
|
||||
print ('<pre> print "${checkbox:checkbox_form=op1,op1|op2|op3}"</pre>')
|
||||
print ('<h3>Matplotlib graph</h3>')
|
||||
print ('<div>The interpreter can display matplotlib graph with the function zeppelin_show()</div>')
|
||||
print ('<div> You need to already have matplotlib module installed to use this functionality !</div><br/>')
|
||||
print ('''<pre>import matplotlib.pyplot as plt
|
||||
print ('%html')
|
||||
print ('<h2>Python Interpreter help</h2>')
|
||||
print ('<h3>Python 2 & 3 comptability</h3>')
|
||||
print ('<p>The interpreter is compatible with Python 2 & 3.<br/>')
|
||||
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)</p>')
|
||||
print ('<h3>Python modules</h3>')
|
||||
print ('<p>The interpreter can use all modules already installed ')
|
||||
print ('(with pip, easy_install, etc)</p>')
|
||||
print ('<h3>Forms</h3>')
|
||||
print ('<h4>Input form</h4>')
|
||||
print ('<pre> print "${input_form(name)=defaultValue}"</pre>')
|
||||
print ('<h4>Selection form</h4>')
|
||||
print ('<pre> print "${select_form(Selection Form)=o1,o1|o2}"</pre>')
|
||||
print ('<h4>Checkbox form</h4>')
|
||||
print ('<pre> print "${checkbox:checkbox_form=o1,o1|o3}"</pre>')
|
||||
print ('<h3>Matplotlib graph</h3>')
|
||||
print ('<div>The interpreter can display matplotlib graph with ')
|
||||
print ('the function zeppelin_show()</div>')
|
||||
print ('<div> You need to already have matplotlib module installed ')
|
||||
print ('to use this functionality !</div><br/>')
|
||||
print ('''<pre>import matplotlib.pyplot as plt
|
||||
plt.figure()
|
||||
(.. ..)
|
||||
zeppelin_show(plt)
|
||||
plt.close()
|
||||
</pre>''')
|
||||
print ('<div><br/> zeppelin_show function can take optional parameters to adapt graph width and height</div>')
|
||||
print ("<div><b>example </b>:")
|
||||
print('''<pre>zeppelin_show(plt,width='50px')
|
||||
zeppelin_show(plt,height='150px') </pre></div>''')
|
||||
print ('<div><br/> zeppelin_show function can take optional parameters ')
|
||||
print ('to adapt graph width and height</div>')
|
||||
print ("<div><b>example </b>:")
|
||||
print('''<pre>zeppelin_show(plt,width='50px')
|
||||
zeppelin_show(plt,height='150px') </pre></div>''')
|
||||
|
||||
|
||||
#Matplotlib show function
|
||||
try:
|
||||
import StringIO as io
|
||||
except ImportError:
|
||||
import io as io
|
||||
# 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 <div style='"+ style +"'>" + img.read() +"<div>")
|
||||
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 <div style='" + style + "'>" + img.read() + "<div>")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue