示例#1
0
 def ipython_ui(self):
     from IPython.terminal.ipapp import TerminalIPythonApp
     import automate
     self.system.namespace.allow_overwrite.extend(['_', '__', '___', '_i', '_ii', '_iii', 'quit'])
     self.system.namespace.update({k: v for k, v in list(automate.__dict__.items()) if k not in self.system.namespace})
     term = TerminalIPythonApp(user_ns=self.system.namespace)
     self.system.namespace['term'] = term
     term.initialize([])
     term.start()
示例#2
0
 def ipython_ui(self):
     from IPython.terminal.ipapp import TerminalIPythonApp
     import automate
     self.system.namespace.allow_overwrite.extend(
         ['_', '__', '___', '_i', '_ii', '_iii', 'quit'])
     self.system.namespace.update({
         k: v
         for k, v in list(automate.__dict__.items())
         if k not in self.system.namespace
     })
     term = TerminalIPythonApp(user_ns=self.system.namespace)
     self.system.namespace['term'] = term
     term.initialize([])
     term.start()
示例#3
0
    def run(self, pipe, no_ipython, no_bpython):
        if pipe:
            # User is attempting to pipe in script through stdin.
            text = sys.stdin.read()
            exec(text, None, _make_context())
            return

        # Try IPython (with autoreload)
        try:
            from IPython.terminal.ipapp import TerminalIPythonApp
            app = TerminalIPythonApp(user_ns=self.get_context())
            config_file = path.join(
                path.dirname(alchemist.__file__), "ipython_startup.ipy")
            app.init_shell()
            app.shell.banner = self.banner
            app.initialize(argv=["-i", config_file])
            app.start()
            return
        except ImportError:
            pass

        # Fallback to normal cycle.
        super(Shell, self).run(no_ipython=no_ipython, no_bpython=no_bpython)
示例#4
0
def _get_debugger_cls():
    shell = get_ipython()
    if shell is None:
        # Not inside IPython
        # Build a terminal app in order to force ipython to load the
        # configuration
        ipapp = TerminalIPythonApp()
        # Avoid output (banner, prints)
        ipapp.interact = False
        ipapp.initialize(["--no-term-title"])
        shell = ipapp.shell
    else:
        # Running inside IPython

        # Detect if embed shell or not and display a message
        if isinstance(shell, InteractiveShellEmbed):
            sys.stderr.write(
                "\nYou are currently into an embedded ipython shell,\n"
                "the configuration will not be loaded.\n\n")

    # Let IPython decide about which debugger class to use
    # This is especially important for tools that fiddle with stdout
    return shell.debugger_cls
示例#5
0
    def run(self, pipe, no_ipython, no_bpython):
        if pipe:
            # User is attempting to pipe in script through stdin.
            text = sys.stdin.read()
            exec(text, None, _make_context())
            return

        # Try IPython (with autoreload)
        try:
            from IPython.terminal.ipapp import TerminalIPythonApp
            app = TerminalIPythonApp(user_ns=self.get_context())
            config_file = path.join(path.dirname(alchemist.__file__),
                                    "ipython_startup.ipy")
            app.init_shell()
            app.shell.banner = self.banner
            app.initialize(argv=["-i", config_file])
            app.start()
            return
        except ImportError:
            pass

        # Fallback to normal cycle.
        super(Shell, self).run(no_ipython=no_ipython, no_bpython=no_bpython)
from IPython.terminal.ipapp import TerminalIPythonApp
from IPython.terminal.embed import InteractiveShellEmbed
try:
    import configparser
except:
    import ConfigParser as configparser

shell = get_ipython()
if shell is None:
    # Not inside IPython
    # Build a terminal app in order to force ipython to load the
    # configuration
    ipapp = TerminalIPythonApp()
    # Avoid output (banner, prints)
    ipapp.interact = False
    ipapp.initialize(['--no-term-title'])
    shell = ipapp.shell
else:
    # Running inside IPython

    # Detect if embed shell or not and display a message
    if isinstance(shell, InteractiveShellEmbed):
        sys.stderr.write(
            "\nYou are currently into an embedded ipython shell,\n"
            "the configuration will not be loaded.\n\n")

# Let IPython decide about which debugger class to use
# This is especially important for tools that fiddle with stdout
debugger_cls = shell.debugger_cls

示例#7
0
__version__ = "0.10.3"

from IPython import get_ipython
from IPython.core.debugger import BdbQuit_excepthook
from IPython.terminal.ipapp import TerminalIPythonApp
from IPython.terminal.embed import InteractiveShellEmbed

shell = get_ipython()
if shell is None:
    # Not inside IPython
    # Build a terminal app in order to force ipython to load the
    # configuration
    ipapp = TerminalIPythonApp()
    # Avoid output (banner, prints)
    ipapp.interact = False
    ipapp.initialize([])
    shell = ipapp.shell
else:
    # Running inside IPython

    # Detect if embed shell or not and display a message
    if isinstance(shell, InteractiveShellEmbed):
        sys.stderr.write(
            "\nYou are currently into an embedded ipython shell,\n"
            "the configuration will not be loaded.\n\n")

# Let IPython decide about which debugger class to use
# This is especially important for tools that fiddle with stdout
debugger_cls = shell.debugger_cls

示例#8
0
文件: faout.py 项目: pwuertz/faout
            raise ValueError("dac_index out of bounds")
        return self._write_reg(value, ADDR_DAC, dac_index)

    def interp_write(self, index, value, steps):
        if index < 0 or index >= 6:
            raise ValueError("dac_index out of bounds")
        self._write_reg(steps, ADDR_INTERP, index+6)
        self._write_reg(value, ADDR_INTERP, index)

    def interp_read(self, index):
        if index < 0 or index >= 6:
            raise ValueError("dac_index out of bounds")
        steps = self._read_reg(ADDR_INTERP, index+6)
        value = self._read_reg(ADDR_INTERP, index)
        return value, steps


if __name__ == "__main__":
    fpga = FPGA_USB_Interface()
    dct = {"fpga": fpga}

    from IPython.terminal.ipapp import TerminalIPythonApp
    TerminalIPythonApp.display_banner = True
    app = TerminalIPythonApp()
    app.initialize(argv=[])
    app.shell.push(dct)
    app.shell.write("\nBuilt-in objects: %s\n" % str(dct))
    app.start()
    del app, fpga, dct

示例#9
0
文件: __main__.py 项目: gotcha/ipdb
from IPython import get_ipython
from IPython.core.debugger import BdbQuit_excepthook
from IPython.terminal.ipapp import TerminalIPythonApp
from IPython.terminal.embed import InteractiveShellEmbed


shell = get_ipython()
if shell is None:
    # Not inside IPython
    # Build a terminal app in order to force ipython to load the
    # configuration
    ipapp = TerminalIPythonApp()
    # Avoid output (banner, prints)
    ipapp.interact = False
    ipapp.initialize([])
    shell = ipapp.shell
else:
    # Running inside IPython

    # Detect if embed shell or not and display a message
    if isinstance(shell, InteractiveShellEmbed):
        sys.stderr.write(
            "\nYou are currently into an embedded ipython shell,\n"
            "the configuration will not be loaded.\n\n"
        )

# Let IPython decide about which debugger class to use
# This is especially important for tools that fiddle with stdout
debugger_cls = shell.debugger_cls
示例#10
0
        if dac_index < 0 or dac_index >= 6:
            raise ValueError("dac_index out of bounds")
        return self._write_reg(value, ADDR_DAC, dac_index)

    def interp_write(self, index, value, steps):
        if index < 0 or index >= 6:
            raise ValueError("dac_index out of bounds")
        self._write_reg(steps, ADDR_INTERP, index + 6)
        self._write_reg(value, ADDR_INTERP, index)

    def interp_read(self, index):
        if index < 0 or index >= 6:
            raise ValueError("dac_index out of bounds")
        steps = self._read_reg(ADDR_INTERP, index + 6)
        value = self._read_reg(ADDR_INTERP, index)
        return value, steps


if __name__ == "__main__":
    fpga = FPGA_USB_Interface()
    dct = {"fpga": fpga}

    from IPython.terminal.ipapp import TerminalIPythonApp
    TerminalIPythonApp.display_banner = True
    app = TerminalIPythonApp()
    app.initialize(argv=[])
    app.shell.push(dct)
    app.shell.write("\nBuilt-in objects: %s\n" % str(dct))
    app.start()
    del app, fpga, dct