Send results to the cloud
        :param result: result dictionary
        :return: response from _client.upload_results(result) or None if something went wrong
764829
def send_result(self, result):
        
        response_data = self._client.upload_results(result)
        if response_data:
            if self.logger is not None:
                self.logger.info("Results sent to the server. ID: {}".format(response_data["_id"]))
            return response_data
        else:
            if self.logger is not None:
                self.logger.info("Server didn't respond or client initialization has failed.")
            return None
1049398
def _result_object(result):
    
    content_type = result.headers.get('content-type', None)

    if content_type is None or content_type.startswith('application/json'):
        # This function is only called when there is content expected.
        # Therefore, a response without content will result in a ParseError.
        try:
            return result.json(object_pairs_hook=OrderedDict)
        except ValueError as exc:
            raise ParseError(
                "JSON parse error in HTTP response: {}. "
                "HTTP request: {} {}. "
                "Response status {}. "
                "Response content-type: {!r}. "
                "Content (max.1000, decoded using {}): {}".
                format(exc.args[0],
                       result.request.method, result.request.url,
                       result.status_code, content_type, result.encoding,
                       _text_repr(result.text, 1000)))
    elif content_type.startswith('text/html'):
        # We are in some error situation. The HMC returns HTML content
        # for some 5xx status codes. We try to deal with it somehow,
        # but we are not going as far as real HTML parsing.
        m = re.search(r'charset=([^;,]+)', content_type)
        if m:
            encoding = m.group(1)  # e.g. RFC "ISO-8859-1"
        else:
            encoding = 'utf-8'
        try:
            html_uni = result.content.decode(encoding)
        except LookupError:
            html_uni = result.content.decode()

        # We convert to one line to be regexp-friendly.
        html_oneline = html_uni.replace('\r\n', '\\n').replace('\r', '\\n').\
            replace('\n', '\\n')

        # Check for some well-known errors:
        if re.search(r'javax\.servlet\.ServletException: '
                     r'Web Services are not enabled\.', html_oneline):
            html_title = "Console Configuration Error"
            html_details = "Web Services API is not enabled on the HMC."
            html_reason = HTML_REASON_WEB_SERVICES_DISABLED
        else:
            m = re.search(
                r'<title>([^<]*)</title>.*'
                r'<h2>Details:</h2>(.*)(<hr size="1" noshade>)?</body>',
                html_oneline)
            if m:
                html_title = m.group(1)
                # Spend a reasonable effort to make the HTML readable:
                html_details = m.group(2).replace('<p>', '\\n').\
                    replace('<br>', '\\n').replace('\\n\\n', '\\n').strip()
            else:
                html_title = "Console Internal Error"
                html_details = "Response body: {!r}".format(html_uni)
            html_reason = HTML_REASON_OTHER
        message = "{}: {}".format(html_title, html_details)

        # We create a minimal JSON error object (to the extent we use it
        # when processing it):
        result_obj = {
            'http-status': result.status_code,
            'reason': html_reason,
            'message': message,
            'request-uri': result.request.url,
            'request-method': result.request.method,
        }
        return result_obj
    elif content_type.startswith('application/vnd.ibm-z-zmanager-metrics'):
        content_bytes = result.content
        assert isinstance(content_bytes, six.binary_type)
        return content_bytes.decode('utf-8')  # as a unicode object
    else:
        raise ParseError(
            "Unknown content type in HTTP response: {}. "
            "HTTP request: {} {}. "
            "Response status {}. "
            "Response content-type: {!r}. "
            "Content (max.1000, decoded using {}): {}".
            format(content_type,
                   result.request.method, result.request.url,
                   result.status_code, content_type, result.encoding,
                   _text_repr(result.text, 1000)))
891759
def process_response(self, result):
        
        if len(result) == 3:
            data = result[0]
            headers = result[2]
            if self.HEADER_API_VERSION in headers:
                api_version = headers[self.HEADER_API_VERSION]
                if (not self.already_printed_version_warning
                        and not self.is_up_to_date(api_version)):
                    print('Warning: Looks like you\'re using an outdated API '
                          'Version, please consider updating (server ' +
                          api_version + ' / client ' + self.__version__ + ')')
                    self.already_printed_version_warning = True
            return data
        return result
133917
def send(self):
        
        web.ctx.status = _convert_http_status(self.status_code)
        return _api_convert_output(self.return_value)
763096
def upsert_result(client_site_url, apikey, resource_id, result):
    """"""

    # TODO: Handle exceptions and unexpected results.
    url = client_site_url + u"deadoralive/upsert"
    params = result.copy()
    params["resource_id"] = resource_id
    requests.post(url, headers=dict(Authorization=apikey), params=params)
445852
def invoke(self, results):
        
        args = [results.get(d) for d in self.deps]
        return self.component(*args)
661182
function gotResults(results) {
  results.JSONquery = JSON.stringify(results.query, null, 2);
  console.log('gotResults', results);
  updateResults(results);
}
747817
def write_result(self, result):
        
        assert not self.finished, "Already sent a response"

        if not self.result.thrift_spec:
            self.finished = True
            return

        spec = self.result.thrift_spec[0]
        if result is not None:
            assert spec, "Tried to return a result for a void method."
            setattr(self.result, spec[2], result)

        self.finished = True
1033517
def sendResult(self, future):
        """"""
        # Greenlets cannot be pickled
        future.greenlet = None
        assert future._ended(), "The results are not valid"
        self.socket.sendResult(future)
405953
def get_result(self, client, check):
        
        data = self._request('GET', '/results/{}/{}'.format(client, check))
        return data.json()
751641
def post_result_data(self, client, check, output, status):
        
        data = {
            'source': client,
            'name': check,
            'output': output,
            'status': status,
        }
        self._request('POST', '/results', data=json.dumps(data))
        return True
1070456
def callback(self, result, message):
        
        self.results.put(result)
        message.ack()
471471
def _result_handler(self, response: Dict[str, Any]):
        
        res = response.get("MESSAGE")
        ID = res.get("ID")
        result = res.get("RESULT")
        fut = self.tasks.get(ID)
        fut.set_result(result)
        return True
70824
function (err, results) {
			if (err) {
				return cb(err);
			}

			// Generate file id
			var id = options.filename || utils.uid(24);

			//
			// Generate the headers to be send to Rackspace
			//

			var headers = {};
			// set the content-length of transfer-encoding as appropriate
			if (fromFile) {
				headers['content-length'] = results.stats.size;
			} else {
				if (source.headers && source.headers['content-length'])
					headers['content-length'] = source.headers['content-length'];
				else
					headers['transfer-encoding'] = 'chunked';
			}

			// Add any additonal headers
			var sKey;
			for (sKey in options.headers) {
				if (options.headers.hasOwnProperty(sKey)) {
					headers[sKey] = options.headers[sKey];
				}
			}

			//
			// Generate the cloud request options
			//
			var _options = {
				container : results.container.name,
				remote : id,
				headers : headers,
				metadata : options.meta,
				contentType : type
			};

			var readStream;
			if (fromFile)
				readStream = fs.createReadStream(source);
			else {
				readStream = source;
				source.resume();
				if (source.headers) {
					// We want to remove any headers from the source stream so they don't clobber our own headers.
					delete source.headers;
				}
			}

			var writeStream = o1._client.upload(_options);

			writeStream.on('error', cb);
			writeStream.on('success', function (file) {
				results.container.count++;
				cb(null, results.container.name + '/' + id);
			});

			readStream.pipe(writeStream);
		}
9431
def result(self):
        
        if self._result is None:
            self.await_result()
        chunks, exception = self._result
        if exception is None:
            return chunks
        raise exception
240855
def _handle_result(self):
        
        result = self.inbox.get()
        if result.success:
            if self._verbosity >= VERB_PROGRESS:
                sys.stderr.write("\nuploaded chunk {} \n".format(result.index))
            self.results.append((result.index, result.md5))
            self._pending_chunks -= 1
        else:
            raise result.traceback
1258818
def _return_response_and_status_code(response):
    

    result_codes = {
        "-11": "No matching data to API Key API Key error",
        "-12": "No authority to use No authority to use",
        "-13": "Expired API Key API Key expired",
        "-14": "Over the daily request limit Request limit per daily exceeded",
        "-15": "Over the hourly request limit Request limit per hour exceeded",
        "-1": "Invalid Parameters / Invalid Request",
        "-25": "File Upload Quota Limit Error in file size to upload",
        "-2": "Invalid URL Error in URL type",
        "-31": "Invalid type of hash error in Hash type",
        "-400": "No file attached No file attached",
        "-404": "No result No result",
        "-415": "Ectype of upload form is not multipart/form-data Error in upload form type",
        "-41": "Invalid type of url Error in URL type",
        "-500": "Internal Server Error System error",
        "-51": "Invalid type of ip Error in IP type",
        "-61": "Invalid type of hostname Error in Hostname type",
        "0": "Data is not exist No information found in DB.",
        "1": "Data exists / Analysis request succeeded /Successful upload (new)",
        "2": "Analysis in progress / Successful upload (duplicated)",
        "-999": "Error"

    }

    results = response.json()

    result_code = str(response.json().get('result_code', '-999'))
    result_message = result_codes[result_code]
    return dict(results=results, response_code=result_code, result_message=result_message)