How to use the beakerx.beakerx.environment.EnvironmentSettings function in beakerx

To help you get started, we’ve selected a few beakerx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github twosigma / beakerx / beakerx / beakerx / environment.py View on Github external
def read_setting_from_file():
        try:
            file = open(EnvironmentSettings.config_path, 'r')
            content = file.read()
            beakerx_settings = json.loads(content)
            if beakerx_settings['beakerx'].get('version') is None:
                content = EnvironmentSettings._convert_to_version_2(beakerx_settings)
        except IOError:
            content = default_config
            EnvironmentSettings.save_setting_to_file(default_config)
        except ValueError as ex:
            print ('Error while parsing beakerx.json: ', ex)
            content = default_config
        else:
            file.close()

        return content
github twosigma / beakerx / beakerx / beakerx / environment.py View on Github external
def save_setting_to_file(content):
        makedirs(paths.jupyter_config_dir(), exist_ok=True)
        with fdopen(osopen(EnvironmentSettings.config_path, O_RDWR | O_CREAT, 0o600), 'w+') as file:
            file_content = file.read()
            new_settings = json.loads(content)
            if file_content:
                saved_settings = json.loads(file_content)
                file.seek(0)
                file.truncate()
                for setting_name in new_settings['beakerx']:
                    saved_settings['beakerx'][setting_name] = new_settings['beakerx'][setting_name]
            else:
                saved_settings = new_settings
            file.write(json.dumps(saved_settings, indent=4, sort_keys=True))
github twosigma / beakerx / beakerx / beakerx / kernel_spec.py View on Github external
def __init__(self, **kw):
        super(BeakerXKernelSpec, self).__init__(**kw)
        if self.argv[0] == 'java':
            args = EnvironmentSettings.read_beakerx_env_settings()
            self.argv[1:1] = args
github twosigma / beakerx / beakerx / beakerx / handlers.py View on Github external
def post(self):
        data = tornado.escape.json_decode(self.request.body)

        EnvironmentSettings.save_setting_to_file(json.dumps(data))

        self.finish(json.dumps(SettingsHandler._read_property()))
github twosigma / beakerx / beakerx / beakerx / environment.py View on Github external
def read_setting_from_file():
        try:
            file = open(EnvironmentSettings.config_path, 'r')
            content = file.read()
            beakerx_settings = json.loads(content)
            if beakerx_settings['beakerx'].get('version') is None:
                content = EnvironmentSettings._convert_to_version_2(beakerx_settings)
        except IOError:
            content = default_config
            EnvironmentSettings.save_setting_to_file(default_config)
        except ValueError as ex:
            print ('Error while parsing beakerx.json: ', ex)
            content = default_config
        else:
            file.close()

        return content