Connection logic; send requests to the Gdax API.
3730
private function _call($method, $path, $param, $header = false) {
    // Clear connection; Set timeout, and json header.
    $this->curl->resetConnection();

    // Set additional headers.
    if ($header) {
      foreach ($header as $name => $value) {
        $this->curl->setHeader($name, $value);
      }
    }

    // Make an API request to the GDAX server.
    if ($param) {
      // If the method is not GET, pass JSON in the request body.
      $payload = false;
      if ($method != 'GET') {
        $param = json_encode($param);
        $payload = true;
      }
      $this->curl->{strtolower($method)}("$this->api/$path", $param, $payload);
    } else {
      $this->curl->{strtolower($method)}("$this->api/$path");
    }

    // TODO: Move error logs out of class. ~: Monolog
    // Error Logging
    if ($this->curl->error) {
      $this->_error[] = "$path: {$this->curl->error_message}";
      if ($this->_debug) {
        $this->_error[] = $this->_dump($path, $param);
      }
    }

    if (is_null($ret = json_decode($this->curl->response))) {
      throw new \Exception(__METHOD__ ." - Invalid JSON or null returned."); 
    }

    // Throw an exception on any returned messages from GDAX.
    if ($ret && isset($ret->message)) {
      throw new \Exception("API: $path-> ". $ret->message);
    }

    return $ret;
  }
405048
def _send(self, data):
        """"""
        if not self._sock:
            self.connect()
        self._do_send(data)
1244265
def _send_result_to_redis(self, result):
        """"""
        if self.redis_connected:
            self.logger.debug("Sending result to redis")
            try:
                key = "rest:poll:{u}".format(u=result['uuid'])
                self.redis_conn.set(key, json.dumps(result))
            except ConnectionError:
                self.logger.error("Lost connection to Redis")
                self._spawn_redis_connection_thread()
        else:
            self.logger.warning("Unable to send result to redis, not connected")
183510
function (request, callback) {
            this.nbXdrRequests += 1;

            this.xdrRequests[request.id] = {
                callback : callback,
                transaction : request.id
            };

            var args = {
                xdr : true,
                method : request.method,
                data : request.data,
                headers : request.headers
            };

            // This might throw an error, propagate it and let the IO know that there was an exception
            this._transport.send(request.url, args, request.id);
        }
200229
public void sendRequest(KNXAddress dst, Priority p, byte[] nsdu)
		throws KNXLinkClosedException, KNXTimeoutException
	{
		send(dst, p, nsdu, false);
	}
977779
protected void processAuthedConnections (long iterStamp)
    {
        AuthingConnection conn;
        while ((conn = _authq.getNonBlocking()) != null) {
            try {
                // construct a new running connection to handle this connections network traffic
                // from here on out
                PresentsConnection rconn = new PresentsConnection();
                rconn.init(this, conn.getChannel(), iterStamp);
                rconn.selkey = conn.selkey;

                // we need to keep using the same object input and output streams from the
                // beginning of the session because they have context that needs to be preserved
                rconn.inheritStreams(conn);

                // replace the mapping in the handlers table from the old conn with the new one
                _handlers.put(rconn.selkey, rconn);

                // add a mapping for the connection id and set the datagram secret
                _connections.put(rconn.getConnectionId(), rconn);
                rconn.setDatagramSecret(conn.getAuthRequest().getCredentials().getDatagramSecret());

                // transfer any overflow queue for that connection
                OverflowQueue oflowHandler = _oflowqs.remove(conn);
                if (oflowHandler != null) {
                    _oflowqs.put(rconn, oflowHandler);
                }

                // and let the client manager know about our new connection
                _clmgr.connectionEstablished(rconn, conn.getAuthName(), conn.getAuthRequest(),
                                             conn.getAuthResponse());

            } catch (IOException ioe) {
                log.warning("Failure upgrading authing connection to running.", ioe);
            }
        }
    }
1203457
def connect(self):
        """"""
        self.transport, _ = yield from self.parent.app.loop.create_datagram_endpoint(
            DatagramProtocol, remote_addr=(self.hostname, self.port))
        return self
998510
def connect(*args, **kwargs):
    """"""
    global __CONNECTION
    if __CONNECTION is None:
        __CONNECTION = Connection(*args, **kwargs)

    return __CONNECTION
210610
def request(self, method, params, session):
        
        session = session or self.client.session
        request = self.create_req(method, params)
        date_time_sent = datetime.datetime.utcnow()
        try:
            response = session.post(
                self.url,
                data=request,
                headers=self.client.request_headers,
                timeout=(self.connect_timeout, self.read_timeout)
            )
        except ConnectionError:
            raise APIError(None, method, params, 'ConnectionError')
        except Exception as e:
            raise APIError(None, method, params, e)
        elapsed_time = (datetime.datetime.utcnow()-date_time_sent).total_seconds()

        check_status_code(response)
        try:
            response_data = response.json()
        except ValueError:
            raise InvalidResponse(response.text)

        if self._error_handler:
            self._error_handler(response_data, method, params)
        return response_data, elapsed_time
260554
def get_connections(self, id, connection_name, **args):
        """"""
        return self.request(
            "{0}/{1}/{2}".format(self.version, id, connection_name), args
        )
903717
function (connectionInfo, query, params) {
    var connection,
        client = new pg.Client(connectionInfo);

    client.connect(function (err) {
        if (err) {
            return respond({
                success: false,
                data: {
                    err: err,
                    query: query,
                    connection: connectionInfo
                }
            });
        }

        // execute a query on our database
        client.query(query, params, function (err, result) {
            // close the client
            client.end();

            // treat the error
            if (err) {
                return respond({
                    success: false,
                    data: {
                        err: err,
                        query: query,
                        connection: connectionInfo
                    }
                });
            }
            
            // Return the respose
            return respond({
                success: true,
                data: result
            });
        });
    });
}
1086936
def send_request(self, request):
        """"""
        # throttle the number of requests to each host
        self.aggregate.wait_for_host(self.urlparts[1])
        kwargs = self.get_request_kwargs()
        kwargs["allow_redirects"] = False
        self._send_request(request, **kwargs)
507520
private void sendRequest(Object request, ContextualFuture future) {
    if (open && connection.open) {
      long requestId = ++this.requestId;
      futures.put(requestId, future);
      connection.handleRequest(requestId, request);
    } else {
      future.context.executor().execute(() -> future.completeExceptionally(new ConnectException("connection closed")));
    }

    if (request instanceof ReferenceCounted) {
      ((ReferenceCounted<?>) request).release();
    }
  }
176934
def _request(self, request, proxies, timeout, verify, **_):
        

        settings = self.http.merge_environment_settings(
            request.url, proxies, False, verify, None)

        self._delay()
        response = self.http.send(
            request, timeout=timeout, allow_redirects=False, **settings)
        self._update(response.headers)

        return response
877550
def send(self, request):
        
        self._connection.connection.rpush(self._request_key, pickle.dumps(request))
        resp_key = '{}:{}'.format(SIGNAL_REDIS_PREFIX, request.uid)

        while True:
            if self._connection.polling_time > 0.0:
                sleep(self._connection.polling_time)

            response_data = self._connection.connection.get(resp_key)
            if response_data is not None:
                self._connection.connection.delete(resp_key)
                break

        return pickle.loads(response_data)
13838
def execute(self, conn, daoinput, transaction = False):
        	
        if not conn:
	    dbsExceptionHandler("dbsException-failed-connect2host", "Oracle/MigrationRequests/UpdateRequestStatus. Expects db connection from upper layer.", 
                                self.logger.exception)
        if daoinput['migration_status'] == 1:
           sql = self.sql2 
        elif daoinput['migration_status'] == 2:
            sql = self.sql + " and MIGRATION_STATUS = 1 "
        elif daoinput['migration_status'] == 3:
            sql = self.sql3 + " and MIGRATION_STATUS = 1 " 
        else:
            dbsExceptionHandler("dbsException-conflict-data", "Oracle/MigrationRequest/UpdateRequestStatus. Expected migration status to be 1, 2 or 3",
                                self.logger.exception)
        
	result = self.dbi.processData(sql, daoinput, conn, transaction)
1217486
def _make_request(session, url, argument=None, params=None, raw=False):
    """"""
    if not params:
        params = {}
    params['key'] = session.auth.key
    try:
        if argument:
            request_url = '{}{}{}{}'.format(session.auth.base_url, VOOBLY_API_URL, url, argument)
        else:
            request_url = '{}{}'.format(VOOBLY_API_URL, url)
        resp = session.get(request_url, params=params)
    except RequestException:
        raise VooblyError('failed to connect')
    if resp.text == 'bad-key':
        raise VooblyError('bad api key')
    elif resp.text == 'too-busy':
        raise VooblyError('service too busy')
    elif not resp.text:
        raise VooblyError('no data returned')
    if raw:
        return resp.text
    try:
        return tablib.Dataset().load(resp.text).dict
    except UnsupportedFormat:
        raise VooblyError('unexpected error {}'.format(resp.text))