Change the name of a Task owned by this Job.

        This will affect the historical data available for this
        Task, e.g. past run logs will no longer be accessible.
436727
def edit_task(self, task_name, **kwargs):
        

        logger.debug('Job {0} editing task {1}'.format(self.name, task_name))
        if not self.state.allow_edit_task:
            raise DagobahError("tasks cannot be edited in this job's " +
                               "current state")

        if task_name not in self.tasks:
            raise DagobahError('task %s not found' % task_name)

        if 'name' in kwargs and isinstance(kwargs['name'], str):
            if kwargs['name'] in self.tasks:
                raise DagobahError('task name %s is unavailable' %
                                   kwargs['name'])

        task = self.tasks[task_name]
        for key in ['name', 'command']:
            if key in kwargs and isinstance(kwargs[key], str):
                setattr(task, key, kwargs[key])

        if 'soft_timeout' in kwargs:
            task.set_soft_timeout(kwargs['soft_timeout'])

        if 'hard_timeout' in kwargs:
            task.set_hard_timeout(kwargs['hard_timeout'])

        if 'hostname' in kwargs:
            task.set_hostname(kwargs['hostname'])

        if 'name' in kwargs and isinstance(kwargs['name'], str):
            self.rename_edges(task_name, kwargs['name'])
            self.tasks[kwargs['name']] = task
            del self.tasks[task_name]

        self.parent.commit(cascade=True)
461019
def rename(name, new_name):
    '''
    
    '''
    current_info = info(name)
    if not current_info:
        raise CommandExecutionError('User \'{0}\' does not exist'.format(name))
    new_info = info(new_name)
    if new_info:
        raise CommandExecutionError(
            'User \'{0}\' already exists'.format(new_name)
        )
    _dscl(
        ['/Users/{0}'.format(name), 'RecordName', name, new_name],
        ctype='change'
    )
    # dscl buffers changes, sleep 1 second before checking if new value
    # matches desired value
    time.sleep(1)
    return info(new_name).get('RecordName') == new_name
340264
def change_parent(sender, instance, **kwargs):
    
    if instance.id is None:
        return
    if len({'task', 'task_id'} & set(instance.changed_fields)) != 0:
        diff = instance.diff
        parent = diff['task'][0] if 'task' in diff else diff['task_id'][0]
        parent_id = parent.item_id if isinstance(parent, Task) else Task.objects.get(pk=parent).item_id
        child_id = instance.item_id
        ItemRelation.objects.filter(parent_id=parent_id, child_id=child_id).delete()
        ItemRelation.objects.create(parent_id=instance.task.item_id, child_id=child_id, visible=True)
    if len({'context', 'context_id'} & set(instance.changed_fields)) != 0:
        diff = instance.diff
        parent = diff['context'][0] if 'context' in diff else diff['context_id'][0]
        parent_id = parent.item_id if isinstance(parent, Context) else Context.objects.get(pk=parent).item_id
        child_id = instance.item_id
        ItemRelation.objects.filter(parent_id=parent_id, child_id=child_id).delete()
        ItemRelation.objects.create(parent_id=instance.context.item_id, child_id=child_id, visible=False)
116649
def _put_task_in_run_log(self, task_name):
        
        logger.debug('Job {0} initializing run log entry for task {1}'.format(self.name, task_name))
        data = {'start_time': datetime.utcnow(),
                'command': self.tasks[task_name].command}
        self.run_log['tasks'][task_name] = data
837780
def set_task(self, command):
        
        self.tasks[command.task_id] = command.task

        self.longest_bar_prefix_size = self.longest_bar_prefix_value()

        # Redraw
        self.changes_made = True
        self.redraw()
260910
public int changePassword(Task task, String strUserName, String strCurrentPassword, String strNewPassword)
    {
        int iErrorCode = Constants.NORMAL_RETURN;
        org.jbundle.thin.base.remote.RemoteTask remoteTask = (org.jbundle.thin.base.remote.RemoteTask)this.getRemoteTask(null, strUserName, false);
        Map<String,Object> properties = new HashMap<String,Object>();
        properties.put(Params.USER_NAME, strUserName);
        properties.put(Params.PASSWORD, strCurrentPassword);
        properties.put("newPassword", strNewPassword);
        try {
            Object objReturn = remoteTask.doRemoteAction(ThinMenuConstants.CHANGE_PASSWORD, properties);
            if (objReturn instanceof Integer)
                iErrorCode = ((Integer)objReturn).intValue();
        } catch (Exception ex) {
            return task.setLastError(ex.getMessage());
        }
        return iErrorCode;
    }
432101
public void remove(final Task task)
  {
    giant.lock();
    try {
      try {
        log.info("Removing task[%s] from activeTasks", task.getId());
        for (final TaskLockPosse taskLockPosse : findLockPossesForTask(task)) {
          unlock(task, taskLockPosse.getTaskLock().getInterval());
        }
      }
      finally {
        activeTasks.remove(task.getId());
      }
    }
    finally {
      giant.unlock();
    }
  }
1292256
def rename(self, new_name):
    
    update = copy.copy(self)
    update.name = new_name
    return self._do_update(update)
314059
def rename(self, new_name):
        
        new_collection = Collection(self.db, new_name, create=False)
        assert not new_collection.exists()

        self.db.execute("alter table %s rename to %s" % (self.name, new_name))
        self.name = new_name
943971
def update_task(self, differences):
        

        self.log('differences UPDATING: {}'.format(differences))

        object_name = '{} - {}'.format(self.app_label, self.instance.master._meta.verbose_name)
        lang = self.instance.language_code
        object_pk = self.instance.master.pk

        for field in differences:
            value = getattr(self.instance, field)
            if value is None or value == '':
                continue
            try:
                TransTask.objects.filter(
                    language__code=lang, object_field=field, object_name=object_name, object_pk=object_pk
                ).update(done=True, date_modification=datetime.now(), object_field_value_translation=value)
                self.log('MARKED TASK AS DONE')
            except TransTask.DoesNotExist:
                self.log('error MARKING TASK AS DONE: {} - {} - {} - {}'.format(lang, field, object_name, object_pk))
180630
def stop(task = :default)
      return nil unless tasks.keys.include?(task) && active?(task)
      time_taken = Time.now.to_f - tasks[task][:current].to_f
      tasks[task][:history] << { start: tasks[task][:current], stop: Time.now.to_f, time: time_taken }
      tasks[task][:current] = nil
      if retention && tasks[task][:history].size > retention then tasks[task][:history].shift end
      time_taken
    end
182507
@Override
  public void recordTaskEnd(String taskId, String deleteReason) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
      HistoricTaskInstanceEntity historicTaskInstance = getHistoricTaskInstanceEntityManager().findById(taskId);
      if (historicTaskInstance != null) {
        historicTaskInstance.markEnded(deleteReason);
      }
    }
  }
561367
private void replaceByJobHandle() {
    assert state != JobState.RUNNING : "Running job cannot be replaced.";
    final Job self = this;
    new TAtomic<Job>() {
      @Override public Job atomic(Job old) {
        if( old == null ) return null;
        JobHandle jh = new JobHandle(self);
        jh.start_time = old.start_time;
        return jh;
      }
    }.fork(job_key);
  }
357300
def _on_client_name_changed(self, data):
        """"""
        self._clients.get(data.get('id')).update_name(data)
24810
public void logRename(String src, String dst, long timestamp) {
    RenameOp op = RenameOp.getInstance();
    op.set(src, dst, timestamp);
    logEdit(op);
  }
717644
def update_name(self, name):
        """"""
        if name != self.name:
            self.parent.executables[name] = self
            del self.parent.executables[self.name]
            self.name = name
74668
public synchronized boolean renameTo( Resource dest)
        throws SecurityException
    {
        if (_resource.renameTo(dest))
        {
            clear();
            return true;
        }
        return false;
    }