Replace the entire datastore with a passed data structure

    CLI Example:

    .. code-block:: bash

        salt '*' data.dump '{'eggs': 'spam'}'
425657
def dump(new_data):
    '''
    
    '''
    if not isinstance(new_data, dict):
        if isinstance(ast.literal_eval(new_data), dict):
            new_data = ast.literal_eval(new_data)
        else:
            return False

    try:
        datastore_path = os.path.join(__opts__['cachedir'], 'datastore')
        with salt.utils.files.fopen(datastore_path, 'w+b') as fn_:
            serial = salt.payload.Serial(__opts__)
            serial.dump(new_data, fn_)

        return True

    except (IOError, OSError, NameError):
        return False
1159956
def update(self, data):
        
        if data:
            _dumps = self._dumps
            zargs = [
                _dumps(x) if (i % 2 == 1) else x
                for y in data.items()
                for i, x in enumerate(reversed(y))
            ]
            return self._client.zadd(self.key_prefix, *zargs)
1209281
def make_value_from_datastore(self, value):
    

    if value is None:
      return None
    _json = json.loads(value, cls=JsonDecoder)
    if self.data_type == dict:
      return _json
    return self.data_type.from_json(_json)
670292
void dumpExcessReplicasSets(PrintWriter out) {
    int size = excessReplicateMap.values().size();
    out.println("Metasave: Excess blocks " + excessBlocksCount
      + " waiting deletion from " + size + " datanodes.");
    if (size == 0) {
      return;
    }
    for (Map.Entry<String, LightWeightHashSet<Block>> entry : excessReplicateMap
        .entrySet()) {
      LightWeightHashSet<Block> blocks = entry.getValue();
      if (blocks.size() > 0) {
        out.println(datanodeMap.get(entry.getKey()).getName());
        blocks.printDetails(out);
      }
    }
  }
682635
def insertDatastore(self, index, store):
    ''''''
    if not isinstance(store, Datastore):
      raise TypeError("stores must be of type %s" % Datastore)

    self._stores.insert(index, store)
1167544
def appendDatastore(self, store):
    ''''''
    if not isinstance(store, Datastore):
      raise TypeError("stores must be of type %s" % Datastore)

    self._stores.append(store)
790734
def dump_all(data_list, stream=None, **kwargs):
    
    return yaml.dump_all(
        data_list,
        stream=stream,
        Dumper=YAMLDictDumper,
        **kwargs
    )
1266907
def publish(self, key, data):
        '''
        
        '''
        publish_data = {key: data}
        pub = salt.utils.json.dumps(publish_data) + str('\n\n')  # future lint: disable=blacklisted-function
        self.handler.write_message(pub)
357099
def cleanup_datastore(self):
    """"""
    print_header('CLEANING UP ENTIRE DATASTORE')
    kinds_to_delete = [u'Submission', u'SubmissionType',
                       u'DatasetImage', u'DatasetBatch',
                       u'AdversarialImage', u'AdversarialBatch',
                       u'Work', u'WorkType',
                       u'ClassificationBatch']
    keys_to_delete = [e.key for k in kinds_to_delete
                      for e in self.datastore_client.query_fetch(kind=k)]
    self._cleanup_keys_with_confirmation(keys_to_delete)
379702
def dump(data, stream=None, Dumper=Dumper, **kwds):
    
    return dump_all([data], stream, Dumper=Dumper, **kwds)
953930
def purge_stale_services(argv=None):
    
    argv = argv or sys.argv
    arg_parser = argparse.ArgumentParser(
            prog=os.path.basename(argv[0]), description=(
                'doublethink-purge-stale-services: utility to periodically '
                'purge stale entries from the "services" table.'))

    arg_parser.add_argument(
            "-d", "--rethinkdb-db", required=True, dest="database",
            help="A RethinkDB database containing a 'services' table")

    arg_parser.add_argument("-s", "--rethinkdb-servers",
        metavar="SERVERS", dest="servers", default='localhost',
        help="rethinkdb servers, e.g. db0.foo.org,db0.foo.org:38015,db1.foo.org")

    arg_parser.add_argument(
        '-v', '--verbose', dest='log_level', action='store_const',
        default=logging.INFO, const=logging.DEBUG, help=(
                'verbose logging'))
    args = arg_parser.parse_args(argv[1:])
    logging.basicConfig(
            stream=sys.stdout, level=args.log_level, format=(
                '%(asctime)s %(process)d %(levelname)s %(threadName)s '
                '%(name)s.%(funcName)s(%(filename)s:%(lineno)d) %(message)s'))

    args.servers = [srv.strip() for srv in args.servers.split(",")]

    rethinker = doublethink.Rethinker(servers=args.servers, db=args.database)
    registry = doublethink.services.ServiceRegistry(rethinker)
    registry.purge_stale_services()
    return 0
1089579
def put(self, key, value):
    ''''''
    return self.child_datastore.put(self._transform(key), value)
264725
def replace_blocks(self, blocks):
        """"""
        start = 0
        bulk_insert = self.bulk_insert
        blocks_len = len(blocks)
        row = '(%s,%s,%s,%s,%s)'
        query = 'REPLACE INTO gauged_data (namespace, offset, `key`, ' \
            'data, flags) VALUES '
        execute = self.cursor.execute
        to_buffer = self.to_buffer
        while start < blocks_len:
            rows = blocks[start:start+bulk_insert]
            params = []
            for namespace, offset, key, data, flags in rows:
                params.extend((namespace, offset, key, to_buffer(data), flags))
            insert = (row + ',') * (len(rows) - 1) + row
            execute(query + insert, params)
            start += bulk_insert
438147
def clone(self, **data):
        '''
'''
        meta = self._meta
        session = self.session
        pkname = meta.pkname()
        pkvalue = data.pop(pkname, None)
        fields = self.todict(exclude_cache=True)
        fields.update(data)
        fields.pop('__dbdata__', None)
        obj = self._meta.make_object((pkvalue, None, fields))
        obj.session = session
        return obj
623510
def datastore(self, datastore):
        
        if isinstance(datastore, DataStore):
            self._datastore = datastore
        else:
            raise Exception('%s is not a valid datastore.' % datastore)
565656
def _handle_dump_unknown(self, data, original):
        """"""
        for key, val in original.items():
            if key not in self.fields:
                data[key] = val
        return data
850053
def index(self, format='html'):
        """"""
        # url('datastores')
        results = meta.Session.query(DataStore)
        serialized_datastores = [{'id': ds.id, 'text': ds.name, 'href': h.url_for(controller="datastores", action="show", id=ds.id), 'type': ds.type} for ds in results]
        # prevent JSON Array Cross-site Exploits (XSRF/CSRF)
        return {'datastores': serialized_datastores}