loading registers from unicorn
541765
def get_regs(self):
        '''  '''

        # first, get the ignore list (in case of symbolic registers)
        if options.UNICORN_SYM_REGS_SUPPORT in self.state.options:
            highest_reg_offset, reg_size = max(self.state.arch.registers.values())
            symbolic_list = (ctypes.c_uint64*(highest_reg_offset + reg_size))()
            num_regs = _UC_NATIVE.get_symbolic_registers(self._uc_state, symbolic_list)

            # we take the approach of saving off the symbolic regs and then writing them back
            saved_registers = [ ]
            cur_group = None
            last = None
            for i in sorted(symbolic_list[:num_regs]):
                if cur_group is None:
                    cur_group = i
                elif i != last + 1 or cur_group//self.state.arch.bytes != i//self.state.arch.bytes:
                    saved_registers.append((
                        cur_group, self.state.registers.load(cur_group, last-cur_group+1)
                    ))
                    cur_group = i
                last = i
            if cur_group is not None:
                saved_registers.append((
                    cur_group, self.state.registers.load(cur_group, last-cur_group+1)
                ))

        # now we sync registers out of unicorn
        for r, c in self._uc_regs.items():
            if r in self.reg_blacklist:
                continue
            v = self.uc.reg_read(c)
            # l.debug('getting $%s = %#x', r, v)
            setattr(self.state.regs, r, v)

        # some architecture-specific register fixups
        if self.state.arch.name in ('X86', 'AMD64'):
            if self.jumpkind.startswith('Ijk_Sys'):
                self.state.registers.store('ip_at_syscall', self.state.regs.ip - 2)

            # update the eflags
            self.state.regs.eflags = self.state.solver.BVV(self.uc.reg_read(self._uc_const.UC_X86_REG_EFLAGS), self.state.arch.bits)

            # sync the fp clerical data
            status = self.uc.reg_read(unicorn.x86_const.UC_X86_REG_FPSW)
            c3210 = status & 0x4700
            top = (status & 0x3800) >> 11
            control = self.uc.reg_read(unicorn.x86_const.UC_X86_REG_FPCW)
            rm = (control & 0x0C00) >> 10
            self.state.regs.fpround = rm
            self.state.regs.fc3210 = c3210
            self.state.regs.ftop = top

            # sync the stx registers
            # we gotta round the 80-bit extended precision values to 64-bit doubles!
            uc_offset = unicorn.x86_const.UC_X86_REG_FP0
            vex_offset = self.state.arch.registers['fpu_regs'][0]
            vex_tag_offset = self.state.arch.registers['fpu_tags'][0] + 7
            tag_word = self.uc.reg_read(unicorn.x86_const.UC_X86_REG_FPTAG)

            for _ in range(8):
                if tag_word & 3 == 3:
                    self.state.registers.store(vex_tag_offset, 0, size=1)
                else:
                    self.state.registers.store(vex_tag_offset, 1, size=1)

                    mantissa, exponent = self.uc.reg_read(uc_offset)
                    sign = bool(exponent & 0x8000)
                    exponent = (exponent & 0x7FFF)
                    if exponent not in (0, 0x7FFF): # normal value
                        exponent = exponent - 16383 + 1023
                        if exponent <= 0:   # underflow to zero
                            exponent = 0
                            mantissa = 0
                        elif exponent >= 0x7FF: # overflow to infinity
                            exponent = 0x7FF
                            mantissa = 0
                    elif exponent == 0:     # zero or subnormal value
                        mantissa = 0
                    elif exponent == 0x7FFF:    # nan or infinity
                        exponent = 0x7FF
                        if mantissa != 0:
                            mantissa = 0xFFFF

                    val = 0x8000000000000000 if sign else 0
                    val |= exponent << 52
                    val |= (mantissa >> 11) & 0xFFFFFFFFFFFFF
                    # the mantissa calculation is to convert from the 64-bit mantissa to 52-bit
                    # additionally, extended precision keeps around an high bit that we don't care about
                    # so 11-shift, not 12

                    self.state.registers.store(vex_offset, val, size=8)

                uc_offset += 1
                vex_offset += 8
                tag_word >>= 2
                vex_tag_offset -= 1

        # now, we restore the symbolic registers
        if options.UNICORN_SYM_REGS_SUPPORT in self.state.options:
            for o,r in saved_registers:
                self.state.registers.store(o, r)
1265023
def load_ipython_extension(ipython):
    """"""
    from google.cloud.bigquery.magics import _cell_magic

    ipython.register_magic_function(
        _cell_magic, magic_kind="cell", magic_name="bigquery"
    )
817788
def register_finders():
  """"""

  # If the previous finder is set, then we've already monkeypatched, so skip.
  global __PREVIOUS_FINDER
  if __PREVIOUS_FINDER:
    return

  # save previous finder so that it can be restored
  previous_finder = _get_finder(zipimport.zipimporter)
  assert previous_finder, 'This appears to be using an incompatible setuptools.'

  # Enable finding zipped wheels.
  pkg_resources.register_finder(
      zipimport.zipimporter, ChainedFinder.of(pkg_resources.find_eggs_in_zip, find_wheels_in_zip))

  # append the wheel finder
  _add_finder(pkgutil.ImpImporter, find_wheels_on_path)

  if importlib_machinery is not None:
    _add_finder(importlib_machinery.FileFinder, find_wheels_on_path)

  __PREVIOUS_FINDER = previous_finder
612202
def _start(self):
        """"""
        cls = self._get_manager_class(register_callables=True)
        ins = cls(address=self.addr, authkey=self.authkey)
        ins.start()
        return ins
349461
def init_tag_processors(self):
        ''''''
        register = self.register_tag_processor

        register('class', classTagProcessor(**self.opts))
        register('file', fileTagProcessor(**self.opts))
        register('namespace', namespaceTagProcessor(**self.opts))
        register('struct', structTagProcessor(**self.opts))
        register('union', unionTagProcessor(**self.opts))
        register('function', functionTagProcessor(**self.opts))
        register('define', defineTagProcessor(**self.opts))
        register('enumeration', enumerationTagProcessor(**self.opts))
        register('enumvalue', enumvalueTagProcessor(**self.opts))
        register('typedef', typedefTagProcessor(**self.opts))
        register('variable', variableTagProcessor(**self.opts))
627215
def load_modules(self, data=None, proxy=None):
        '''
        
        '''
        log.info('Loading fresh modules for state activity')
        # Load a modified client interface that looks like the interface used
        # from the minion, but uses remote execution
        #
        self.functions = salt.client.FunctionWrapper(
                self.opts,
                self.opts['id']
                )
        # Load the states, but they should not be used in this class apart
        # from inspection
        self.utils = salt.loader.utils(self.opts)
        self.serializers = salt.loader.serializers(self.opts)
        self.states = salt.loader.states(self.opts, self.functions, self.utils, self.serializers)
        self.rend = salt.loader.render(self.opts, self.functions, states=self.states, context=self.state_con)
1102624
def jit_load(self):
        
        try:
            model = importlib.import_module('.' + self.model, 'andes.models')
            device = getattr(model, self.device)
            self.system.__dict__[self.name] = device(self.system, self.name)

            g = self.system.__dict__[self.name]._group
            self.system.group_add(g)
            self.system.__dict__[g].register_model(self.name)

            # register device after loading
            self.system.devman.register_device(self.name)
            self.loaded = 1
            logger.debug('Imported model <{:s}.{:s}>.'.format(
                self.model, self.device))
        except ImportError:
            logger.error(
                'non-JIT model <{:s}.{:s}> import error'
                .format(self.model, self.device))
        except AttributeError:
            logger.error(
                'model <{:s}.{:s}> not exist. Check models/__init__.py'
                .format(self.model, self.device))
872187
def register_entrypoints(self):
        
        for spec in iter_entry_points(self.entry_point_group):
            format_properties = {"name": spec.name}
            try:
                format_properties.update(spec.load())
            except (DistributionNotFound, ImportError) as err:
                self.log.info(
                    "ipymd format {} could not be loaded: {}".format(
                        spec.name, err))
                continue

            self.register(**format_properties)

        return self
1198342
def load_data_batch(self, data_batch):
        """"""
        if self.sym_gen is not None:
            key = data_batch.bucket_key
            if key not in self.execgrp_bucket:
                # create new bucket entry
                symbol = self.sym_gen(key)
                execgrp = DataParallelExecutorGroup(symbol, self.arg_names,
                                                    self.param_names, self.ctx,
                                                    self.slices, data_batch,
                                                    shared_group=self.execgrp)
                self.execgrp_bucket[key] = execgrp

            self.curr_execgrp = self.execgrp_bucket[key]
        else:
            self.curr_execgrp = self.execgrp

        self.curr_execgrp.load_data_batch(data_batch)
890931
def load_accelerators(self):
        

        def getk(x):
            return self.guake.settings.keybindingsLocal.get_string(x)

        key, mask = Gtk.accelerator_parse(getk('reset-terminal'))

        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_reset_terminal
            )

        key, mask = Gtk.accelerator_parse(getk('quit'))
        if key > 0:
            self.accel_group.connect(key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_quit)

        key, mask = Gtk.accelerator_parse(getk('new-tab'))
        if key > 0:
            self.accel_group.connect(key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_add)

        key, mask = Gtk.accelerator_parse(getk('new-tab-home'))
        if key > 0:
            self.accel_group.connect(key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_add_home)

        key, mask = Gtk.accelerator_parse(getk('close-tab'))
        if key > 0:

            def x(*args):
                prompt_cfg = self.guake.settings.general.get_int('prompt-on-close-tab')
                self.guake.get_notebook().delete_page_current(prompt=prompt_cfg)

            self.accel_group.connect(key, mask, Gtk.AccelFlags.VISIBLE, x)

        key, mask = Gtk.accelerator_parse(getk('previous-tab'))
        if key > 0:
            self.accel_group.connect(key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_prev)

        key, mask = Gtk.accelerator_parse(getk('next-tab'))
        if key > 0:
            self.accel_group.connect(key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_next)

        key, mask = Gtk.accelerator_parse(getk('move-tab-left'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_move_tab_left
            )

        key, mask = Gtk.accelerator_parse(getk('move-tab-right'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_move_tab_right
            )

        key, mask = Gtk.accelerator_parse(getk('rename-current-tab'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_rename_current_tab
            )

        key, mask = Gtk.accelerator_parse(getk('clipboard-copy'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_copy_clipboard
            )

        key, mask = Gtk.accelerator_parse(getk('clipboard-paste'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_paste_clipboard
            )

        key, mask = Gtk.accelerator_parse(getk('toggle-fullscreen'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_toggle_fullscreen
            )

        key, mask = Gtk.accelerator_parse(getk('toggle-hide-on-lose-focus'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_toggle_hide_on_lose_focus
            )

        key, mask = Gtk.accelerator_parse(getk('zoom-in'))
        if key > 0:
            self.accel_group.connect(key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_zoom_in)

        key, mask = Gtk.accelerator_parse(getk('zoom-in-alt'))
        if key > 0:
            self.accel_group.connect(key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_zoom_in)

        key, mask = Gtk.accelerator_parse(getk('zoom-out'))
        if key > 0:
            self.accel_group.connect(key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_zoom_out)

        key, mask = Gtk.accelerator_parse(getk('increase-height'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_increase_height
            )

        key, mask = Gtk.accelerator_parse(getk('decrease-height'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_decrease_height
            )

        key, mask = Gtk.accelerator_parse(getk('increase-transparency'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_increase_transparency
            )

        key, mask = Gtk.accelerator_parse(getk('decrease-transparency'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_decrease_transparency
            )

        key, mask = Gtk.accelerator_parse(getk('toggle-transparency'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_toggle_transparency
            )

        for tab in range(1, 11):
            key, mask = Gtk.accelerator_parse(getk('switch-tab%d' % tab))
            if key > 0:
                self.accel_group.connect(
                    key, mask, Gtk.AccelFlags.VISIBLE, self.guake.gen_accel_switch_tabN(tab - 1)
                )

        key, mask = Gtk.accelerator_parse(getk('switch-tab-last'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_switch_tab_last
            )

        try:
            key, mask = Gtk.accelerator_parse(getk('search-on-web'))
            if key > 0:
                self.accel_group.connect(
                    key, mask, Gtk.AccelFlags.VISIBLE, self.guake.search_on_web
                )
        except Exception:
            log.exception("Exception occured")

        key, mask = Gtk.accelerator_parse(getk('split-tab-vertical'))
        if key > 0:
            self.accel_group.connect(
                key,
                mask,
                Gtk.AccelFlags.VISIBLE,
                (
                    lambda *args:  # keep make style from concat this lines
                    self.guake.get_notebook().get_current_terminal().get_parent().split_v() or True
                )
            )
        key, mask = Gtk.accelerator_parse(getk('split-tab-horizontal'))
        if key > 0:
            self.accel_group.connect(
                key,
                mask,
                Gtk.AccelFlags.VISIBLE,
                (
                    lambda *args:  # keep make style from concat this lines
                    self.guake.get_notebook().get_current_terminal().get_parent().split_h() or True
                )
            )
        key, mask = Gtk.accelerator_parse(getk('close-terminal'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE,
                (lambda *args: self.guake.get_notebook().get_current_terminal().kill() or True)
            )
        key, mask = Gtk.accelerator_parse(getk('focus-terminal-up'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, (
                    lambda *args: FocusMover(self.guake.window).
                    move_up(self.guake.get_notebook().get_current_terminal()) or True
                )
            )
        key, mask = Gtk.accelerator_parse(getk('focus-terminal-down'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, (
                    lambda *args: FocusMover(self.guake.window).
                    move_down(self.guake.get_notebook().get_current_terminal()) or True
                )
            )
        key, mask = Gtk.accelerator_parse(getk('focus-terminal-right'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, (
                    lambda *args: FocusMover(self.guake.window).
                    move_right(self.guake.get_notebook().get_current_terminal()) or True
                )
            )
        key, mask = Gtk.accelerator_parse(getk('focus-terminal-left'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, (
                    lambda *args: FocusMover(self.guake.window).
                    move_left(self.guake.get_notebook().get_current_terminal()) or True
                )
            )
        key, mask = Gtk.accelerator_parse(getk('move-terminal-split-up'))
        if key > 0:
            self.accel_group.connect(
                key,
                mask,
                Gtk.AccelFlags.VISIBLE,
                (
                    lambda *args:  # keep make style from concat this lines
                    SplitMover.move_up(self.guake.get_notebook().get_current_terminal()) or True
                )
            )
        key, mask = Gtk.accelerator_parse(getk('move-terminal-split-down'))
        if key > 0:
            self.accel_group.connect(
                key,
                mask,
                Gtk.AccelFlags.VISIBLE,
                (
                    lambda *args:  # keep make style from concat this lines
                    SplitMover.move_down(self.guake.get_notebook().get_current_terminal()) or True
                )
            )
        key, mask = Gtk.accelerator_parse(getk('move-terminal-split-left'))
        if key > 0:
            self.accel_group.connect(
                key,
                mask,
                Gtk.AccelFlags.VISIBLE,
                (
                    lambda *args:  # keep make style from concat this lines
                    SplitMover.move_left(self.guake.get_notebook().get_current_terminal()) or True
                )
            )
        key, mask = Gtk.accelerator_parse(getk('move-terminal-split-right'))
        if key > 0:
            self.accel_group.connect(
                key,
                mask,
                Gtk.AccelFlags.VISIBLE,
                (
                    lambda *args:  # keep make style from concat this lines
                    SplitMover.move_right(self.guake.get_notebook().get_current_terminal()) or True
                )
            )

        key, mask = Gtk.accelerator_parse(getk('search-terminal'))
        if key > 0:
            self.accel_group.connect(
                key, mask, Gtk.AccelFlags.VISIBLE, self.guake.accel_search_terminal
            )
405322
def register_plugin_module(mod):
    """"""
    for k, v in load_plugins_from_module(mod).items():
        if k:
            if isinstance(k, (list, tuple)):
                k = k[0]
            global_registry[k] = v
973519
def register(cls):
        
        if not cls.IS_LOADED:
            cls.IS_LOADED = True

            yaml.add_constructor('!param', Parameter.parameter_constructor, Loader=yaml.SafeLoader)
            yaml.add_constructor('!env', EnvironmentVariable.parameter_constructor, Loader=yaml.SafeLoader)
1255962
def _loadlib(lib='standard'):
    """"""
    global _LIB
    if _LIB is not None:
        warnings.warn('rabit.int call was ignored because it has'\
                          ' already been initialized', level=2)
        return
    if lib == 'standard':
        _LIB = ctypes.cdll.LoadLibrary(WRAPPER_PATH % '')
    elif lib == 'mock':
        _LIB = ctypes.cdll.LoadLibrary(WRAPPER_PATH % '_mock')
    elif lib == 'mpi':
        _LIB = ctypes.cdll.LoadLibrary(WRAPPER_PATH % '_mpi')
    else:
        raise Exception('unknown rabit lib %s, can be standard, mock, mpi' % lib)
    _LIB.RabitGetRank.restype = ctypes.c_int
    _LIB.RabitGetWorldSize.restype = ctypes.c_int
    _LIB.RabitVersionNumber.restype = ctypes.c_int
1201561
def _register_resources(self, api_dirs, do_checks):
        ''''''
        msg = 'Looking-up for APIs in the following directories: {}'
        log.debug(msg.format(api_dirs))
        if do_checks:
            check_and_load(api_dirs)
        else:
            msg = 'Loading module "{}" from directory "{}"'
            for loader, mname, _ in pkgutil.walk_packages(api_dirs):
                sys.path.append(os.path.abspath(loader.path))
                log.debug(msg.format(mname, loader.path))
                import_module(mname)
797654
def load_states():
    '''
    
    '''
    states = {}

    # the loader expects to find pillar & grain data
    __opts__['grains'] = salt.loader.grains(__opts__)
    __opts__['pillar'] = __pillar__
    lazy_utils = salt.loader.utils(__opts__)
    lazy_funcs = salt.loader.minion_mods(__opts__, utils=lazy_utils)
    lazy_serializers = salt.loader.serializers(__opts__)
    lazy_states = salt.loader.states(__opts__,
            lazy_funcs,
            lazy_utils,
            lazy_serializers)

    # TODO: some way to lazily do this? This requires loading *all* state modules
    for key, func in six.iteritems(lazy_states):
        if '.' not in key:
            continue
        mod_name, func_name = key.split('.', 1)
        if mod_name not in states:
            states[mod_name] = {}
        states[mod_name][func_name] = func

    __context__['pyobjects_states'] = states
244941
function registerJytPlugins() {
    var rootDir = this.pancakes.getRootDir();
    var pluginDir = path.normalize(rootDir + '/app/common/jyt.plugins');
    var me = this;

    // if plugin dir doesn't exist, just return
    if (!fs.existsSync(pluginDir)) { return;  }

    // else get all plugin files from the jyt.plugins dir
    var pluginFiles = fs.readdirSync(pluginDir);
    var deps = { dependencies: me.getJangularDeps() };
    _.each(pluginFiles, function (pluginFile) {
        var name = me.dotToCamelCase(pluginFile);
        var pluginFlapjack = me.pancakes.requireModule(pluginDir + delim + pluginFile);
        var plugin = me.pancakes.cook(pluginFlapjack, deps);
        jangular.registerPlugin(name, plugin);
        me.jangularDeps[name] = plugin;
    });
}
837609
def load_plugins(self):
        
        for entry_point in CINQ_PLUGINS['cloud_inquisitor.plugins.collectors']['plugins']:
            cls = entry_point.load()
            if cls.enabled():
                self.log.debug('Collector loaded: {} in module {}'.format(cls.__name__, cls.__module__))
                self.collectors.setdefault(cls.type, []).append(Worker(
                    cls.name,
                    cls.interval,
                    {
                        'name': entry_point.name,
                        'module_name': entry_point.module_name,
                        'attrs': entry_point.attrs
                    }
                ))
            else:
                self.log.debug('Collector disabled: {} in module {}'.format(cls.__name__, cls.__module__))

        for entry_point in CINQ_PLUGINS['cloud_inquisitor.plugins.auditors']['plugins']:
            cls = entry_point.load()
            if cls.enabled():
                self.log.debug('Auditor loaded: {} in module {}'.format(cls.__name__, cls.__module__))
                self.auditors.append(Worker(
                    cls.name,
                    cls.interval,
                    {
                        'name': entry_point.name,
                        'module_name': entry_point.module_name,
                        'attrs': entry_point.attrs
                    }
                ))
            else:
                self.log.debug('Auditor disabled: {} in module {}'.format(cls.__name__, cls.__module__))

        collector_count = sum(len(x) for x in self.collectors.values())
        auditor_count = len(self.auditors)

        if collector_count + auditor_count == 0:
            raise Exception('No auditors or collectors loaded, aborting scheduler')

        self.log.info('Scheduler loaded {} collectors and {} auditors'.format(collector_count, auditor_count))