mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Python: normalize newlines in python
This commit is contained in:
parent
58efcc98a4
commit
e84cd5c506
2 changed files with 6 additions and 10 deletions
|
|
@ -14,11 +14,12 @@
|
|||
# limitations under the License.
|
||||
|
||||
# PYTHON 2 / 3 comptability :
|
||||
# bootstrap.py must be runnable with Python 2 and 3
|
||||
# bootstrap.py must be runnable with Python 2 or 3
|
||||
|
||||
# Remove interactive mode displayhook
|
||||
import sys
|
||||
import signal
|
||||
|
||||
try:
|
||||
import StringIO as io
|
||||
except ImportError:
|
||||
|
|
@ -26,14 +27,12 @@ except ImportError:
|
|||
|
||||
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 ('<h2>Python Interpreter help</h2>')
|
||||
|
|
@ -72,9 +71,7 @@ plt.close()
|
|||
print('''<pre>zeppelin_show(plt,width='50px')
|
||||
zeppelin_show(plt,height='150px') </pre></div>''')
|
||||
|
||||
|
||||
# Matplotlib show function
|
||||
|
||||
def zeppelin_show(p, width="0", height="0"):
|
||||
img = io.StringIO()
|
||||
p.savefig(img, format='svg')
|
||||
|
|
@ -88,10 +85,8 @@ def zeppelin_show(p, width="0", height="0"):
|
|||
style += 'height:'+height
|
||||
print("%html <div style='" + style + "'>" + img.read() + "<div>")
|
||||
|
||||
|
||||
# If py4j is detected, these class will be override
|
||||
# with the implementation in bootstrap_input.py
|
||||
|
||||
class PyZeppelinContext():
|
||||
errorMsg = "You must install py4j Python module " \
|
||||
"(pip install py4j) to use Zeppelin dynamic forms features"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
from py4j.java_gateway import JavaGateway
|
||||
from py4j.java_gateway import java_import, JavaGateway, GatewayClient
|
||||
|
||||
|
|
@ -21,14 +20,16 @@ client = GatewayClient(port=%PORT%)
|
|||
gateway = JavaGateway(client)
|
||||
java_import(gateway.jvm, "org.apache.zeppelin.display.Input")
|
||||
|
||||
|
||||
class PyZeppelinContext():
|
||||
paramOption = gateway.jvm.org.apache.zeppelin.display.Input.ParamOption
|
||||
javaList = gateway.jvm.java.util.ArrayList
|
||||
|
||||
def __init__(self, zc):
|
||||
self.z = zc
|
||||
|
||||
def input(self, name, defaultValue=""):
|
||||
return self.z.getGui().input(name, defaultValue)
|
||||
|
||||
def select(self, name, options, defaultValue=""):
|
||||
javaOptions = gateway.new_array(self.paramOption, len(options))
|
||||
i = 0
|
||||
|
|
@ -36,6 +37,7 @@ class PyZeppelinContext():
|
|||
javaOptions[i] = self.paramOption(tuple[0], tuple[1])
|
||||
i += 1
|
||||
return self.z.getGui().select(name, defaultValue, javaOptions)
|
||||
|
||||
def checkbox(self, name, options, defaultChecked=[]):
|
||||
javaOptions = gateway.new_array(self.paramOption, len(options))
|
||||
i = 0
|
||||
|
|
@ -47,5 +49,4 @@ class PyZeppelinContext():
|
|||
javaDefaultCheck.append(check)
|
||||
return self.z.getGui().checkbox(name, javaDefaultCheck, javaOptions)
|
||||
|
||||
|
||||
z = PyZeppelinContext(gateway.entry_point)
|
||||
|
|
|
|||
Loading…
Reference in a new issue