コード例 #1
0
ファイル: main.py プロジェクト: ericmharris/xonsh
def start_services(shell_kwargs, args):
    """Starts up the essential services in the proper order.
    This returns the environment instance as a convenience.
    """
    install_import_hooks()
    # create execer, which loads builtins
    ctx = shell_kwargs.get("ctx", {})
    debug = to_bool_or_int(os.getenv("XONSH_DEBUG", "0"))
    events.on_timingprobe.fire(name="pre_execer_init")
    execer = Execer(
        xonsh_ctx=ctx,
        debug_level=debug,
        scriptcache=shell_kwargs.get("scriptcache", True),
        cacheall=shell_kwargs.get("cacheall", False),
    )
    events.on_timingprobe.fire(name="post_execer_init")
    # load rc files
    login = shell_kwargs.get("login", True)
    env = builtins.__xonsh__.env
    rc = shell_kwargs.get("rc", None)
    rc = env.get("XONSHRC") if rc is None else rc
    if args.mode != XonshMode.interactive and not args.force_interactive:
        #  Don't load xonshrc if not interactive shell
        rc = None
    events.on_pre_rc.fire()
    xonshrc_context(rcfiles=rc, execer=execer, ctx=ctx, env=env, login=login)
    events.on_post_rc.fire()
    # create shell
    builtins.__xonsh__.shell = Shell(execer=execer, **shell_kwargs)
    ctx["__name__"] = "__main__"
    return env
コード例 #2
0
ファイル: main.py プロジェクト: tinloaf/xonsh
def start_services(shell_kwargs):
    """Starts up the essential services in the proper order.
    This returns the environment instance as a convenience.
    """
    install_import_hooks()
    # create execer, which loads builtins
    ctx = shell_kwargs.get('ctx', {})
    debug = to_bool_or_int(os.getenv('XONSH_DEBUG', '0'))
    events.on_timingprobe.fire(name='pre_execer_init')
    execer = Execer(xonsh_ctx=ctx, debug_level=debug,
                    scriptcache=shell_kwargs.get('scriptcache', True),
                    cacheall=shell_kwargs.get('cacheall', False))
    events.on_timingprobe.fire(name='post_execer_init')
    # load rc files
    login = shell_kwargs.get('login', True)
    env = builtins.__xonsh_env__
    rc = shell_kwargs.get('rc', None)
    rc = env.get('XONSHRC') if rc is None else rc
    events.on_pre_rc.fire()
    xonshrc_context(rcfiles=rc, execer=execer, ctx=ctx, env=env, login=login)
    events.on_post_rc.fire()
    # create shell
    builtins.__xonsh_shell__ = Shell(execer=execer, **shell_kwargs)
    ctx['__name__'] = '__main__'
    return env
コード例 #3
0
ファイル: main.py プロジェクト: kevindwei/xonsh
def start_services(shell_kwargs, args):
    """Starts up the essential services in the proper order.
    This returns the environment instance as a convenience.
    """
    install_import_hooks()
    # create execer, which loads builtins
    ctx = shell_kwargs.get('ctx', {})
    debug = to_bool_or_int(os.getenv('XONSH_DEBUG', '0'))
    events.on_timingprobe.fire(name='pre_execer_init')
    execer = Execer(xonsh_ctx=ctx,
                    debug_level=debug,
                    scriptcache=shell_kwargs.get('scriptcache', True),
                    cacheall=shell_kwargs.get('cacheall', False))
    events.on_timingprobe.fire(name='post_execer_init')
    # load rc files
    login = shell_kwargs.get('login', True)
    env = builtins.__xonsh_env__
    rc = shell_kwargs.get('rc', None)
    rc = env.get('XONSHRC') if rc is None else rc
    if args.mode != XonshMode.interactive and not args.force_interactive:
        #  Don't load xonshrc if not interactive shell
        rc = None
    events.on_pre_rc.fire()
    xonshrc_context(rcfiles=rc, execer=execer, ctx=ctx, env=env, login=login)
    events.on_post_rc.fire()
    # create shell
    builtins.__xonsh_shell__ = Shell(execer=execer, **shell_kwargs)
    ctx['__name__'] = '__main__'
    return env
コード例 #4
0
ファイル: main.py プロジェクト: sailychen/xonsh
def start_services(shell_kwargs, args):
    """Starts up the essential services in the proper order.
    This returns the environment instance as a convenience.
    """
    install_import_hooks()
    # create execer, which loads builtins
    ctx = shell_kwargs.get("ctx", {})
    debug = to_bool_or_int(os.getenv("XONSH_DEBUG", "0"))
    events.on_timingprobe.fire(name="pre_execer_init")
    execer = Execer(
        xonsh_ctx=ctx,
        debug_level=debug,
        scriptcache=shell_kwargs.get("scriptcache", True),
        cacheall=shell_kwargs.get("cacheall", False),
    )
    events.on_timingprobe.fire(name="post_execer_init")
    # load rc files
    login = shell_kwargs.get("login", True)
    env = builtins.__xonsh__.env
    rc = shell_kwargs.get("rc", None)
    rc = env.get("XONSHRC") if rc is None else rc
    if args.mode != XonshMode.interactive and not args.force_interactive:
        #  Don't load xonshrc if not interactive shell
        rc = None
    events.on_pre_rc.fire()
    xonshrc_context(rcfiles=rc, execer=execer, ctx=ctx, env=env, login=login)
    events.on_post_rc.fire()
    # create shell
    builtins.__xonsh__.shell = Shell(execer=execer, **shell_kwargs)
    ctx["__name__"] = "__main__"
    return env
コード例 #5
0
ファイル: main.py プロジェクト: Auto-ML/xonsh
def start_services(shell_kwargs, args, pre_env=None):
    """Starts up the essential services in the proper order.
    This returns the environment instance as a convenience.
    """
    if pre_env is None:
        pre_env = {}
    install_import_hooks()
    # create execer, which loads builtins
    ctx = shell_kwargs.get("ctx", {})
    debug = to_bool_or_int(os.getenv("XONSH_DEBUG", "0"))
    events.on_timingprobe.fire(name="pre_execer_init")
    execer = Execer(
        xonsh_ctx=ctx,
        debug_level=debug,
        scriptcache=shell_kwargs.get("scriptcache", True),
        cacheall=shell_kwargs.get("cacheall", False),
    )
    events.on_timingprobe.fire(name="post_execer_init")
    # load rc files
    login = shell_kwargs.get("login", True)
    env = builtins.__xonsh__.env
    for k, v in pre_env.items():
        env[k] = v

    # determine which RC files to load, including whether any RC directories
    # should be scanned for such files
    if shell_kwargs.get("norc") or (
        args.mode != XonshMode.interactive
        and not args.force_interactive
        and not args.login
    ):
        # if --no-rc was passed, or we're not in an interactive shell and
        # interactive mode was not forced, then disable loading RC files and dirs
        rc = ()
        rcd = ()
    elif shell_kwargs.get("rc"):
        # if an explicit --rc was passed, then we should load only that RC
        # file, and nothing else (ignore both XONSHRC and XONSHRC_DIR)
        rc = shell_kwargs.get("rc")
        rcd = ()
    else:
        # otherwise, get the RC files from XONSHRC, and RC dirs from XONSHRC_DIR
        rc = env.get("XONSHRC")
        rcd = env.get("XONSHRC_DIR")

    events.on_pre_rc.fire()
    xonshrc_context(
        rcfiles=rc, rcdirs=rcd, execer=execer, ctx=ctx, env=env, login=login
    )
    events.on_post_rc.fire()
    # create shell
    builtins.__xonsh__.shell = Shell(execer=execer, **shell_kwargs)
    ctx["__name__"] = "__main__"
    return env
コード例 #6
0
 def _init_environ(self, ctx, config, rc, scriptcache, cacheall):
     self.ctx = {} if ctx is None else ctx
     debug = to_bool_or_int(os.getenv('XONSH_DEBUG', '0'))
     self.execer = Execer(config=config,
                          login=self.login,
                          xonsh_ctx=self.ctx,
                          debug_level=debug)
     self.execer.scriptcache = scriptcache
     self.execer.cacheall = cacheall
     if self.stype != 'none' or self.login:
         # load xontribs from config file
         names = builtins.__xonsh_config__.get('xontribs', ())
         for name in names:
             update_context(name, ctx=self.ctx)
         if getattr(update_context, 'bad_imports', None):
             prompt_xontrib_install(update_context.bad_imports)
             del update_context.bad_imports
         # load run control files
         env = builtins.__xonsh_env__
         rc = env.get('XONSHRC') if rc is None else rc
         self.ctx.update(
             xonshrc_context(rcfiles=rc,
                             execer=self.execer,
                             initial=self.ctx))
     self.ctx['__name__'] = '__main__'
コード例 #7
0
ファイル: shell.py プロジェクト: CJ-Wright/xonsh
 def _init_environ(self, ctx, config, rc):
     self.execer = Execer(config=config, login=self.login)
     if ctx is None:
         builtins.__xonsh_ctx__ = self.ctx = context = {}
         if self.login or self.stype != 'none':
             # load xontrib files listed in the config file
             names = builtins.__xonsh_config__.get('xontribs', ())
             for name in names:
                 xontribs.update_context(name, ctx=context)
             # load run contol files
             env = builtins.__xonsh_env__
             rc = env.get('XONSHRC') if rc is None else rc
             xonshrc_context(rcfiles=rc, execer=self.execer, ctx=context)
     else:
         builtins.__xonsh_ctx__ = self.ctx = ctx
     self.ctx['__name__'] = '__main__'
コード例 #8
0
ファイル: shell.py プロジェクト: dboyliao/xonsh
 def _init_environ(self, ctx):
     self.execer = Execer()
     env = builtins.__xonsh_env__
     if ctx is not None:
         self.ctx = ctx
     else:
         rc = env.get('XONSHRC', None)
         self.ctx = xonshrc_context(rcfile=rc, execer=self.execer)
     builtins.__xonsh_ctx__ = self.ctx
     self.ctx['__name__'] = '__main__'
コード例 #9
0
ファイル: shell.py プロジェクト: slaveuser/gitsome20160430
 def _init_environ(self, ctx):
     self.execer = Execer()
     env = builtins.__xonsh_env__
     if ctx is not None:
         self.ctx = ctx
     else:
         rc = env.get('XONSHRC')
         self.ctx = xonshrc_context(rcfiles=rc, execer=self.execer)
     builtins.__xonsh_ctx__ = self.ctx
     self.ctx['__name__'] = '__main__'
コード例 #10
0
ファイル: shell.py プロジェクト: gitter-badger/xonsh
 def _init_environ(self, ctx, config, rc):
     self.execer = Execer(config=config)
     env = builtins.__xonsh_env__
     if ctx is None:
         rc = env.get('XONSHRC') if rc is None else rc
         self.ctx = xonshrc_context(rcfiles=rc, execer=self.execer)
     else:
         self.ctx = ctx
     builtins.__xonsh_ctx__ = self.ctx
     self.ctx['__name__'] = '__main__'
コード例 #11
0
ファイル: shell.py プロジェクト: minrk/xonsh
 def _init_environ(self, ctx, config, rc):
     self.execer = Execer(config=config)
     env = builtins.__xonsh_env__
     if ctx is None:
         rc = env.get("XONSHRC") if rc is None else rc
         self.ctx = xonshrc_context(rcfiles=rc, execer=self.execer)
     else:
         self.ctx = ctx
     builtins.__xonsh_ctx__ = self.ctx
     self.ctx["__name__"] = "__main__"
コード例 #12
0
def _load_rc_files(shell_kwargs: dict, args, env, execer, ctx):
    events.on_pre_rc.fire()
    # load rc files
    login = shell_kwargs.get("login", True)
    rc, rcd = _get_rc_files(shell_kwargs, args, env)
    XSH.rc_files = xonshrc_context(rcfiles=rc,
                                   rcdirs=rcd,
                                   execer=execer,
                                   ctx=ctx,
                                   env=env,
                                   login=login)
    events.on_post_rc.fire()
コード例 #13
0
 def __init__(self, completekey='tab', stdin=None, stdout=None, ctx=None):
     super(Shell, self).__init__(completekey=completekey,
                                 stdin=stdin,
                                 stdout=stdout)
     self.execer = Execer()
     env = builtins.__xonsh_env__
     self.ctx = ctx if ctx is not None else \
         xonshrc_context(rcfile=env.get('XONSHRC', None), execer=self.execer)
     self.completer = Completer()
     self.buffer = []
     self.need_more_lines = False
     self.mlprompt = None
     setup_readline()
コード例 #14
0
ファイル: shell.py プロジェクト: bvenkatr/xonsh
 def _init_environ(self, ctx, config, rc):
     self.execer = Execer(config=config, login=self.login)
     env = builtins.__xonsh_env__
     if ctx is None:
         if self.stype == 'none' and not self.login:
             self.ctx = {}
         else:
             rc = env.get('XONSHRC') if rc is None else rc
             self.ctx = xonshrc_context(rcfiles=rc, execer=self.execer)
     else:
         self.ctx = ctx
     builtins.__xonsh_ctx__ = self.ctx
     self.ctx['__name__'] = '__main__'
コード例 #15
0
ファイル: shell.py プロジェクト: wjwwood/xonsh
 def _init_environ(self, ctx, config, rc, scriptcache, cacheall):
     self.ctx = {} if ctx is None else ctx
     self.execer = Execer(config=config, login=self.login, xonsh_ctx=self.ctx)
     self.execer.scriptcache = scriptcache
     self.execer.cacheall = cacheall
     if self.stype != 'none' or self.login:
         # load xontribs from config file
         names = builtins.__xonsh_config__.get('xontribs', ())
         for name in names:
             xontribs.update_context(name, ctx=self.ctx)
         # load run control files
         env = builtins.__xonsh_env__
         rc = env.get('XONSHRC') if rc is None else rc
         self.ctx.update(xonshrc_context(rcfiles=rc, execer=self.execer, initial=self.ctx))
     self.ctx['__name__'] = '__main__'
コード例 #16
0
ファイル: shell.py プロジェクト: mwiebe/xonsh
 def _init_environ(self, ctx, config, rc, scriptcache, cacheall):
     self.ctx = {} if ctx is None else ctx
     self.execer = Execer(config=config, login=self.login, xonsh_ctx=self.ctx)
     self.execer.scriptcache = scriptcache
     self.execer.cacheall = cacheall
     if ctx is None and (self.stype != 'none' or self.login):
         # load xontribs from config file
         names = builtins.__xonsh_config__.get('xontribs', ())
         for name in names:
             xontribs.update_context(name, ctx=self.ctx)
         # load run control files
         env = builtins.__xonsh_env__
         rc = env.get('XONSHRC') if rc is None else rc
         self.ctx.update(xonshrc_context(rcfiles=rc, execer=self.execer))
     self.ctx['__name__'] = '__main__'
コード例 #17
0
ファイル: shell.py プロジェクト: youtux/xonsh
 def _init_environ(self, ctx, config, rc, scriptcache, cacheall):
     self.ctx = {} if ctx is None else ctx
     debug = to_bool_or_int(os.getenv("XONSH_DEBUG", "0"))
     self.execer = Execer(config=config, login=self.login, xonsh_ctx=self.ctx, debug_level=debug)
     self.execer.scriptcache = scriptcache
     self.execer.cacheall = cacheall
     if self.stype != "none" or self.login:
         # load xontribs from config file
         names = builtins.__xonsh_config__.get("xontribs", ())
         for name in names:
             xontribs.update_context(name, ctx=self.ctx)
         # load run control files
         env = builtins.__xonsh_env__
         rc = env.get("XONSHRC") if rc is None else rc
         self.ctx.update(xonshrc_context(rcfiles=rc, execer=self.execer, initial=self.ctx))
     self.ctx["__name__"] = "__main__"
コード例 #18
0
ファイル: shell.py プロジェクト: chenesan/xonsh
 def __init__(self, completekey='tab', stdin=None, stdout=None, ctx=None):
     super(Shell, self).__init__(completekey=completekey,
                                 stdin=stdin,
                                 stdout=stdout)
     self.execer = Execer()
     env = builtins.__xonsh_env__
     if ctx is not None:
         self.ctx = ctx
     else:
         rc = env.get('XONSHRC', None)
         self.ctx = xonshrc_context(rcfile=rc, execer=self.execer)
     self.ctx['__name__'] = '__main__'
     self.completer = Completer()
     self.buffer = []
     self.need_more_lines = False
     self.mlprompt = None
     setup_readline()
コード例 #19
0
ファイル: shell.py プロジェクト: janschulz/xonsh
 def _init_environ(self, ctx, config, rc, scriptcache, cacheall):
     self.ctx = {} if ctx is None else ctx
     debug = to_bool_or_int(os.getenv('XONSH_DEBUG', '0'))
     self.execer = Execer(config=config, login=self.login, xonsh_ctx=self.ctx,
                          debug_level=debug)
     self.execer.scriptcache = scriptcache
     self.execer.cacheall = cacheall
     if self.stype != 'none' or self.login:
         # load xontribs from config file
         names = builtins.__xonsh_config__.get('xontribs', ())
         for name in names:
             update_context(name, ctx=self.ctx)
         if getattr(update_context, 'bad_imports', None):
             prompt_xontrib_install(update_context.bad_imports)
             del update_context.bad_imports
         # load run control files
         env = builtins.__xonsh_env__
         rc = env.get('XONSHRC') if rc is None else rc
         self.ctx.update(xonshrc_context(rcfiles=rc, execer=self.execer, initial=self.ctx))
     self.ctx['__name__'] = '__main__'