Ejemplo n.º 1
0
    def run_rpc_shell(self, app_name):
        settings = self.get_app_settings(app_name)
        api = self.get_api(self.settings.__dict__, app_name, use_bind=True)

        # Make PyFlakes ignore the 'unused' variables
        settings, api = settings, api

        logfile_root = os.path.expanduser("~/.dirt_api_logs/")
        if not os.path.exists(logfile_root):
            print "%r doesn't exist - not logging API calls" %(logfile_root, )
        else:
            logfile = os.path.join(logfile_root, app_name)
            from .rpc import connection
            connection.full_message_log_enable(logfile)
            print "Logging API calls to %r", logfile

        print "access the api using the `api` variable"
        print

        try:
            from IPython.frontend.terminal.embed import embed
            embed()
        except ImportError:
            # compat with older ipython
            from IPython.Shell import IPShellEmbed
            IPShellEmbed(argv='')()
Ejemplo n.º 2
0
Archivo: runner.py Proyecto: taavi/dirt
    def run_rpc_shell(self, app_name):
        settings = self.get_app_settings(app_name)
        api = self.get_api(self.settings.__dict__, app_name, use_bind=True)

        # Make PyFlakes ignore the 'unused' variables
        settings, api = settings, api

        logfile_root = os.path.expanduser("~/.dirt_api_logs/")
        if not os.path.exists(logfile_root):
            print "%r doesn't exist - not logging API calls" % (logfile_root,)
        else:
            logfile = os.path.join(logfile_root, app_name)
            from .rpc import connection

            connection.full_message_log_enable(logfile)
            print "Logging API calls to %r", logfile

        print "access the api using the `api` variable"
        print

        try:
            from IPython.frontend.terminal.embed import embed

            embed()
        except ImportError:
            # compat with older ipython
            from IPython.Shell import IPShellEmbed

            IPShellEmbed(argv="")()
Ejemplo n.º 3
0
    def interact(self, vars=None):
        if vars is not None:
            self.ns.update(vars)

        # Set the default encoding to utf-8, pango/gtk normally does
        # this but we don't want to import that here.
        import sys
        reload(sys)
        sys.setdefaultencoding('utf-8')

        banner = self.get_console_banner()
        if USE_IPYTHON:
            embed(user_ns=self.ns, banner1=banner)
        else:
            readline.parse_and_bind("tab: complete")
            code.interact(local=self.ns, banner=banner)
Ejemplo n.º 4
0
 def ipython(self):
     try:
         from IPython.frontend.terminal.embed import embed
         ns = auto_import()
         embed(user_ns=ns)
     except ImportError:
         # IPython < 0.11
         # Explicitly pass an empty list as arguments, because otherwise
         # IPython would use sys.argv from this script.
         try:
             from IPython.Shell import IPShell
             shell = IPShell(argv=[])
             shell.mainloop()
         except ImportError:
             # IPython not found at all, raise ImportError
             raise
Ejemplo n.º 5
0
 def ipython(self):
     try:
         from IPython.frontend.terminal.embed import embed
         ns = auto_import()
         embed(user_ns=ns)
     except ImportError:
         # IPython < 0.11
         # Explicitly pass an empty list as arguments, because otherwise
         # IPython would use sys.argv from this script.
         try:
             from IPython.Shell import IPShell
             shell = IPShell(argv=[])
             shell.mainloop()
         except ImportError:
             # IPython not found at all, raise ImportError
             raise
Ejemplo n.º 6
0
    def interact(self, vars=None):
        if vars is not None:
            self.ns.update(vars)

        # Set the default encoding to utf-8, pango/gtk normally does
        # this but we don't want to import that here.
        import sys
        reload(sys)
        sys.setdefaultencoding('utf-8')

        banner = self.get_console_banner()
        # PyCharm doesn't support colors and tabs
        if USE_IPYTHON:
            config = Config()
            if 'PYCHARM_HOSTED' in os.environ:
                config.TerminalInteractiveShell.colors = 'NoColor'
            embed(config=config, user_ns=self.ns, banner1=banner)
        else:
            readline.parse_and_bind("tab: complete")
            code.interact(local=self.ns, banner=banner)
Ejemplo n.º 7
0
    def interact(self, vars=None):
        if vars is not None:
            self.ns.update(vars)

        # Set the default encoding to utf-8, pango/gtk normally does
        # this but we don't want to import that here.
        import sys

        reload(sys)
        sys.setdefaultencoding("utf-8")

        banner = self.get_console_banner()
        # PyCharm doesn't support colors and tabs
        if USE_IPYTHON:
            config = Config()
            if "PYCHARM_HOSTED" in os.environ:
                config.TerminalInteractiveShell.colors = "NoColor"
            embed(config=config, user_ns=self.ns, banner1=banner)
        else:
            readline.parse_and_bind("tab: complete")
            code.interact(local=self.ns, banner=banner)