send data to fhmbaas
344892
function syncBatch(batch, cb) {
    if (batch && batch.length > 0) {
      var mbaasClient = new MBaaSClient(ENVIRONMENT, {
        url: URL.format(PROTOCOL + '://' + HOST),
        accessKey: ACCESS_KEY,
        project: PROJECT,
        app: GUID,
        appApiKey: API_KEY
      });
      // /api/app/:domain/:environment/:projectid/:appid/message/:topic with [] or messages for data (a batch)
      mbaasClient.app.message.sendbatch({
        'host': HOST,
        'environment': ENVIRONMENT,
        'domain': DOMAIN,
        'data': batch,
        'topic': 'fhact' //the only other topic is fhweb which is not longer used
      }, function(err) {
        if (err) {
          return cb(err, {message: 'Error sending message batch to MBaaS', host: HOST, environment: ENVIRONMENT, domain: DOMAIN, topic:'fhact', batch: batch});
        } else {
          return cb(undefined, {message: 'Batch sent to MBaaS'});
        }
      });
    } else {
      return cb(undefined, {message: 'Batch empty...nothing to sync at this time'});
    }
  }
1241845
private function sendSitemap(): void
    {
        $this->addUrl(hu);

        $rs = safe_rows_start(
            'name',
            'txp_section',
            "name != 'default' and rah_sitemap_include_in = 1 order by name asc"
        );

        if ($rs) {
            while ($a = nextRow($rs)) {
                $this->addUrl(pagelinkurl(['s' => $a['name']]));
            }
        }

        $rs = safe_rows_start(
            'name, type',
            'txp_category',
            "name != 'root' and rah_sitemap_include_in = 1 order by name asc"
        );

        if ($rs) {
            while ($a = nextRow($rs)) {
                $this->addUrl(pagelinkurl([
                    'c' => $a['name'],
                    'context' => $a['type'],
                ]));
            }
        }

        $sql = ['Status >= 4'];

        foreach (do_list(get_pref('rah_sitemap_exclude_fields')) as $field) {
            if ($field) {
                $f = explode(':', $field);
                $n = strtolower(trim($f[0]));

                if (isset($this->articleFields[$n])) {
                    $sql[] = $this->articleFields[$n]." NOT LIKE '".doSlash(trim(implode(':', array_slice($f, 1))))."'";
                }
            }
        }

        if (get_pref('rah_sitemap_exclude_sticky_articles')) {
            $sql[] = 'Status != 5';
        }

        if (!get_pref('rah_sitemap_future_articles')) {
            $sql[] = 'Posted <= now()';
        }

        if (!get_pref('rah_sitemap_past_articles')) {
            $sql[] = 'Posted >= now()';
        }

        if (!get_pref('rah_sitemap_expired_articles')) {
            $sql[] = "(Expires = ".NULLDATETIME." or Expires >= now())";
        }

        $rs = safe_rows_start(
            '*, unix_timestamp(Posted) as posted, unix_timestamp(LastMod) as uLastMod',
            'textpattern',
            implode(' and ', $sql) . ' order by Posted desc'
        );

        if ($rs) {
            while ($a = nextRow($rs)) {
                $this->addUrl(permlinkurl($a), (int) max($a['uLastMod'], $a['posted']));
            }
        }

        foreach (do_list(get_pref('rah_sitemap_urls')) as $url) {
            if ($url) {
                $this->addUrl($url);
            }
        }

        $urlset = [];
        callback_event_ref('rah_sitemap.urlset', '', 0, $urlset);

        if ($urlset && is_array($urlset)) {
            foreach ($urlset as $url => $lastmod) {
                $this->addUrl($url, $lastmod);
            }
        }

        $xml =
            '<?xml version="1.0" encoding="utf-8"?>'.
            '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'.
            implode('', array_slice($this->addUrlset, 0, self::URL_LIMIT)).
            '</urlset>';

        ob_clean();
        txp_status_header('200 OK');
        header('Content-type: text/xml; charset=utf-8');

        if (get_pref('rah_sitemap_compress') &&
            strpos(serverSet('HTTP_ACCEPT_ENCODING'), 'gzip') !== false
        ) {
            header('Content-Encoding: gzip');
            $xml = gzencode($xml);
        }

        echo $xml;
        exit;
    }
397991
function sendImageMessage(recipientId, imageURL, token) {
      imageMessageData = {
        attachment:{
          type:"image",
          payload:{
            url:imageURL
          }
        }
      }
      request({
        url: FB_MSG_URL,
        qs: {access_token:token},
        method: 'POST',
        json: {
          recipient: {id:recipientId},
          message: imageMessageData,
        }
      }, function(error, response, body) {
        if (error) {
          node.log('Error sending iamge message: ', error);
        } else if (response.body.error) {
          node.log('Error: ', response.body.error);
        }
      });
    }
1316975
private void sendEmail(Message m, SendRawEmailRequest req)
            throws SendFailedException, MessagingException {

        Address[] sent = null;
        Address[] unsent = null;
        Address[] invalid = null;

        try {
            appendUserAgent(req, USER_AGENT);
            SendRawEmailResult resp = this.emailService.sendRawEmail(req);
            lastMessageId = resp.getMessageId();
            sent = m.getAllRecipients();
            unsent = new Address[0];
            invalid = new Address[0];
            super.notifyTransportListeners(TransportEvent.MESSAGE_DELIVERED,
                    sent, unsent, invalid, m);
        } catch (Exception e) {
            sent = new Address[0];
            unsent = m.getAllRecipients();
            invalid = new Address[0];
            super.notifyTransportListeners(
                    TransportEvent.MESSAGE_NOT_DELIVERED, sent, unsent,
                    invalid, m);
            throw new SendFailedException("Unable to send email", e, sent,
                    unsent, invalid);
        }
    }
763094
def send_action(action, params=None):
	
	data={"msg_type":"action", "action":action}
	if params is not None:
		data['params']=params
	_comm.send(data)
402752
async def sendto(self, data, component):
        
        active_pair = self._nominated.get(component)
        if active_pair:
            await active_pair.protocol.send_data(data, active_pair.remote_addr)
        else:
            raise ConnectionError('Cannot send data, not connected')
411463
def data16_send(self, type, len, data, force_mavlink1=False):
                '''
                

                '''
                return self.send(self.data16_encode(type, len, data), force_mavlink1=force_mavlink1)
962011
@Override
    public String sendLMS(String CorpNum, Message[] Messages, Date reserveDT,
                          String UserID) throws PopbillException {
        return sendLMS(CorpNum, null, null, null, Messages, reserveDT, UserID);
    }
28003
def sendmess(self, msgtype, payload, flags=0, size=0, offset=0, timeout=0):
        

        # reuse last valid connection or create new
        conn = self.conn or self._new_connection()
        # invalidate last connection
        self.conn = None

        flags |= self.flags
        assert (flags & FLG_PERSISTENCE)
        ret, rflags, data = conn.req(
            msgtype, payload, flags, size, offset, timeout)
        if rflags & FLG_PERSISTENCE:
            # persistence granted, save connection object for reuse
            self.conn = conn
        else:
            # discard connection object
            conn.shutdown()

        return ret, data
297435
def sendAZ(self, az):
        '''
        

        '''
        self.lock.acquire()
        self.data.az = az
        self.lock.release()
1117156
def uavionix_adsb_transceiver_health_report_send(self, rfHealth, force_mavlink1=False):
                '''
                

                '''
                return self.send(self.uavionix_adsb_transceiver_health_report_encode(rfHealth), force_mavlink1=force_mavlink1)
95344
function SendToCB (err, result) {
        // check if sms was sent from output table
        self.Debug (7,"SendToCB SMS=%j result=%j err=%j", smscmd, result, err);
        if (err) {
            self.Debug (1, "Insert in MySql outbox refused %s", err);
            appcb ({status: -1, id: smscmd.id, error: err});
        } else {
            setTimeout (function() {CheckOutbox (result.insertId);}, smsc.opts.delay);
        }
    }
755505
def send_data_message(
            self,
            condition=None,
            collapse_key=None,
            delay_while_idle=False,
            time_to_live=None,
            restricted_package_name=None,
            low_priority=False,
            dry_run=False,
            data_message=None,
            content_available=None,
            api_key=None,
            timeout=5,
            json_encoder=None):
        
        from .fcm import fcm_send_single_device_data_message
        result = fcm_send_single_device_data_message(
            registration_id=str(self.registration_id),
            condition=condition,
            collapse_key=collapse_key,
            delay_while_idle=delay_while_idle,
            time_to_live=time_to_live,
            restricted_package_name=restricted_package_name,
            low_priority=low_priority,
            dry_run=dry_run,
            data_message=data_message,
            content_available=content_available,
            api_key=api_key,
            timeout=timeout,
            json_encoder=json_encoder,
        )

        self._deactivate_device_on_error_result(result)
        return result
148883
def send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=False):
    

    if len(heartbeats) == 0:
        return SUCCESS

    api_url = args.api_url
    if not api_url:
        api_url = 'https://api.wakatime.com/api/v1/users/current/heartbeats.bulk'
    log.debug('Sending heartbeats to api at %s' % api_url)
    timeout = args.timeout
    if not timeout:
        timeout = 60

    data = [h.sanitize().dict() for h in heartbeats]
    log.debug(data)

    # setup api request
    request_body = json.dumps(data)
    api_key = u(base64.b64encode(str.encode(args.key) if is_py3 else args.key))
    auth = u('Basic {api_key}').format(api_key=api_key)
    headers = {
        'User-Agent': get_user_agent(args.plugin),
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'Authorization': auth,
    }

    hostname = get_hostname(args)
    if hostname:
        headers['X-Machine-Name'] = u(hostname).encode('utf-8')

    # add Olson timezone to request
    try:
        tz = tzlocal.get_localzone()
    except:
        tz = None
    if tz:
        headers['TimeZone'] = u(tz.zone).encode('utf-8')

    session_cache = SessionCache()
    session = session_cache.get()

    should_try_ntlm = False
    proxies = {}
    if args.proxy:
        if use_ntlm_proxy:
            from .packages.requests_ntlm import HttpNtlmAuth
            username = args.proxy.rsplit(':', 1)
            password = ''
            if len(username) == 2:
                password = username[1]
            username = username[0]
            session.auth = HttpNtlmAuth(username, password, session)
        else:
            should_try_ntlm = '\\' in args.proxy
            proxies['https'] = args.proxy

    ssl_verify = not args.nosslverify
    if args.ssl_certs_file and ssl_verify:
        ssl_verify = args.ssl_certs_file

    # send request to api
    response, code = None, None
    try:
        response = session.post(api_url, data=request_body, headers=headers,
                                proxies=proxies, timeout=timeout,
                                verify=ssl_verify)
    except RequestException:
        if should_try_ntlm:
            return send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=True)
        else:
            exception_data = {
                sys.exc_info()[0].__name__: u(sys.exc_info()[1]),
            }
            if log.isEnabledFor(logging.DEBUG):
                exception_data['traceback'] = traceback.format_exc()
            if args.offline:
                queue = Queue(args, configs)
                queue.push_many(heartbeats)
                if log.isEnabledFor(logging.DEBUG):
                    log.warn(exception_data)
            else:
                log.error(exception_data)

    except:  # delete cached session when requests raises unknown exception
        if should_try_ntlm:
            return send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=True)
        else:
            exception_data = {
                sys.exc_info()[0].__name__: u(sys.exc_info()[1]),
                'traceback': traceback.format_exc(),
            }
            if args.offline:
                queue = Queue(args, configs)
                queue.push_many(heartbeats)
                log.warn(exception_data)

    else:
        code = response.status_code if response is not None else None
        content = response.text if response is not None else None

        if _success(code):
            results = _get_results(response)
            _process_server_results(heartbeats, code, content, results, args, configs)
            session_cache.save(session)
            return SUCCESS
        else:
            log.debug({
                'response_code': code,
                'response_text': content,
            })

        if should_try_ntlm:
            return send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=True)

        _handle_unsent_heartbeats(heartbeats, code, content, args, configs)

    session_cache.delete()
    return AUTH_ERROR if code == 401 else API_ERROR
644520
def send_mfg_inspector_data(inspector_proto, credentials, destination_url):
  """"""
  envelope = guzzle_pb2.TestRunEnvelope()
  envelope.payload = zlib.compress(inspector_proto.SerializeToString())
  envelope.payload_type = guzzle_pb2.COMPRESSED_MFG_EVENT
  envelope_data = envelope.SerializeToString()

  for _ in xrange(5):
    try:
      result = _send_mfg_inspector_request(
          envelope_data, credentials, destination_url)
      return result
    except UploadFailedError:
      time.sleep(1)

  logging.critical(
      'Could not upload to mfg-inspector after 5 attempts. Giving up.')

  return {}
1308206
def send_data(self):
        """"""
        if not self.connection._sock:
            raise err.InterfaceError("(0, '')")
        conn = self.connection

        try:
            with open(self.filename, 'rb') as open_file:
                packet_size = min(conn.max_allowed_packet, 16*1024)  # 16KB is efficient enough
                while True:
                    chunk = open_file.read(packet_size)
                    if not chunk:
                        break
                    conn.write_packet(chunk)
        except IOError:
            raise err.OperationalError(1017, "Can't find file '{0}'".format(self.filename))
        finally:
            # send the empty packet to signify we are done sending data
            conn.write_packet(b'')
405048
def _send(self, data):
        """"""
        if not self._sock:
            self.connect()
        self._do_send(data)