Get unordered list of scheduling block ids
425697
def get_sched_block_instance_ids(self):
        """"""

        # Initialise empty list
        scheduling_block_ids = []

        # Pattern used to search scheduling block ids
        pattern = 'scheduling_block:*'
        block_ids = self._db.get_ids(pattern)

        for block_id in block_ids:
            if 'processing_block' not in block_id:
                id_split = block_id.split(':')[-1]
                scheduling_block_ids.append(id_split)
        return sorted(scheduling_block_ids)
170674
def get_next_schedule_brok(self):
        
        data = {'uuid': self.uuid}
        self.fill_data_brok_from(data, 'next_schedule')
        return Brok({'type': self.my_type + '_next_schedule', 'data': data})
644838
def list(gandi, domain, zone_id, output, format, limit):
    """"""
    options = {
        'items_per_page': limit,
    }
    output_keys = ['name', 'type', 'value', 'ttl']

    if not zone_id:
        result = gandi.domain.info(domain)
        zone_id = result['zone_id']

    if not zone_id:
        gandi.echo('No zone records found, domain %s doesn\'t seems to be '
                   'managed at Gandi.' % domain)
        return

    records = gandi.record.list(zone_id, options)

    if not output and not format:
        for num, rec in enumerate(records):
            if num:
                gandi.separator_line()
            output_generic(gandi, rec, output_keys, justify=12)
    elif output:
        zone_filename = domain + "_" + str(zone_id)
        if os.path.isfile(zone_filename):
            open(zone_filename, 'w').close()
        for record in records:
            format_record = ('%s %s IN %s %s' %
                             (record['name'], record['ttl'],
                              record['type'], record['value']))
            with open(zone_filename, 'ab') as zone_file:
                zone_file.write(format_record + '\n')
        gandi.echo('Your zone file have been writen in %s' % zone_filename)
    elif format:
        if format == 'text':
            for record in records:
                format_record = ('%s %s IN %s %s' %
                                 (record['name'], record['ttl'],
                                  record['type'], record['value']))
                gandi.echo(format_record)
        if format == 'json':
            format_record = json.dumps(records, sort_keys=True,
                                       indent=4, separators=(',', ': '))
            gandi.echo(format_record)

    return records
2268
function getScheduledName(arr) {
    var name = arr.slice(0).shift()
    return [`${app}-production-${name}`, `${app}-staging-${name}`]
  }
866047
def scheduling_blocks():
    """"""
    sbi_list = SchedulingBlockInstanceList()
    return dict(active=sbi_list.active,
                completed=sbi_list.completed,
                aborted=sbi_list.aborted)
426213
async def listCronJobs(self):
        '''
        
        '''
        crons = []
        for iden, cron in self.cell.agenda.list():
            useriden = cron['useriden']
            if not (self.user.admin or useriden == self.user.iden):
                continue
            user = self.cell.auth.user(useriden)
            cron['username'] = '<unknown>' if user is None else user.name
            crons.append((iden, cron))

        return crons
1232673
def job_ids(log_stream):
    """"""
    id_rows = [line for line in log_stream if 'scancel' in line]
    jobs = [id_row.strip()[-7:-1] for id_row in id_rows]
    return jobs
916848
def _scheduling_block_ids(num_blocks, start_id, project):
    """"""
    for i in range(num_blocks):
        _root = '{}-{}'.format(strftime("%Y%m%d", gmtime()), project)
        yield '{}-sb{:03d}'.format(_root, i + start_id), \
              '{}-sbi{:03d}'.format(_root, i + start_id)
272759
def gen_schedule(user, num_blocks=6, surrounding_blocks=None):
    
    no_signup_today = None
    schedule = []

    if surrounding_blocks is None:
        surrounding_blocks = EighthBlock.objects.get_upcoming_blocks(num_blocks)

    if len(surrounding_blocks) == 0:
        return None, False

    # Use select_related to reduce query count
    signups = (EighthSignup.objects.filter(user=user, scheduled_activity__block__in=surrounding_blocks).select_related(
        "scheduled_activity", "scheduled_activity__block", "scheduled_activity__activity"))
    block_signup_map = {s.scheduled_activity.block.id: s.scheduled_activity for s in signups}

    for b in surrounding_blocks:
        current_sched_act = block_signup_map.get(b.id, None)
        if current_sched_act:
            current_signup = current_sched_act.title_with_flags
            current_signup_cancelled = current_sched_act.cancelled
            current_signup_sticky = current_sched_act.activity.sticky
            rooms = current_sched_act.get_scheduled_rooms()
        else:
            current_signup = None
            current_signup_cancelled = False
            current_signup_sticky = False
            rooms = None

        # warning flag (red block text and signup link) if no signup today
        # cancelled flag (red activity text) if cancelled
        flags = "locked" if b.locked else "open"
        blk_today = b.is_today()
        if blk_today and not current_signup:
            flags += " warning"
        if current_signup_cancelled:
            flags += " cancelled warning"

        if current_signup_cancelled:
            # don't duplicate this info; already caught
            current_signup = current_signup.replace(" (Cancelled)", "")

        info = {
            "id": b.id,
            "block": b,
            "block_letter": b.block_letter,
            "current_signup": current_signup,
            "current_signup_cancelled": current_signup_cancelled,
            "current_signup_sticky": current_signup_sticky,
            "locked": b.locked,
            "date": b.date,
            "flags": flags,
            "is_today": blk_today,
            "signup_time": b.signup_time,
            "signup_time_future": b.signup_time_future,
            "rooms": rooms
        }
        schedule.append(info)

        if blk_today and not current_signup:
            no_signup_today = True

    return schedule, no_signup_today
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
77617
def getBufferedFiles(self, block_id):
        
            
        try:
            conn = self.dbi.connection()
            result = self.buflist.execute(conn, block_id)
            return result
        finally:
            if conn:
                conn.close()
681413
def _split_sched_block_instance(self, scheduling_block):
        """"""

        # Initialise empty list
        _scheduling_block_data = {}
        _processing_block_data = {}
        _processing_block_id = []

        for block in scheduling_block:
            values = scheduling_block[block]

            if block != 'processing_blocks':
                _scheduling_block_data[block] = values
            else:
                # Check if there is a processing block that already exits in
                # the database
                processing_block_id = self.get_processing_block_ids()

                for value in values:
                    if value['id'] not in processing_block_id:
                        _processing_block_data = values
                    else:
                        raise Exception("Processing block already exits",
                                        value['id'])

        # Adding processing block id to the scheduling block list
        for block_id in _processing_block_data:
            _processing_block_id.append(block_id['id'])
        _scheduling_block_data['processing_block_ids'] = _processing_block_id

        return _scheduling_block_data, _processing_block_data
1141959
def _add_status(scheduling_block):
        """"""
        scheduling_block['status'] = "created"
        for block in scheduling_block:
            if isinstance(scheduling_block[block], list):
                for field in scheduling_block[block]:
                    field['status'] = 'created'
        return scheduling_block
1187181
def _build_block_element_list(self):
        
        return sorted(
            [e for e in self.block_elements.values() if not e.virtual],
            key=lambda e: e.priority,
            reverse=True
        )
73530
def get_backup_blocks(cls, impl, working_dir):
        
        ret = []
        backup_dir = config.get_backups_directory(impl, working_dir)
        if not os.path.exists(backup_dir):
            return []

        for name in os.listdir( backup_dir ):
            if ".bak." not in name:
                continue 

            suffix = name.split(".bak.")[-1]
            try:
                block_id = int(suffix)
            except:
                continue 

            # must exist...
            backup_paths = cls.get_backup_paths(block_id, impl, working_dir)
            for p in backup_paths:
                if not os.path.exists(p):
                    # doesn't exist
                    block_id = None
                    continue

            if block_id is not None:
                # have backup at this block 
                ret.append(block_id)

        return ret
271737
def list(gandi, limit, step):
    """"""
    output_keys = ['id', 'type', 'step']

    options = {
        'step': step,
        'items_per_page': limit,
        'sort_by': 'date_created DESC'
    }

    result = gandi.oper.list(options)
    for num, oper in enumerate(reversed(result)):
        if num:
            gandi.separator_line()
        output_generic(gandi, oper, output_keys)

    return result
337428
def get_blocks(self, chrom, start, end):
    
    if chrom not in self.block_trees:
      return []
    return self.block_trees[chrom].intersectingInterval(start, end)