forked from manishmohanlal/Fuse---KVFS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindxattr
executable file
·36 lines (22 loc) · 926 Bytes
/
findxattr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python
import os,sys,logging,re
import argparse
parser = argparse.ArgumentParser(description='Process attribute names and values')
parser.add_argument('--key', dest="attributes", action='append', help='attribute name to search for')
parser.add_argument('--val', dest="values", action='append', nargs='+', help="attribute value")
args = parser.parse_args()
path = os.getenv("KFS_PATH")
sys.path.append(path)
#from path
from mongo_wrapper import *
import helper
logging.basicConfig(filename=path+'/log',level=logging.DEBUG)
logging.info("Script called")
initialValSet = helper.initialize()
mongo = mongoWrapper(initialValSet['mongo_host'],int(initialValSet['mongo_port']))
search = dict()
for i in range(0,len(args.attributes)):
search[args.attributes[i]] = {'$in':[re.compile(x) for x in args.values[i]]}
for i in mongo.collection.find(search):
print i['_id']
os.system("getfattr -d "+i['_id'][1:])