Exemple #1
0
    def run(self, options, cleanup=None):
        from .session import create_radian_prompt_session
        from .console import create_read_console, create_write_console_ex
        import rchitect
        from . import rutils, settings

        self.set_env_vars(options)

        args = ["radian", "--quiet", "--no-restore-history"]

        if sys.platform != "win32":
            args.append("--no-readline")

        if options.no_environ:
            args.append("--no-environ")

        if options.no_site_file:
            args.append("--no-site-file")

        if options.no_init_file:
            args.append("--no-init-file")

        if options.ask_save is not True:
            args.append("--no-save")

        if options.restore_data is not True:
            args.append("--no-restore-data")

        rchitect.init(args=args)

        rutils.source_radian_profile(options.profile)

        settings = settings.radian_settings
        settings.load()
        self.session = create_radian_prompt_session(options, settings)

        rchitect.def_callback(name="read_console")(create_read_console(
            self.session))
        rchitect.def_callback(name="write_console_ex")(create_write_console_ex(
            self.session, settings.stderr_format))

        rutils.load_custom_key_bindings()

        from radian import main
        if main.cleanup:
            rutils.register_cleanup(main.cleanup)

        from . import reticulate
        reticulate.configure()

        # run user on load hooks
        rutils.run_on_load_hooks()

        # print welcome message
        if options.quiet is not True:
            self.session.app.output.write(rchitect.interface.greeting())

        rchitect.loop()
Exemple #2
0
    def run(self, options, cleanup=None):
        from .prompt import create_radian_prompt_session
        from .read_console import create_read_console
        import rchitect

        self.set_env_vars(options)

        args = ["rchitect", "--quiet", "--no-restore-history"]

        if sys.platform != "win32":
            args.append("--no-readline")

        if options.no_environ:
            args.append("--no-environ")

        if options.no_site_file:
            args.append("--no-site-file")

        if options.no_init_file:
            args.append("--no-init-file")

        if options.ask_save is not True:
            args.append("--no-save")

        if options.restore_data is not True:
            args.append("--no-restore-data")

        rchitect.init(args=args)

        self.session = create_radian_prompt_session(options)

        rchitect.def_callback(name="read_console")(create_read_console(
            self.session))

        from . import rutils
        rutils.execute_key_bindings_script()

        from radian import main
        if main.cleanup:
            rutils.finalizer(main.cleanup)

        from . import reticulate
        reticulate.hooks()

        # print welcome message
        if options.quiet is not True:
            self.session.app.output.write(rchitect.interface.greeting())

        rchitect.loop()
Exemple #3
0
    def run(self, options, cleanup=None):
        from .session import create_radian_prompt_session
        from .console import create_read_console, create_write_console_ex
        import rchitect
        from . import rutils, settings

        self.set_env_vars(options)

        args = ["radian", "--quiet", "--no-restore-history"]

        if sys.platform != "win32":
            args.append("--no-readline")

        if options.no_environ:
            args.append("--no-environ")

        if options.no_site_file:
            args.append("--no-site-file")

        if options.no_init_file:
            args.append("--no-init-file")

        if options.ask_save is not True:
            args.append("--no-save")

        if options.restore_data is not True:
            args.append("--no-restore-data")

        rchitect.init(args=args)

        rutils.source_radian_profile(options.profile)

        settings = settings.radian_settings
        settings.load()
        self.session = create_radian_prompt_session(options, settings)

        rchitect.def_callback(name="read_console")(create_read_console(self.session))
        rchitect.def_callback(name="write_console_ex")(
            create_write_console_ex(self.session, settings.stderr_format))

        rutils.load_custom_key_bindings()

        from radian import main
        if main.cleanup:
            rutils.register_cleanup(main.cleanup)

        from . import reticulate
        reticulate.configure()

        # run user on load hooks
        rutils.run_on_load_hooks()

        # print welcome message
        if options.quiet is not True:
            self.session.app.output.write(rchitect.interface.greeting())

        if sys.platform.startswith("darwin"):
            # a workaround to suppress quartz error message
            # see https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17734
            devnull = os.open(os.devnull, os.O_WRONLY)
            os.dup2(devnull, 2)

        rchitect.loop()
Exemple #4
0
    def run(self, options, cleanup=None):
        from .session import create_radian_prompt_session
        from .console import create_read_console, create_write_console_ex
        import rchitect
        from . import rutils, settings

        self.set_env_vars(options)

        args = ["radian", "--quiet", "--no-restore-history"]

        if sys.platform != "win32":
            args.append("--no-readline")

        if options.no_environ:
            args.append("--no-environ")

        if options.no_site_file:
            args.append("--no-site-file")

        if options.no_init_file:
            args.append("--no-init-file")

        if options.ask_save is not True:
            args.append("--no-save")

        if options.restore_data is not True:
            args.append("--no-restore-data")

        # disable the code injection of rchitect to reticulate::py_discover_config
        os.environ["RCHITECT_RETICULATE_CONFIG"] = "0"
        # enable signal handlers
        os.environ["RCHITECT_REGISTER_SIGNAL_HANDLERS"] = "1"

        rchitect.init(args=args, register_signal_handlers=True)

        try:
            rutils.source_radian_profile(options.profile)
        except RuntimeError as e:
            print("Got an error while loading radian profile")
            print(e)

        settings = settings.radian_settings
        settings.load()
        self.session = create_radian_prompt_session(options, settings)

        rchitect.def_callback(name="read_console")(create_read_console(
            self.session))
        rchitect.def_callback(name="write_console_ex")(create_write_console_ex(
            self.session, settings.stderr_format))

        rutils.load_custom_key_bindings()

        from radian import main
        if main.cleanup:
            rutils.register_cleanup(main.cleanup)

        from . import reticulate
        reticulate.configure()

        # run user on load hooks
        rutils.run_on_load_hooks()

        # print welcome message
        if options.quiet is not True:
            self.session.app.output.write(rchitect.interface.greeting())

        # if sys.platform.startswith("darwin"):
        #     # a workaround to suppress quartz error message
        #     # see https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17734
        #     devnull = os.open(os.devnull, os.O_WRONLY)
        #     os.dup2(devnull, 2)

        rchitect.loop()