Get users zarafa-search index file location

From Zarafa wiki

Revision as of 09:58, 24 May 2013 by Ddebyttere (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Example: ./ username

Save as

#!/usr/bin/env python

from MAPI import *
from MAPI.Util import *
import sys
import re

def read_config(filename):

    Get the value of a config file variable
    The value is separated by an equal character
    r = re.compile(r'^\s*(\S+)\s*=\s*([^\n\r]*?)[\s\n\r]?$')
    l = []
    for line in open(filename, 'r'):
        if line.startswith('#'):
        m = r.match(line)
        if m:
    return dict(l)

if len(sys.argv) < 2: # Check if username input is present, otherwise exit.
    sys.exit('Usage: %s username' % sys.argv[0])

indexPath = read_config('/etc/zarafa/search.cfg')['index_path'] # Read index_path variable from config.

s = OpenECSession(sys.argv[1], '', 'file:///var/run/zarafa') # Open new user session
st = GetDefaultStore(s) # Get the users default store

# E.g. /var/lib/zarafa/index/7B722BFC3AA542C1BE4F0DE9CF92D1EB-9B003200E1944B6ABF15378C2FE90AB5.kct
print 'Index file is at:', indexPath+ st.GetProps([PR_MAPPING_SIGNATURE], 0)[0].Value.encode('hex').upper()+ "-" +st.GetProps([PR_RECORD_KEY], 0)[0].Value.encode('hex').upper()+ ".kct"
Personal tools