Beispiel #1
0
def define_commands(dictionary):
    print "Ipython detected - magicing commands"
    magiced_names = []
    commands = hkl_commands_for_help + ub_commands_for_help  # @UndefinedVariable
    commands += [pos, scan]  # @UndefinedVariable
    ipython.GLOBAL_NAMESPACE_DICT = dictionary
    for f in commands:
        # Skip section headers like 'Motion'
        if not hasattr(f, '__call__'):
            continue
        
        # magic the function and remove from namespace (otherwise it would
        # shadow the magiced command)
        register_line_magic(parse_line(f))
        del dictionary[f.__name__]
        command_map[f.__name__] = f
        magiced_names.append(f.__name__)
    
    print "Magiced commands: " + ' '.join(magiced_names) 
    
    # because the functions have gone from namespace we need to override
    pythons_help = __builtins__.help
    del __builtins__.help
    
    register_line_magic(help)
    del help
Beispiel #2
0
#     chi = ScannableAdapter(satilt, 'chi', 90)  # chi = satilt + 90deg
#     phi = ScannableAdapter(saazimuth, 'phi')
    
    def usediode():
        _fourc.delta_scn = diodetth
        setmin(delta, 0)
        setmax(delta, 180)
        
    def usevessel():
        _fourc.delta_scn = m5tth
        setmin(delta, 0)
        setmax(delta, 150)
        
    if IPYTHON:
        from IPython import get_ipython  # @UnresolvedImport @UnusedImport
        register_line_magic(parse_line(usediode, globals()))
        del usediode
        register_line_magic(parse_line(usevessel, globals()))
        del usevessel
        register_line_magic(parse_line(centresample, globals()))
        del centresample
        register_line_magic(parse_line(zerosample, globals()))
        del zerosample
        register_line_magic(parse_line(toolpoint_on, globals()))
        del toolpoint_on
        register_line_magic(parse_line(toolpoint_off, globals()))
        del toolpoint_off

        
print "Created i21 bespoke commands: usediode & usevessel"
Beispiel #3
0
    from gda.jython.commands.GeneralCommands import alias  # @UnresolvedImport
    alias("usem5tth")
    alias("uselowq")
    alias("usehighq")
    alias("usedifftth")
    alias("usem5tth_tp")
    alias("uselowq_tp")
    alias("usehighq_tp")
    alias("usedifftth_tp")
    alias("usesim")
else:
    from IPython.core.magic import register_line_magic  # @UnresolvedImport
    from diffcmd.ipython import parse_line
    if IPYTHON:
        from IPython import get_ipython  # @UnresolvedImport @UnusedImport
        register_line_magic(parse_line(usem5tth, globals()))
        del usem5tth
        register_line_magic(parse_line(uselowq, globals()))
        del uselowq
        register_line_magic(parse_line(usehighq, globals()))
        del usehighq
        register_line_magic(parse_line(usedifftth, globals()))
        del usedifftth
        register_line_magic(parse_line(usem5tth_tp, globals()))
        del usem5tth_tp
        register_line_magic(parse_line(uselowq_tp, globals()))
        del uselowq_tp
        register_line_magic(parse_line(usehighq_tp, globals()))
        del usehighq_tp
        register_line_magic(parse_line(usedifftth_tp, globals()))
        del usedifftth_tp
Beispiel #4
0
    from IPython.core.magic import register_line_magic
    from diffcmd.ipython import parse_line
    delta = ScannableAdapter(diode_tth, 'delta')  # or vessel_tth
    eta = ScannableAdapter(sapol, 'eta')
    chi = ScannableAdapter(satilt, 'chi', 90)  # chi = satilt + 90deg
    phi = ScannableAdapter(saaz, 'phi')
    
    def usediode():
        delta.delegate_scn = diode_tth
    
    def usevessel():
        delta.delegate_scn = vessel_tth
        
    if IPYTHON:
        from IPython import get_ipython
        register_line_magic(parse_line(usediode, globals()))
        del usediode
        register_line_magic(parse_line(usevessel, globals()))
        del usevessel
        
print "Created i21 bespoke commands: usediode & usevessel"
 
_fourc = ScannableGroup('_fourc', (delta, eta, chi, phi))
en = Dummy('en')
en.level = 3
 
 
### Configure and import diffcalc objects ###
ESMTGKeV = 1
settings.hardware = ScannableHardwareAdapter(_fourc, en, ESMTGKeV)
settings.geometry = diffcalc.hkl.you.geometry.FourCircle()  # @UndefinedVariable