示例#1
0
    def get(self):
        args = self.get_argument('m', default=None)

        if args is not None:
            args = json.loads(
                decrypt(base64.b64decode(args), self.config(key='sesskey')))

        if args is not None:
            self.log_debug("setting cookies")
            for cname in [
                    'sessname', 'hostshell', 'hostupload', 'hostipnb', 'sign',
                    'juliabox'
            ]:
                self.set_cookie(cname, args[cname])
            self.set_status(status_code=204)
            self.finish()
        else:
            args = dict()
            for cname in [
                    'sessname', 'hostshell', 'hostupload', 'hostipnb', 'sign',
                    'juliabox'
            ]:
                args[cname] = self.get_cookie(cname)
            args = tornado.escape.url_escape(
                base64.b64encode(
                    encrypt(json.dumps(args), self.config(key='sesskey'))))
            url = "//" + CloudHost.notebook_websocket_hostname(
            ) + "/cors/?m=" + args
            self.log_debug("redirecting to " + url)
            self.redirect(url)
示例#2
0
 def setup_instance_config(self, profiles=('julia', 'jboxjulia')):
     for profile in profiles:
         profile_path = '.ipython/profile_' + profile
         profile_path = os.path.join(self.disk_path, profile_path)
         if not os.path.exists(profile_path):
             continue
         nbconfig = os.path.join(profile_path, 'ipython_notebook_config.py')
         wsock_cfg = "c.NotebookApp.websocket_url = '" + JBoxVol.NOTEBOOK_WEBSOCK_PROTO + \
                     CloudHost.notebook_websocket_hostname() + "'\n"
         JBoxVol.replace_in_file(nbconfig, "c.NotebookApp.websocket_url", wsock_cfg)
示例#3
0
 def setup_instance_config(self, profiles=('julia', 'jboxjulia')):
     for profile in profiles:
         profile_path = '.ipython/profile_' + profile
         profile_path = os.path.join(self.disk_path, profile_path)
         if not os.path.exists(profile_path):
             continue
         nbconfig = os.path.join(profile_path, 'ipython_notebook_config.py')
         wsock_cfg = "c.NotebookApp.websocket_url = '" + JBoxVol.NOTEBOOK_WEBSOCK_PROTO + \
                     CloudHost.notebook_websocket_hostname() + "'\n"
         JBoxVol.replace_in_file(nbconfig, "c.NotebookApp.websocket_url", wsock_cfg)
示例#4
0
    def setup_instance_config(self):
        nbconfig = os.path.join(self.disk_path, '.ipython/profile_julia/ipython_notebook_config.py')
        nbconfig_temp = os.path.join(self.disk_path, '.ipython/profile_julia/ipython_notebook_config.py.temp')

        if os.path.exists(nbconfig_temp):
            os.remove(nbconfig_temp)
        os.rename(nbconfig, nbconfig_temp)

        wsock_cfg = "c.NotebookApp.websocket_url = 'wss://" + CloudHost.notebook_websocket_hostname() + "'\n"

        replaced = False
        with open(nbconfig_temp) as fin, open(nbconfig, 'w') as fout:
            for line in fin:
                if line.startswith("c.NotebookApp.websocket_url"):
                    line = wsock_cfg
                    replaced = True
                fout.write(line)
            if not replaced:
                fout.write(wsock_cfg)
示例#5
0
文件: cors.py 项目: arshak/JuliaBox
    def get(self):
        args = self.get_argument('m', default=None)

        if args is not None:
            args = json.loads(decrypt(base64.b64decode(args), self.config(key='sesskey')))

        if args is not None:
            self.log_debug("setting cookies")
            for cname in ['sessname', 'hostshell', 'hostupload', 'hostipnb', 'sign', 'juliabox']:
                self.set_cookie(cname, args[cname])
            self.set_status(status_code=204)
            self.finish()
        else:
            args = dict()
            for cname in ['sessname', 'hostshell', 'hostupload', 'hostipnb', 'sign', 'juliabox']:
                args[cname] = self.get_cookie(cname)
            args = tornado.escape.url_escape(base64.b64encode(encrypt(json.dumps(args), self.config(key='sesskey'))))
            url = "//" + CloudHost.notebook_websocket_hostname() + "/cors/?m=" + args
            self.log_debug("redirecting to " + url)
            self.redirect(url)
示例#6
0
    def setup_instance_config(self):
        nbconfig = os.path.join(
            self.disk_path,
            '.ipython/profile_julia/ipython_notebook_config.py')
        nbconfig_temp = os.path.join(
            self.disk_path,
            '.ipython/profile_julia/ipython_notebook_config.py.temp')

        if os.path.exists(nbconfig_temp):
            os.remove(nbconfig_temp)
        os.rename(nbconfig, nbconfig_temp)

        wsock_cfg = "c.NotebookApp.websocket_url = '" + JBoxVol.NOTEBOOK_WEBSOCK_PROTO + \
                    CloudHost.notebook_websocket_hostname() + "'\n"

        replaced = False
        with open(nbconfig_temp) as fin, open(nbconfig, 'w') as fout:
            for line in fin:
                if line.startswith("c.NotebookApp.websocket_url"):
                    line = wsock_cfg
                    replaced = True
                fout.write(line)
            if not replaced:
                fout.write(wsock_cfg)