예제 #1
0
def console(settings):
    from IPython.terminal.embed import InteractiveShellEmbed
    if not settings.database:
        print 'No database specified.'
        sys.exit(1)

    uri = 'postgresql:///%s' % settings.database

    def models(filters):
        search = filters.replace(' ', '%')
        M = Model.get('ir.model')
        models = M.find(['model', 'ilike', '%' + search + '%'])
        for model in models:
            print '%s  --  %s' % (model.model, model.name)

    print "Launching tryton>proteus console on %s..." % uri
    banner = ('Proteus Help:\n'
              "Classes\t\t-> Model, Wizard & Report\n"
              "Push button\t-> record.click('confirm')\n"
              "Show models\t-> %models stock shipment\n")

    ipshell = InteractiveShellEmbed(banner2=banner)
    ipshell.register_magic_function(models)

    # Imports and config setup to be used in Interactive Shell
    from proteus import config, Model, Wizard, Report
    # Just use Wizard and Report to avoid pyflakes warnings
    Wizard
    Report
    config.set_trytond(uri)

    ipshell()
예제 #2
0
You can script the device's SCSI interface too:

    sc c ac              # Backdoor signature
    sc 8 ff 00 ff        # Undocumented firmware version
    ALSO: reset, eject, sc_sense, sc_read, scsi_in, scsi_out

Happy hacking!    -- Type 'thing?' for help on 'thing' or
~MeS`14              '?' for IPython, '%h' for this again.
"""

from IPython.terminal.embed import InteractiveShellEmbed
from shell_magics import ShellMagics
from remote import Device
import shell_namespace

# Make a global device, but only give it to the user namespace.
# Make it default by assigning it to 'd', our current device.
shell_namespace.d = shell_namespace.d_remote = Device()

# Make a shell that feels like a debugger
ipy = InteractiveShellEmbed(user_ns = shell_namespace.__dict__)
shell_namespace.ipy = ipy
ipy.register_magics(ShellMagics)
ipy.register_magic_function(lambda _: ipy.write(__doc__), magic_name='h')
ipy.alias_manager.define_alias('git', 'git')
ipy.alias_manager.define_alias('make', 'make')

# Hello, tiny world
ipy.mainloop(display_banner = __doc__)
예제 #3
0
from shell_magics import ShellMagics
from remote import Device
import shell_namespace
import sys

messages = ''
user_ns = dict(shell_namespace.__dict__)

# Make a global device, but only give it to the user namespace.
# Make it default by assigning it to 'd', our current device.
try:
    user_ns['d'] = user_ns['d_remote'] = Device()
except IOError as e:
    messages += "\n-------- There is NO DEVICE available! --------\n"
    messages += "\n%s\n\n" % e
    messages += "--> Try again to attach via USB:   %reset\n"
    messages += "--> Reattach over bitbang serial:  %bitbang -a /dev/tty.usb<tab>\n"
    user_ns['d'] = user_ns['d_remote'] = None

# Make a shell that feels like a debugger
ipy = InteractiveShellEmbed(user_ns=user_ns)
user_ns['ipy'] = ipy
ipy.register_magics(ShellMagics)
ipy.register_magic_function(lambda _: ipy.write(__doc__), magic_name='h')
ipy.alias_manager.define_alias('git', 'git')
ipy.alias_manager.define_alias('make', 'make')

# Hello, tiny world
sys.stdout.write(__doc__ + messages)
ipy.mainloop()