-
Notifications
You must be signed in to change notification settings - Fork 4
/
initalsync.py
executable file
·50 lines (37 loc) · 1.48 KB
/
initalsync.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/env python
#-*- coding: utf-8 -*-
""" Run a initial full sync of a akonadi resource.
Copyright: Sandro Knauß <[email protected]>
Date: 2015-12-02
Licence: GPL-2+
"""
import argparse
from email.Utils import formataddr
import logging
import os
import subprocess
from sync import akonadi, config, kwalletbinding
from sync.dbusServer import DBusServer
parser = argparse.ArgumentParser(description='run a initial full sync of a akonadi resource.')
parser.add_argument('name', help='name of the kolabuser')
parser.add_argument('mail', help='mail of the kolabuser')
parser.add_argument('uid', help='uid of the kolabuser')
parser.add_argument('password', help='password of the kolabuser')
parser.add_argument('resource', help='name of the akonadi_resource to sync something like "akonadi_kolab_resource_0"')
options = parser.parse_args()
name = options.name
email = options.mail
fullName = formataddr((name, email))
uid = options.uid
password = options.password
home = os.path.expanduser("~")
akonadi_resource_name = options.resource
logging.basicConfig(level=logging.INFO)
logging.info("setup configs")
config.setupConfigDirs(home, fullName, email, name, uid, password)
with DBusServer():
logging.info("set kwallet password")
kwalletbinding.kwallet_put("imap", akonadi_resource_name+"rc", password)
with akonadi.AkonadiServer(open("akonadi.log", "w"), open("akonadi.err", "w")):
logging.info("trigger fullSync")
akonadi.fullSync(akonadi_resource_name)