Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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:
def setup_bpython():
import bpython
bpython.embed()
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:
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()
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()
def invoke_bpython_shell(self):
import bpython
bpython.embed(self.locals)
def bpython(self, options):
import bpython
bpython.embed()
def bpython(self):
import bpython
bpython.embed()
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()