Update internal state from polling strava.com.

        :raise stravalib.exc.ActivityUploadFailed: If the poll returns an error.
773544
def poll(self):
        
        response = self.client.protocol.get('/uploads/{upload_id}',
                                            upload_id=self.upload_id,
                                            check_for_errors=False)

        self.update_from_response(response)
175116
def update_status(status)
      if status.present?
        RRRSpec.redis.hset(key, 'status', status)
      else
        RRRSpec.redis.hdel(key, 'status')
      end
    end
1332938
def _perform_update(self, method, resource, payload):
        '''
        
        '''

        # python2/3 compatibility wizardry
        try:
            file_type = file
        except NameError:
            file_type = IOBase

        if isinstance(payload, (dict, list)):
            response = self._perform_request(method, resource,
                                             data=json.dumps(payload))
        elif isinstance(payload, file_type):
            headers = {
                "content-type": "text/csv",
            }
            response = self._perform_request(method, resource, data=payload,
                                             headers=headers)
        else:
            raise Exception("Unrecognized payload {0}. Currently only list-, dictionary-,"
                            " and file-types are supported.".format(type(payload)))

        return response
1055200
def _raise_if_error(self):
        
        retcode = self.process.poll()
        if retcode is not None and retcode != 0:
            message = self._stderr.read().strip()
            raise IOError(message)
1096420
def _update_state(self, operation_pb):
        
        if operation_pb.done:
            self._complete = True

        if operation_pb.HasField("metadata"):
            self.metadata = _from_any(operation_pb.metadata)

        result_type = operation_pb.WhichOneof("result")
        if result_type == "error":
            self.error = operation_pb.error
        elif result_type == "response":
            self.response = _from_any(operation_pb.response)
787391
synchronized void statusUpdate(State runState, 
                                 float progress,
                                 String state, 
                                 Phase phase,
                                 long finishTime) {
    setRunState(runState);
    setProgress(progress);
    setStateString(state);
    setPhase(phase);
    if (finishTime > 0) {
      setFinishTime(finishTime); 
    }
  }
29899
def update(self, *, visible=None, comment=None):
        
        if visible is None and comment is None:
            raise ValueError('Provide "visible" or "comment" to update.')
        data = {}
        if visible is not None:
            data['visible'] = visible
        if comment is not None:
            data['comment'] = comment
        data = None if not data else data
        response = self.session.patch(self.build_url(''), data=data)
        if not response:
            return False
        data = response.json()

        self.visible = data.get('visible', self.visible)
        self.comment = data.get('comment', self.comment)
        return True
1259587
private function internalUpdate()
    {
        if ($this->triggerEvent(self::EVENT_NAME_BEFORE_UPDATE)->isCancelled()) {
            return;
        }

        // locking
        $query = array('_id' => $this->getId());
        if ($this->getOption('lock') === Definition::LOCK_OPTIMISTIC) {
            $query['__version__'] = $this->get('__version__');
            $this->getOperator()->increment('__version__');
        }

        // update
        try {
            $status = $this
                ->collection
                ->getMongoCollection()
                ->update(
                    $query,
                    $this->getOperator()->toArray()
                );
        } catch (\Exception $e) {
            throw new WriteException(
                $e->getMessage(),
                $e->getCode(),
                $e
            );
        }

        // check update status
        if ($status['ok'] != 1) {
            throw new WriteException(
                sprintf(
                    'Update error: %s: %s',
                    $status['err'],
                    $status['errmsg']
                )
            );
        }

        // check if document modified due to specified lock
        if ($this->getOption('lock') === Definition::LOCK_OPTIMISTIC) {
            if ($status['n'] === 0) {
                throw new OptimisticLockFailureException;
            }
        }

        if ($this->getOperator()->isReloadRequired()) {
            $this->refresh();
        } else {
            $this->getOperator()->reset();
        }

        $this->triggerEvent(self::EVENT_NAME_AFTER_UPDATE);
    }
986217
def can_reupload(self, user=None):
        """"""

        # Re-uploads are allowed only when test executions have failed.
        if self.state not in (self.TEST_VALIDITY_FAILED, self.TEST_FULL_FAILED):
            return False

        # It must be allowed to modify the submission.
        if not self.can_modify(user=user):
            return False

        return True
262979
@Override
    public void uploadFailed(final FailedEvent event) {
        assertStateConsistency(fileUploadId, event.getFilename());

        if (!isUploadInterrupted()) {
            interruptUploadDueToUploadFailed();
        }
        publishUploadFailedAndFinishedEvent(fileUploadId, event.getReason());
    }
1201008
def _set_upload_status(self, file_data_object, upload_status):
        
        uuid = file_data_object['uuid']
        return self.connection.update_data_object(
            uuid,
            {'uuid': uuid, 'value': { 'upload_status': upload_status}}
        )
225964
def poll_error(self):
        
        if self.block:
            return self.error

        new_list = self.error[self.old_error_size:]
        self.old_error_size += len(new_list)
        return new_list
145497
def _commit(self):
        
        assert self.uri is not None, Exception("BadArgument: uri property cannot be None")
        url = '{}/{}'.format(self.uri, self.__class__.__name__)
        serialized_json = jsonpickle.encode(self, unpicklable=False, )
        headers = {'Content-Type': 'application/json', 'Content-Length': str(len(serialized_json))}
        response = Http.post(url=url, data=serialized_json, headers=headers)
        if response.status_code != 200:
            from ArubaCloud.base.Errors import MalformedJsonRequest
            raise MalformedJsonRequest("Request: {}, Status Code: {}".format(serialized_json, response.status_code))
        content = jsonpickle.decode(response.content.decode("utf-8"))
        if content['ResultCode'] == 17:
            from ArubaCloud.base.Errors import OperationAlreadyEnqueued
            raise OperationAlreadyEnqueued("{} already enqueued".format(self.__class__.__name__))
        if content['Success'] is False:
            from ArubaCloud.base.Errors import RequestFailed
            raise RequestFailed("Request: {}, Response: {}".format(serialized_json, response.content))
        return content
1044313
private function updateStatus()
    {
        if (isset($this->inputs['status']) && trim($this->inputs['status']) !== '') {
            $this->connectToWhatsApp();
            $this->wa->sendStatusUpdate($this->inputs['status']);
            exit(json_encode([
                'success'  => true,
                'data'     => "<br />Your status was updated to - <b>{$this->inputs['status']}</b>",
                'messages' => $this->messages,
            ]));
        } else {
            exit(json_encode([
                'success'  => false,
                'errormsg' => 'There was no text in the submitted status box!',
            ]));
        }
    }
711420
def run(self):
    """"""
    while True:
      try:
        self._poll_for_update()
      except RuntimeError as error:
        # Note that because logging triggers a call to notify_update(), by
        # logging a message, we automatically retry publishing the update
        # after an error occurs.
        if error.message == 'dictionary changed size during iteration':
          # These errors occur occasionally and it is infeasible to get rid of
          # them entirely unless data.convert_to_base_types() is made
          # thread-safe. Ignore the error and retry quickly.
          _LOG.debug('Ignoring (probably harmless) error in station watcher: '
                     '`dictionary changed size during iteration`.')
          time.sleep(0.1)
        else:
          _LOG.exception('Error in station watcher: %s', error)
          time.sleep(1)
      except Exception as error:  # pylint: disable=broad-except
        _LOG.exception('Error in station watcher: %s', error)
        time.sleep(1)
537174
def update_flag(self, state: str, feature_key: str) \
        -> launchdarkly_api.FeatureFlag:
        
        build_env = "/environments/" + self.environment_key + "/on"
        patch_comment = [{"op": "replace", "path": build_env, "value": state}]

        try:
            resp = self.feature.patch_feature_flag(
                self.project_key, feature_key, patch_comment)
        except launchdarkly_api.rest.ApiException as ex:
            msg = "Unable to update flag."
            resp = "API response was {0} {1}.".format(ex.status, ex.reason)
            LOG.error("%s %s", msg, resp)
            sys.exit(1)

        return resp
582799
def expect_and_reraise_internal_error(modID='SDK'):
    
    try:
        yield
    except exception.SDKInternalError as err:
        msg = err.format_message()
        raise exception.SDKInternalError(msg, modID=modID)