Get the blocks that need to be migrated
163660
def getBlocks(self):
        
        try:
            conn = self.dbi.connection()
            result = self.buflistblks.execute(conn)
            return result
        finally:
            if conn:
                conn.close()
860658
def processing_blocks(self):
        """"""
        pb_list = ProcessingBlockList()
        # TODO(BMo) realtime, offline etc.
        return json.dumps(dict(active=pb_list.active,
                               completed=pb_list.completed,
                               aborted=pb_list.aborted))
1333266
protected function magic_get_blocks() {
        global $CFG;
        if (is_null($this->_blocks)) {
            if (!empty($CFG->blockmanagerclass)) {
                if (!empty($CFG->blockmanagerclassfile)) {
                    require_once($CFG->blockmanagerclassfile);
                }
                $classname = $CFG->blockmanagerclass;
            } else {
                $classname = 'block_manager';
            }
            $this->_blocks = new $classname($this);
        }
        return $this->_blocks;
    }
472104
def get_pending_migrations(path, databases=None, stop_at=None):
    
    if stop_at is None:
        stop_at = float("inf")
    
    # database: [(number, full_path)]
    possible_migrations = get_all_migrations(path, databases)
    # database: [full_path]
    applied_migrations = get_applied_migrations(databases)
    # database: [full_path]
    to_execute = defaultdict(list)
    
    for database, scripts in possible_migrations.iteritems():
        applied = applied_migrations[database]
        pending = to_execute[database]
        for number, migration in scripts:
            path, script = os.path.split(migration)
            if script not in applied and number <= stop_at:
                pending.append(script)
    
    return dict((k, v) for k, v in to_execute.iteritems() if v)
1050871
def get_scheduling_block(sub_array_id, block_id):
    """"""
    block_ids = DB.get_sub_array_sbi_ids(sub_array_id)
    if block_id in block_ids:
        block = DB.get_block_details([block_id]).__next__()
        return block, HTTPStatus.OK

    return dict(error="unknown id"), HTTPStatus.NOT_FOUND
878031
public function getGlobalBlocks()
    {
        $db = Loader::db();
        $v = [Stack::ST_TYPE_GLOBAL_AREA];
        $rs = $db->GetCol('select stName from Stacks where Stacks.stType = ?', $v);
        $blocks = [];
        if (count($rs) > 0) {
            $pcp = new Permissions($this);
            foreach ($rs as $garHandle) {
                if ($pcp->canViewPageVersions()) {
                    $s = Stack::getByName($garHandle, 'RECENT');
                } else {
                    $s = Stack::getByName($garHandle, 'ACTIVE');
                }
                if (is_object($s)) {
                    $blocksTmp = $s->getBlocks(STACKS_AREA_NAME);
                    $blocks = array_merge($blocks, $blocksTmp);
                }
            }
        }

        return $blocks;
    }
1211338
def get_migrations(self):
        
        return github.PaginatedList.PaginatedList(
            github.Migration.Migration,
            self._requester,
            "/orgs/" + self.login + "/migrations",
            None,
            headers={
                "Accept": Consts.mediaTypeMigrationPreview
            }
        )
736232
async def blocks(client: Client, pubkey: str, start: int, end: int) -> dict:
    
    return await client.get(MODULE + '/history/%s/blocks/%s/%s' % (pubkey, start, end), schema=HISTORY_SCHEMA)
337428
def get_blocks(self, chrom, start, end):
    
    if chrom not in self.block_trees:
      return []
    return self.block_trees[chrom].intersectingInterval(start, end)
260766
def _get_migrate_command():
    '''
    
    '''
    tunnel = __salt__['config.option']('virt.tunnel')
    if tunnel:
        salt.utils.versions.warn_until(
            'Sodium',
            '\'virt.tunnel\' has been deprecated in favor of '
            '\'virt:tunnel\'. \'virt.tunnel\' will stop '
            'being used in {version}.')
    else:
        tunnel = __salt__['config.get']('virt:tunnel')
    if tunnel:
        return ('virsh migrate --p2p --tunnelled --live --persistent '
                '--undefinesource ')
    return 'virsh migrate --live --persistent --undefinesource '
223479
public function transform($block)
    {
        $block = $this->entityToArray(Block::class, $block);
        return [
            'id'          => $this->setNullableValue($block['id']),
            'type'        => $block['type'],
            'region'      => $block['region'],
            'filter'      => $block['filter'],
            'options'     => $block['options'],
            'theme'       => $block['theme'],
            'weight'      => (int) $block['weight'],
            'isActive'    => (bool) $block['is_active'],
            'isCacheable' => (bool) $block['is_cacheable'],
            'createdAt'   => $block['created_at'],
            'updatedAt'   => $block['updated_at']
        ];
    }
669697
def listMigrationRequests(self, migration_request_id="", block_name="",
                              dataset="", user="", oldest=False):
        

        conn = self.dbi.connection()
        migratee = ""
        try:
            if block_name:
                migratee = block_name
            elif dataset:
                migratee = dataset
            result = self.mgrlist.execute(conn, migration_url="",
                    migration_input=migratee, create_by=user,
                    migration_request_id=migration_request_id, oldest=oldest)
            return result

        finally:
            if conn: conn.close()
734821
protected function getMigrations($version_tag = false, $flatList = false, $configuration = [])
    {
        //Get migration definitions by tag
        $migrations = array_filter(
            $this->pluginManagerMigration->getDefinitions(), function ($migration) use ($version_tag) {
                return !empty($migration['migration_tags']) && in_array($version_tag, $migration['migration_tags']);
            }
        );

        // Create an array to configure all migration plugins with same configuration
        $keys = array_keys($migrations);
        $migration_plugin_configuration = array_fill_keys($keys, $configuration);

        //Create all migration instances
        $all_migrations = $this->pluginManagerMigration->createInstances(array_keys($migrations), $migration_plugin_configuration);

        $migrations = [];
        foreach ($all_migrations as $migration) {
            if ($flatList) {
                $migrations[$migration->id()] = ucwords($migration->label());
            } else {
                $migrations[$migration->id()]['tags'] = implode(', ', $migration->getMigrationTags());
                $migrations[$migration->id()]['description'] = ucwords($migration->label());
            }
        }
        return  $migrations;
    }
705631
private static Block convertBlock(TBlock tblk) {
    return new Block(tblk.getBlockId(), 
                     tblk.getNumBytes(),
                     tblk.getGenerationStamp());
  }
199461
def _load_blocks(self, blocks: List[Tuple[Key, Any]]) -> List[TimeAggregate]:
        
        return [
            TypeLoader.load_item(self._schema.source.type)(self._schema.source, self._identity,
                                                           EvaluationContext()).run_restore(block)
            for (_, block) in blocks
        ]
1292721
protected function _prepareBlocks()
    {
        $cacheKey = "{$this->_View->theme}_{$this->_machineName}";
        $blocks = TableRegistry::get('Block.Blocks')
            ->find('all')
            ->cache($cacheKey, 'blocks')
            ->contain(['Roles', 'BlockRegions'])
            ->matching('BlockRegions', function ($q) {
                return $q->where([
                    'BlockRegions.theme' => $this->_View->theme(),
                    'BlockRegions.region' => $this->_machineName,
                ]);
            })
            ->where(['Blocks.status' => 1])
            ->order(['BlockRegions.ordering' => 'ASC']);

        $blocks->sortBy(function ($block) {
            return $block->region->ordering;
        }, SORT_ASC);

        // remove blocks that cannot be rendered based on current request.
        $blocks = $blocks->filter(function ($block) {
            return $this->_filterBlock($block) && $block->renderable();
        });

        $this->blocks($blocks);
    }
1126832
function importNonBlocks(blocks, tokens) {
    var temp = [];
    utils.each(blocks, function (block) { temp.push(block); });
    utils.each(temp.reverse(), function (block) {
      if (block.name !== 'block') {
        tokens.unshift(block);
      }
    });
  }