blob: ab91a603f9a83a7df7e084aaf5f5d5a562ccda23 (
plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#! -*- encoding: utf-8 -*-
"""
xxx fill me in
"""
import os
import yaml
from leap.util import log, version
config_filename = 'mx.conf'
class MissingConfig(Exception):
"""Raised when the config file cannot be found."""
def __init__(self, message=None, config_file=None):
if message:
return
else:
self.message = "Cannot locate config file"
if config_file:
self.message += " %s" % config_file
self.message += "."
def getConfigFilename(dir=None, file=None):
"""
xxx fill me in
"""
if not dir:
dir = version.getRepoDir()
if not file:
file = config_filename
return os.path.join(dir, file)
def createConfigFile(config_file=None):
"""
xxx fill me in
"""
if not config_file:
config_file = getConfigFilename()
if not os.path.isfile(config_file):
with open(config_file, 'w+') as conf:
conf.write("""
#
# mx.conf
# =======
# Configurable options for the leap_mx encrypting mail exchange.
#
""")
conf.flush()
else:
log.debug("Config file %s already present." % config_file)
def loadConfigFile(config_file=None):
"""
xxx fill me in
"""
if not config_file:
config_file = getConfigFilename()
if os.path.isfile(config_file):
with open(config_file, 'a+') as conf:
config_contents = '\n'.join(conf.readlines())
configuration = yaml.safe_load(config_contents)
else:
createConfigFile(config_file)
## xxx finish load config
## ask kali if we're using yaml or json or what?
## xxx kali says json, so ixnay on the amlya bits
|