Adds a scheduling block to the database, returning a response object
552912
def add_scheduling_block(config):
    """"""
    try:
        DB.add_sbi(config)
    except jsonschema.ValidationError as error:
        error_dict = error.__dict__
        for key in error_dict:
            error_dict[key] = error_dict[key].__str__()
        error_response = dict(message="Failed to add scheduling block",
                              reason="JSON validation error",
                              details=error_dict)
        return error_response, HTTPStatus.BAD_REQUEST
    response = dict(config=config,
                    message='Successfully registered scheduling block '
                            'instance with ID: {}'.format(config['id']))
    response['links'] = {
        'self': '{}scheduling-block/{}'.format(request.url_root,
                                               config['id']),
        'list': '{}'.format(request.url),
        'home': '{}'.format(request.url_root)
    }
    return response, HTTPStatus.ACCEPTED
26242
def _determine_scheduled_actions(scheduled_actions, scheduled_actions_from_pillar):
    '''
    
    '''
    tmp = copy.deepcopy(
        __salt__['config.option'](scheduled_actions_from_pillar, {})
    )
    # merge with data from state
    if scheduled_actions:
        tmp = dictupdate.update(tmp, scheduled_actions)
    return tmp
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)
188588
function executeScheduleItem(schedule, iteration, value) {
  if (schedule.length < iteration + 1) {
    throw Error("ZLIQ: schedule for iteration " + iteration + " not defined");
  }
  let item = schedule[iteration];
  if (typeof item === "function") {
    return item(value);
  } else {
    return item;
  }
}
16873
def _scheduling_block_config(num_blocks=5, start_sbi_id=0, start_pb_id=0,
                             project='sip'):
    """"""
    pb_id = start_pb_id
    for sb_id, sbi_id in _scheduling_block_ids(num_blocks, start_sbi_id,
                                               project):
        sub_array_id = 'subarray-{:02d}'.format(random.choice(range(5)))
        config = dict(id=sbi_id,
                      sched_block_id=sb_id,
                      sub_array_id=sub_array_id,
                      processing_blocks=_generate_processing_blocks(pb_id))
        pb_id += len(config['processing_blocks'])
        yield config
189232
def create(sub_array_id):
    """"""
    config = request.data
    config['sub_array_id'] = 'subarray-{:02d}'.format(sub_array_id)
    return add_scheduling_block(config)
1279191
def get_scheduling_block_event():
    """"""
    event = DB.rpoplpush('scheduling_block_events',
                         'scheduling_block_event_history')
    if event:
        event = json.loads(event.decode('utf-8'))
    return event
328545
public JsonResponse scheduleBlastFromTemplate(String template, String list, Date scheduleTime, Blast blast) throws IOException {
        blast.setCopyTemplate(template);
        blast.setList(list);
        blast.setScheduleTime(scheduleTime);
        return apiPost(blast);
    }
533915
def _schedule_processing_blocks(self):
        """"""
        LOG.info('Starting to Schedule Processing Blocks.')
        while True:
            time.sleep(0.5)
            if not self._queue:
                continue
            if self._num_pbcs >= self._max_pbcs:
                LOG.warning('Resource limit reached!')
                continue
            _inspect = Inspect(app=APP)
            if self._queue and _inspect.active() is not None:
                next_pb = self._queue[-1]
                LOG.info('Considering %s for execution...', next_pb[2])
                utc_now = datetime.datetime.utcnow()
                time_in_queue = (utc_now -
                                 datetime_from_isoformat(next_pb[4]))
                if time_in_queue.total_seconds() >= 10:
                    item = self._queue.get()
                    LOG.info('------------------------------------')
                    LOG.info('>>> Executing %s! <<<', item)
                    LOG.info('------------------------------------')
                    execute_processing_block.delay(item)
                    self._num_pbcs += 1
                else:
                    LOG.info('Waiting for resources for %s', next_pb[2])
866047
def scheduling_blocks():
    """"""
    sbi_list = SchedulingBlockInstanceList()
    return dict(active=sbi_list.active,
                completed=sbi_list.completed,
                aborted=sbi_list.aborted)
1332426
public static Scheduler.SchedulerResponse constructSchedulerResponse(boolean isOK) {
    Common.Status.Builder status = Common.Status.newBuilder();
    if (isOK) {
      status.setStatus(Common.StatusCode.OK);
    } else {
      status.setStatus(Common.StatusCode.NOTOK);
    }

    return Scheduler.SchedulerResponse.newBuilder().
        setStatus(status).
        build();
  }
1301501
def response_add(self, request, obj):
        
        response = super(PageAdmin, self).response_add(request, obj)
        return self._maintain_parent(request, response)
248065
def add_sched_block_instance(self, config_dict):
        
        # Get schema for validation
        schema = self._get_schema()
        LOG.debug('Adding SBI with config: %s', config_dict)

        # Validates the schema
        validate(config_dict, schema)

        # Add status field and value to the data
        updated_block = self._add_status(config_dict)

        # Splitting into different names and fields before
        # adding to the database
        scheduling_block_data, processing_block_data = \
            self._split_sched_block_instance(updated_block)

        # Adding Scheduling block instance with id
        name = "scheduling_block:" + updated_block["id"]
        self._db.set_specified_values(name, scheduling_block_data)

        # Add a event to the scheduling block event list to notify
        # of a new scheduling block being added to the db.
        self._db.push_event(self.scheduling_event_name,
                            updated_block["status"],
                            updated_block["id"])

        # Adding Processing block with id
        for value in processing_block_data:
            name = ("scheduling_block:" + updated_block["id"] +
                    ":processing_block:" + value['id'])
            self._db.set_specified_values(name, value)

            # Add a event to the processing block event list to notify
            # of a new processing block being added to the db.
            self._db.push_event(self.processing_event_name,
                                value["status"],
                                value["id"])
812014
function processSchedule(host,api_key,category,format,mode,pid) {
	var path = '/nitro/api/schedules';

	var today = new Date();
	var todayStr = today.toISOString();

	var query = nitro.newQuery();
	query.add(api.fSchedulesStartFrom,todayStr,true);

	if (mode == 'genre') {
		for (var c in category) {
			query.add(api.fSchedulesGenre,category[c]);
		}
	}
	for (var f in format) {
		query.add(api.fSchedulesFormat,format[f]);
	}
	if (search != '') {
		query.add(api.fSchedulesQ,search);
	}
	if (mode == 'pid') {
		query.add(api.fSchedulesDescendantsOf,pid);
	}
	if (channel != '') {
		query.add(api.fSchedulesServiceMasterBrand,channel);
	}
	if (partner_pid) {
		query.add(api.fSchedulesPartnerPid,partner_pid);
	}
	if (sid) {
		query.add(api.fSchedulesSid,sid);
	}

	query.add(api.mSchedulesAncestorTitles)
		.add(api.fSchedulesPageSize,pageSize);

	nitro.make_request(host,path,api_key,query,{},function(obj){
		var result = scheduleResponse(obj);
		var dest = nitro.getReturn();
		if (dest.callback) {
			// call the callback's next required destination
			// e.g. second and subsequent pages
			if (dest.path) {
				nitro.make_request(host,dest.path,api_key,dest.query,{},dest.callback);
			}
			else {
				dest.callback();
			}
		}
	});
}
501584
def table(table_name, options={}, &block)
      table = Mongify::Database::Table.new(table_name, options, &block)
      add_table(table)
    end
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
82122
private void populateCalendarHours(Record record, ProjectCalendarHours hours) throws MPXJException
   {
      hours.setDay(Day.getInstance(NumberHelper.getInt(record.getInteger(0))));
      addDateRange(hours, record.getTime(1), record.getTime(2));
      addDateRange(hours, record.getTime(3), record.getTime(4));
      addDateRange(hours, record.getTime(5), record.getTime(6));
   }