Write the points to the CouchDB server.
349541
def export(self, name, columns, points):
        """"""
        logger.debug("Export {} stats to CouchDB".format(name))

        # Create DB input
        data = dict(zip(columns, points))

        # Set the type to the current stat name
        data['type'] = name
        data['time'] = couchdb.mapping.DateTimeField()._to_json(datetime.now())

        # Write input to the CouchDB database
        # Result can be view: http://127.0.0.1:5984/_utils
        try:
            self.client[self.db].save(data)
        except Exception as e:
            logger.error("Cannot export {} stats to CouchDB ({})".format(name, e))
429243
def write(self, data):
        ''
        if not hasattr(data, 'read'):
            data = six.BytesIO(data)#StringIO(data)
        self.jfs.up(self.path, data)
87633
def write(name, values, tags={}, timestamp=None, database=None):
    
    point = {
        'measurement': name,
        'tags': tags,
        'fields': values
    }
    if isinstance(timestamp, datetime):
        timestamp = timestamp.strftime('%Y-%m-%dT%H:%M:%SZ')
    if timestamp:
        point['time'] = timestamp
    try:
        get_db().write({'points': [point]},
                       {'db': database or settings.INFLUXDB_DATABASE})
    except Exception, e:
        if settings.INFLUXDB_FAIL_SILENTLY:
            pass
        else:
            raise e
552897
def write(self, request):
    """"""
    if FLAGS.sc2_verbose_protocol:
      self._log(" Writing request ".center(60, "-") + "\n")
      self._log_packet(request)
    self._write(request)
286053
def init(self):
        """"""
        if not self.export_enable:
            return None

        if self.user is None:
            server_uri = 'http://{}:{}/'.format(self.host,
                                                self.port)
        else:
            server_uri = 'http://{}:{}@{}:{}/'.format(self.user,
                                                      self.password,
                                                      self.host,
                                                      self.port)

        try:
            s = couchdb.Server(server_uri)
        except Exception as e:
            logger.critical("Cannot connect to CouchDB server %s (%s)" % (server_uri, e))
            sys.exit(2)
        else:
            logger.info("Connected to the CouchDB server %s" % server_uri)

        try:
            s[self.db]
        except Exception as e:
            # Database did not exist
            # Create it...
            s.create(self.db)
        else:
            logger.info("There is already a %s database" % self.db)

        return s
528741
function rewriteDuration() {
                var
                    buffer = new ArrayBufferDataStream(8),
                    oldPos = blobBuffer.pos;
                
                // Rewrite the data payload (don't need to update the id or size)
                buffer.writeDoubleBE(clusterStartTime);
                
                // And write that through to the file
                blobBuffer.seek(segmentDuration.dataOffset);
                blobBuffer.write(buffer.getAsDataArray());
        
                blobBuffer.seek(oldPos);
            }
1023637
def write(self, oprot):
        '''
        
        '''

        oprot.write_struct_begin('OnlineDatabaseObjectDetail')

        oprot.write_field_begin(name='attributes', type=13, id=None)
        oprot.write_map_begin(11, len(self.attributes), 11)
        for __key0, __value0 in self.attributes.items():
            oprot.write_string(__key0)
            oprot.write_string(__value0)
        oprot.write_map_end()
        oprot.write_field_end()

        oprot.write_field_begin(name='guid', type=11, id=None)
        oprot.write_string(self.guid)
        oprot.write_field_end()

        oprot.write_field_begin(name='id', type=11, id=None)
        oprot.write_string(self.id)
        oprot.write_field_end()

        oprot.write_field_begin(name='related_photos', type=15, id=None)
        oprot.write_list_begin(12, len(self.related_photos))
        for _0 in self.related_photos:
            _0.write(oprot)
        oprot.write_list_end()
        oprot.write_field_end()

        oprot.write_field_stop()

        oprot.write_struct_end()

        return self
115767
def WriteClientStats(self,
                       client_id,
                       stats,
                       cursor=None):
    """"""

    try:
      cursor.execute(
          """
          INSERT INTO client_stats (client_id, payload, timestamp)
          VALUES (%s, %s, FROM_UNIXTIME(%s))
          ON DUPLICATE KEY UPDATE payload=VALUES(payload)
          """, [
              db_utils.ClientIDToInt(client_id),
              stats.SerializeToString(),
              mysql_utils.RDFDatetimeToTimestamp(rdfvalue.RDFDatetime.Now())
          ])
    except MySQLdb.IntegrityError as e:
      if e.args[0] == mysql_error_constants.NO_REFERENCED_ROW_2:
        raise db.UnknownClientError(client_id, cause=e)
      else:
        raise
596
def post(self):
        """"""
        self.set_header("Content-Type", "application/json")
        key = uuid.uuid4().hex
        metadata = json.loads(self.request.body.decode())
        metadata["uuid"] = key
        self.database[key] = metadata
        result = json.dumps({"uuid": key})
        self.write(result)
979049
def db_for_write(self, model, **hints):
        
        if model._meta.app_label in self._apps:
            return getattr(model, '_db_alias', model._meta.app_label)
        return None
1275426
def _write(self, request):
    """"""
    with sw("serialize_request"):
      request_str = request.SerializeToString()
    with sw("write_request"):
      with catch_websocket_connection_errors():
        self._sock.send(request_str)
181509
def write(self, oprot):
        '''
        
        '''

        oprot.write_struct_begin('DbfDatabaseConfiguration')

        if self.pp_images_dir_path is not None:
            oprot.write_field_begin(name='pp_images_dir_path', type=11, id=None)
            oprot.write_string(self.pp_images_dir_path)
            oprot.write_field_end()

        if self.pp_install_dir_path is not None:
            oprot.write_field_begin(name='pp_install_dir_path', type=11, id=None)
            oprot.write_string(self.pp_install_dir_path)
            oprot.write_field_end()

        if self.pp_objects_dbf_file_path is not None:
            oprot.write_field_begin(name='pp_objects_dbf_file_path', type=11, id=None)
            oprot.write_string(self.pp_objects_dbf_file_path)
            oprot.write_field_end()

        oprot.write_field_stop()

        oprot.write_struct_end()

        return self
207169
def _write_cluster(metacluster, cluster, loci, idx, path):
    
    out_file = op.join(path, 'log', str(idx) + '.bed')
    with utils.safe_run(out_file):
        with open(out_file, 'w') as out_handle:
            for idc in metacluster:
                for idl in cluster[idc].loci2seq:
                    pos = loci[idl].list()
                    print("\t".join(pos[:4] + [str(len(cluster[idc].loci2seq[idl]))] + [pos[-1]]), file=out_handle, end="")
1224271
function CouchDB () {
  var self = this;

  self.klass = CouchDB;
  self.klass.super_.apply(self, arguments);

  if (self.options.server.protocol === 'https') {
    self.options.server.port = self.options.server.port || 443;
    self.options.server.secure = true;
  }

  if (self.options.server.username || self.options.server.password) {
    self.options.client.auth = {
      username: self.options.server.username,
      password: self.options.server.password
    };
  }
}
273548
private function writeIndexes()
    {
        //Begin database batch
        $this->beginBatch();

        //Index all node entities
        foreach ($this->nodeEntities as $entity)
        {
            $this->index($entity);
        }

        //Index all relation entities
        foreach ($this->relationEntities as $entity)
        {
            $this->index($entity);
        }

        //Write all repository indexes
        foreach ($this->repositories as $repository)
        {
            $repository->writeIndex();
        }

        //Commit batch to the database
        $this->commitBatch();
    }
415787
def main(host='localhost', port=8086):
    """"""
    now = datetime.datetime.today()
    points = []

    for angle in range(0, 360):
        y = 10 + math.sin(math.radians(angle)) * 10

        point = {
            "measurement": 'foobar',
            "time": int(now.strftime('%s')) + angle,
            "fields": {
                "value": y
            }
        }
        points.append(point)

    client = InfluxDBClient(host, port, USER, PASSWORD, DBNAME)

    print("Create database: " + DBNAME)
    client.create_database(DBNAME)
    client.switch_database(DBNAME)

    # Write points
    client.write_points(points)

    time.sleep(3)

    query = 'SELECT * FROM foobar'
    print("Querying data: " + query)
    result = client.query(query, database=DBNAME)
    print("Result: {0}".format(result))

    """
    You might want to comment the delete and plot the result on InfluxDB
    Interface. Connect on InfluxDB Interface at http://127.0.0.1:8083/
    Select the database tutorial -> Explore Data

    Then run the following query:

        SELECT * from foobar
    """

    print("Delete database: " + DBNAME)
    client.drop_database(DBNAME)
800977
def write(models, out=None, base=None, logger=logging):
    '''
    
    '''
    assert out is not None #Output stream required
    if not isinstance(models, list): models = [models]
    for m in models:
        for link in m.match():
            s, p, o = link[:3]
            #Skip docheader statements
            if s == (base or '') + '@docheader': continue
            if p in RESOURCE_MAPPING: p = RESOURCE_MAPPING[p]
            if o in RESOURCE_MAPPING: o = RESOURCE_MAPPING[o]
            
            if p == VERSA_TYPE_REL: p = RDF_TYPE_REL
            print(strconv(s), strconv(p), strconv(o), '.', file=out)
    return