Writes the full history for a particular client.
321728
def WriteClientSnapshotHistory(self, clients, cursor=None):
    """"""
    client_id = clients[0].client_id
    latest_timestamp = max(client.timestamp for client in clients)

    query = ""
    params = {
        "client_id": db_utils.ClientIDToInt(client_id),
        "latest_timestamp": mysql_utils.RDFDatetimeToTimestamp(latest_timestamp)
    }

    for idx, client in enumerate(clients):
      startup_info = client.startup_info
      client.startup_info = None

      query += """
      INSERT INTO client_snapshot_history (client_id, timestamp,
                                           client_snapshot)
      VALUES (%(client_id)s, FROM_UNIXTIME(%(timestamp_{idx})s),
              %(client_snapshot_{idx})s);

      INSERT INTO client_startup_history (client_id, timestamp,
                                          startup_info)
      VALUES (%(client_id)s, FROM_UNIXTIME(%(timestamp_{idx})s),
              %(startup_info_{idx})s);
      """.format(idx=idx)

      params.update({
          "timestamp_{idx}".format(idx=idx):
              mysql_utils.RDFDatetimeToTimestamp(client.timestamp),
          "client_snapshot_{idx}".format(idx=idx):
              client.SerializeToString(),
          "startup_info_{idx}".format(idx=idx):
              startup_info.SerializeToString(),
      })

      client.startup_info = startup_info

    query += """
    UPDATE clients
       SET last_snapshot_timestamp = FROM_UNIXTIME(%(latest_timestamp)s)
     WHERE client_id = %(client_id)s
       AND (last_snapshot_timestamp IS NULL OR
            last_snapshot_timestamp < FROM_UNIXTIME(%(latest_timestamp)s));

    UPDATE clients
       SET last_startup_timestamp = FROM_UNIXTIME(%(latest_timestamp)s)
     WHERE client_id = %(client_id)s
       AND (last_startup_timestamp IS NULL OR
            last_startup_timestamp < FROM_UNIXTIME(%(latest_timestamp)s));
    """

    try:
      cursor.execute(query, params)
    except MySQLdb.IntegrityError as error:
      raise db.UnknownClientError(client_id, cause=error)
681469
def _write_history(self):
        """"""
        if self.data['history_file'] is None:
            return
        contents = '\n'.join(self.data['history_lines'])
        history = self.data['history_file']
        open(history, 'w').write(contents)
        logger.info("History file %s updated.", history)
924597
private void writeFile() throws IOException {
        historyFile.delete();
        try (FileWriter fw = new FileWriter(historyFile)) {
            for(int i=0; i < size();i++)
                fw.write(Parser.fromCodePoints(get(i)) + (Config.getLineSeparator()));
        }
        if (historyFilePermission != null) {
            historyFile.setReadable(false, false);
            historyFile.setReadable(historyFilePermission.isReadable(), historyFilePermission.isReadableOwnerOnly());
            historyFile.setWritable(false, false);
            historyFile.setWritable(historyFilePermission.isWritable(), historyFilePermission.isWritableOwnerOnly());
            historyFile.setExecutable(false, false);
            historyFile.setExecutable(historyFilePermission.isExecutable(),
                    historyFilePermission.isExecutableOwnerOnly());
        }
    }
230085
def WriteClientStartupInfo(self, client_id, startup_info, cursor=None):
    """"""
    query = """
    SET @now = NOW(6);

    INSERT INTO client_startup_history (client_id, timestamp, startup_info)
         VALUES (%(client_id)s, @now, %(startup_info)s);

    UPDATE clients
       SET last_startup_timestamp = @now
     WHERE client_id = %(client_id)s;
    """

    params = {
        "client_id": db_utils.ClientIDToInt(client_id),
        "startup_info": startup_info.SerializeToString(),
    }

    try:
      cursor.execute(query, params)
    except MySQLdb.IntegrityError as e:
      raise db.UnknownClientError(client_id, cause=e)
1065825
public void addHistory(Object historyKey)
    {
        if (this.history == null)
        {
            this.history = new KeyHistory();
        }

        this.history.addKey(historyKey.toString());
    }
814132
def WriteClientSnapshot(self, snapshot, cursor=None):
    """"""
    insert_history_query = (
        "INSERT INTO client_snapshot_history(client_id, timestamp, "
        "client_snapshot) VALUES (%s, FROM_UNIXTIME(%s), %s)")
    insert_startup_query = (
        "INSERT INTO client_startup_history(client_id, timestamp, "
        "startup_info) VALUES(%s, FROM_UNIXTIME(%s), %s)")

    now = rdfvalue.RDFDatetime.Now()

    client_platform = snapshot.knowledge_base.os
    current_timestamp = mysql_utils.RDFDatetimeToTimestamp(now)
    client_info = {
        "last_snapshot_timestamp": current_timestamp,
        "last_startup_timestamp": current_timestamp,
        "last_version_string": snapshot.GetGRRVersionString(),
        "last_platform_release": snapshot.Uname(),
    }
    update_clauses = [
        "last_snapshot_timestamp = FROM_UNIXTIME(%(last_snapshot_timestamp)s)",
        "last_startup_timestamp = FROM_UNIXTIME(%(last_startup_timestamp)s)",
        "last_version_string = %(last_version_string)s",
        "last_platform_release = %(last_platform_release)s",
    ]
    if client_platform:
      client_info["last_platform"] = client_platform
      update_clauses.append("last_platform = %(last_platform)s")

    update_query = (
        "UPDATE clients SET {} WHERE client_id = %(client_id)s".format(
            ", ".join(update_clauses)))

    int_client_id = db_utils.ClientIDToInt(snapshot.client_id)
    client_info["client_id"] = int_client_id

    startup_info = snapshot.startup_info
    snapshot.startup_info = None
    try:
      cursor.execute(
          insert_history_query,
          (int_client_id, current_timestamp, snapshot.SerializeToString()))
      cursor.execute(
          insert_startup_query,
          (int_client_id, current_timestamp, startup_info.SerializeToString()))
      cursor.execute(update_query, client_info)
    except MySQLdb.IntegrityError as e:
      raise db.UnknownClientError(snapshot.client_id, cause=e)
    finally:
      snapshot.startup_info = startup_info
700628
def WriteClientStats(self, client_id,
                       stats):
    """"""
    if client_id not in self.ReadAllClientIDs():
      raise db.UnknownClientError(client_id)

    self.client_stats[client_id][rdfvalue.RDFDatetime.Now()] = stats
63325
def hosting_history(self, query, **kwargs):
        """"""
        return self._results('hosting-history', '/v1/{0}/hosting-history'.format(query), cls=GroupedIterable, **kwargs)
1047403
def RecordHistory(self):
        """"""
        if not self.restoringHistory:
            record = self.activated_node
            if self.historyIndex < -1:
                try:
                    del self.history[self.historyIndex+1:]
                except AttributeError, err:
                    pass
            if (not self.history) or record != self.history[-1]:
                self.history.append(record)
            del self.history[:-200]
            self.historyIndex = -1
12226
def update_history(self, directory):
        """"""
        try:
            directory = osp.abspath(to_text_string(directory))
            if directory in self.history:
                self.histindex = self.history.index(directory)
        except Exception:
            user_directory = get_home_dir()
            self.chdir(directory=user_directory, browsing_history=True)
149559
public function onReportsHistory()
    {
        $this->onSystemInformations();
        Breadcrumbs::register('logger-reports-history', function($breadcrumbs) {
            $breadcrumbs->parent('logger-system-informations');
            $breadcrumbs->push('Reports history', handles('antares::logger/history'));
        });
        view()->share('breadcrumbs', Breadcrumbs::render('logger-reports-history'));
    }
393780
def history(ctx, account, limit, type, csv, exclude, raw):
    
    from bitsharesbase.operations import getOperationNameForId

    t = [["#", "time (block)", "operation", "details"]]

    for a in account:
        account = Account(a, bitshares_instance=ctx.bitshares)
        for b in account.history(limit=limit, only_ops=type, exclude_ops=exclude):
            block = BlockHeader(b["block_num"])
            row = [
                b["id"],
                "%s (%s)" % (block.time(), b["block_num"]),
                "{} ({})".format(getOperationNameForId(b["op"][0]), b["op"][0]),
                pprintOperation(b) if not raw else json.dumps(b, indent=4),
            ]
            t.append(row)
    print_table(t)
1229138
def ReadClientSnapshotHistory(self, client_id, timerange=None):
    """"""
    from_time, to_time = self._ParseTimeRange(timerange)

    history = self.clients.get(client_id)
    if not history:
      return []
    res = []
    for ts in sorted(history, reverse=True):
      if ts < from_time or ts > to_time:
        continue

      client_obj = rdf_objects.ClientSnapshot.FromSerializedString(history[ts])
      client_obj.timestamp = ts
      client_obj.startup_info = rdf_client.StartupInfo.FromSerializedString(
          self.startup_history[client_id][ts])
      res.append(client_obj)
    return res
696394
public static void getHistory() throws Exception{
        Client client = new Client("ProfileName", false);

        // Obtain the 100 history entries starting from offset 0
        History[] history = client.refreshHistory(100, 0);

        client.clearHistory();
    }
827735
def WritePathHashHistory(self, client_path, hash_entries):
    
    client_path_history = ClientPathHistory()
    for timestamp, hash_entry in iteritems(hash_entries):
      client_path_history.AddHashEntry(timestamp, hash_entry)

    self.MultiWritePathHistory({client_path: client_path_history})
1257105
public void writeHistoryProject(CmsDbContext dbc, int publishTag, long publishDate) throws CmsDataAccessException {

        getHistoryDriver(dbc).writeProject(dbc, publishTag, publishDate);
    }
452449
def ReadClientStartupInfoHistory(self, client_id, timerange=None,
                                   cursor=None):
    """"""

    client_id_int = db_utils.ClientIDToInt(client_id)

    query = ("SELECT startup_info, UNIX_TIMESTAMP(timestamp) "
             "FROM client_startup_history "
             "WHERE client_id=%s ")
    args = [client_id_int]

    if timerange:
      time_from, time_to = timerange  # pylint: disable=unpacking-non-sequence

      if time_from is not None:
        query += "AND timestamp >= FROM_UNIXTIME(%s) "
        args.append(mysql_utils.RDFDatetimeToTimestamp(time_from))

      if time_to is not None:
        query += "AND timestamp <= FROM_UNIXTIME(%s) "
        args.append(mysql_utils.RDFDatetimeToTimestamp(time_to))

    query += "ORDER BY timestamp DESC "

    ret = []
    cursor.execute(query, args)

    for startup_info, timestamp in cursor.fetchall():
      si = rdf_client.StartupInfo.FromSerializedString(startup_info)
      si.timestamp = mysql_utils.TimestampToRDFDatetime(timestamp)
      ret.append(si)
    return ret