PKs[LCn n jupyter_app.py""" jupyter_app - run Jupyter lab as a desktop app Usage: * jupyter_app run Jupyter as an app * jupyter_app --webruntime=xx specify the runtime, (see webruntime module) * jupyter_app --version print version and exit * jupyter_app --help print this help and exit """ import os import sys import time import threading import _thread as thread from tornado.httputil import url_concat from notebook import DEFAULT_STATIC_FILES_PATH from jupyterlab.labapp import LabApp from webruntime import launch __version__ = '0.1' # Get location of Jupyter icon iconfile = os.path.join(DEFAULT_STATIC_FILES_PATH, 'favicon.ico') if not os.path.isfile(iconfile): iconfile = None # Init web runtime runtime = 'app' # Good default that tries Firefox, NW.js (and Chrome on win) class MyLabApp(LabApp): """ Subclass LabApp so we can launch our webruntime instead of the browser. """ def start(self): url = self.connection_url if self.token and self._token_generated: url = url_concat(url, {'token': self.token}) rt = launch(url, runtime, title="Jupyterlab", icon=iconfile, size=(1024, 768) ) self._watcher = Watcher(rt._proc) self._watcher.start() self.open_browser = False super().start() class Watcher(threading.Thread): """ Thread that stops Python when a given process (the runtime has stopped) """ def __init__(self, process): super().__init__() self.process = process self.setDaemon(True) def run(self): while True: time.sleep(0.2) if self.process.poll() is not None: thread.interrupt_main() break def main(): global runtime for x in sys.argv[1:]: if x.startswith('--webruntime='): runtime = x.split('=', 1)[-1] elif x in ('-h', '--help'): print(__doc__.lstrip()) return elif x in ('--version'): print(__version__) return assert runtime.endswith('app'), "Runtime needs to end in 'app'" MyLabApp.launch_instance() if __name__ == '__main__': main() PK!Hp)0*jupyter_app-0.1.dist-info/entry_points.txtN+I/N.,()*-,I-O,(Eb[&fqqPK[s[Lr$$!jupyter_app-0.1.dist-info/LICENSEBSD 2-Clause License Copyright (c) 2018, Almar Klein All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PK!HxQPjupyter_app-0.1.dist-info/WHEEL1 0 RZq+D-Dv;_[*7Fp 8MRq%_:==ߘPT PK!H՞"jupyter_app-0.1.dist-info/METADATATMS0WL{)'Oa@!PX6u%U>p¥d>ݷoR(?!WQYe<2M#^?Gbֵ=d[r 2aDrN5f3wcpnbNsEPZ&]X4n{Q܏/c1jcEQeJ2շy %~q[1d7Ks)' S^NQ :Ppha7zr̩}rK4Õt[kAxGQ)Gz4 ZT{TJ̀M Rb= Gci;)D7a; +[*VXWdYrl:0:Ƥ ,lrYI8 j|-v$0m.J ֺ0DFK=OIaeFcD$Ɣ``S2g|G`Ta.*t߰'be)J T-f$1m`i e~vŗxzuQyPK!HOfˣ' jupyter_app-0.1.dist-info/RECORD}B@{ς5p؃TF$.}!O'޼=H3xg oD9mjjT&GkRݣV ⟡Y0#t^WRtM^!#k\S'{)p"c)To./s`eZm5s/ZCa dJG>x^B6tVɞ\Mܯ Lo @-(]PQ4Qf%!+Lajj#bL)-g$*)@H5ZPKs[LCn n jupyter_app.pyPK!Hp)0* jupyter_app-0.1.dist-info/entry_points.txtPK[s[Lr$$! jupyter_app-0.1.dist-info/LICENSEPK!HxQPnjupyter_app-0.1.dist-info/WHEELPK!H՞"jupyter_app-0.1.dist-info/METADATAPK!HOfˣ' jupyter_app-0.1.dist-info/RECORDPK`