Added startup stack size check
[elliptics.git] / example / remove_keys_from_storage_found_removed_in_eblob.py
blob8368e407a8b5113e201ac3c1d15e217b076ba6df
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
4 import sys
5 sys.path.insert(0, "/usr/lib/")
6 sys.path.insert(0, "./.libs/")
7 sys.path.insert(0, "bindings/python/.libs/")
8 from libelliptics_python import *
9 import eblob
11 class remover:
12 def __init__(self, remotes=[], groups=[], log='/dev/stdout', mask=8, path=''):
13 self.log = elliptics_log_file(log, mask)
14 self.n = elliptics_node_python(self.log)
16 self.n.add_groups(groups)
17 for r in remotes:
18 try:
19 self.n.add_remote(r[0], r[1])
20 except:
21 pass
22 if len(self.n.get_routes()) == 0:
23 raise NameError("Route table for group " + str(group) + " is empty")
25 b = eblob.blob(path)
26 for id in b.iterate(want_removed=True):
27 if b.removed():
28 for g in groups:
29 eid = elliptics_id(list(bytearray(id)), g, -1)
30 self.n.remove(eid, 0)
32 print "%s: flags: %x, position: %d, data_size: %d" % \
33 (b.sid(count=64), b.flags, b.position, b.data_size)
36 if __name__ == '__main__':
37 # this script runs over index for given blob, finds all removed entries and removes them from the storage
39 # list of tuples of remote addresses to connect and grab route table
40 remotes = [('elisto19f.dev', 1025)]
42 # these groups
43 groups = [1, 2, 3]
45 # Path to blob to get objects from. Index file must be near with .index suffix
46 inpath='/opt/elliptics/eblob.2/data.0'
48 try:
49 remover(remotes=remotes, groups=groups, path=inpath)
50 except NameError as e:
51 print "Completed:", e