summaryrefslogtreecommitdiff
path: root/src/leap/eip/config.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-27 23:21:43 +0900
committerkali <kali@leap.se>2012-08-27 23:31:39 +0900
commit4a46723219e5284bec21b9dccd6589a670babc63 (patch)
treeb2d435b0c7e616c91cbf92b185f097985aec041e /src/leap/eip/config.py
parente896190d159342d9819f0ad6f11fe01deb8eb9e5 (diff)
add test_dump_default_eipconfig to eip.test_checks
plus a little bit of cleaning around (created constants file). added some notes about inminent deprecation *work in progress*
Diffstat (limited to 'src/leap/eip/config.py')
-rw-r--r--src/leap/eip/config.py37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py
index 8d5c19da..2694ca61 100644
--- a/src/leap/eip/config.py
+++ b/src/leap/eip/config.py
@@ -1,4 +1,5 @@
-import ConfigParser
+import ConfigParser # to be deprecated
+import json
import logging
import os
import platform
@@ -6,6 +7,8 @@ import socket
from leap.util.fileutil import (which, mkdir_p,
check_and_fix_urw_only)
+
+# from leap.base import config as baseconfig
from leap.base.config import (get_default_provider_path,
get_config_file,
get_username,
@@ -14,6 +17,7 @@ from leap.base.config import (get_default_provider_path,
from leap.baseapp.permcheck import (is_pkexec_in_system,
is_auth_agent_running)
from leap.eip import exceptions as eip_exceptions
+from leap.eip import constants as eipconstants
logger = logging.getLogger(name=__name__)
logger.setLevel('DEBUG')
@@ -276,6 +280,8 @@ def get_sensible_defaults():
return defaults
+# XXX to be deprecated. see dump_default_eipconfig
+# and the new JSONConfig classes.
def get_config(config_file=None):
"""
temporary method for getting configs,
@@ -286,10 +292,6 @@ def get_config(config_file=None):
@rtype: ConfigParser instance
@rparam: a config object
"""
- # TODO
- # - refactor out common things and get
- # them to util/ or baseapp/
-
defaults = get_sensible_defaults()
config = ConfigParser.ConfigParser(defaults)
@@ -302,21 +304,24 @@ def get_config(config_file=None):
with open(fpath, 'wb') as configfile:
config.write(configfile)
config_file = open(fpath)
-
- #TODO
- # - convert config_file to list;
- # look in places like /etc/leap/eip.cfg
- # for global settings.
- # - raise warnings/error if bad options.
-
- # at this point, the file should exist.
- # errors would have been raised above.
-
config.readfp(config_file)
-
return config
+def dump_default_eipconfig(filepath):
+ """
+ writes a sample eip config
+ in the given location
+ """
+ # XXX TODO:
+ # use EIPConfigSpec istead
+ folder, filename = os.path.split(filepath)
+ if not os.path.isdir(folder):
+ mkdir_p(folder)
+ with open(filepath, 'w') as fp:
+ json.dump(eipconstants.EIP_SAMPLE_JSON, fp)
+
+
def check_vpn_keys(config):
"""
performs an existance and permission check