How to use the bpython.embed function in bpython

To help you get started, we’ve selected a few bpython 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 Kegbot / kegbot-server / pykeg / src / pykeg / external / django_extensions / management / commands / shell_plus.py View on Github external
for model in app_models:
                try:
                    imported_objects[model.__name__] = getattr(__import__(app_mod.__name__, {}, {}, model.__name__), model.__name__)
                except AttributeError, e:
                    print self.style.ERROR("Failed to import '%s' from '%s' reason: %s" % (model.__name__, app_mod.__name__.split('.')[-2], str(e)))
                    continue
        try:
            if use_plain:
                # Don't bother loading B/IPython, because the user wants plain Python.
                raise ImportError
            try:
                if use_ipython:
                    # User wants IPython
                    raise ImportError
                from bpython import embed
                embed(imported_objects)
            except ImportError:
                # Explicitly pass an empty list as arguments, because otherwise IPython
                # would use sys.argv from this script.
                try:
                    from IPython.core.iplib import InteractiveShell
                    shell = InteractiveShell(user_ns=imported_objects)
                except ImportError:
                    import IPython
                    shell = IPython.Shell.IPShell(argv=[], user_ns=imported_objects)
                shell.mainloop()
        except ImportError:
            # Using normal Python shell
            import code
            try: # Try activating rlcompleter, because it's handy.
                import readline
            except ImportError:
github agentultra / dmon / dmon / shell.py View on Github external
def setup_bpython():
    import bpython
    bpython.embed()
github openstack / cinder / cinder / cmd / manage.py View on Github external
def run(self, shell=None):
        """Runs a Python interactive interpreter."""
        if not shell:
            shell = 'bpython'

        if shell == 'bpython':
            try:
                import bpython
                bpython.embed()
            except ImportError:
                shell = 'ipython'
        if shell == 'ipython':
            try:
                from IPython import embed
                embed()
            except ImportError:
                try:
                    # Ipython < 0.11
                    # Explicitly pass an empty list as arguments, because
                    # otherwise IPython would use sys.argv from this script.
                    import IPython

                    shell = IPython.Shell.IPShell(argv=[])
                    shell.mainloop()
                except ImportError:
github rackerlabs / yolo / yolo / client.py View on Github external
def shell(self, stage):
        self.set_up_yolofile_context(stage=stage)
        self._yolo_file = self.yolo_file.render(**self.context)

        # Set up AWS credentials for the shell
        self._setup_aws_credentials_in_environment(
            self.context.account.account_number,
            self.context.stage.region,
        )

        # Select Python shell
        if have_bpython:
            bpython.embed()
        elif have_ipython:
            start_ipython(argv=[])
        else:
            code.interact()
github aiidateam / aiida-core / aiida / cmdline / utils / shell.py View on Github external
def bpython():
    """Start a bpython shell."""
    import bpython as bpy_shell  # pylint: disable=import-error

    user_ns = get_start_namespace()
    if user_ns:
        bpy_shell.embed(user_ns)
    else:
        bpy_shell.embed()
github ansible / awx / awx / lib / site-packages / celery / bin / celery.py View on Github external
def invoke_bpython_shell(self):
        import bpython
        bpython.embed(self.locals)
github aiidateam / aiida-core / aiida / cmdline / utils / shell.py View on Github external
def bpython():
    """Start a bpython shell."""
    import bpython as bpy_shell  # pylint: disable=import-error

    user_ns = get_start_namespace()
    if user_ns:
        bpy_shell.embed(user_ns)
    else:
        bpy_shell.embed()