##// END OF EJS Templates
svn: Split up config generation method and do not raise exceptions on writing config to file.
Martin Bornhold -
r571:9f6938e9 default
parent child Browse files
Show More
@@ -18,6 +18,7 b''
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import logging
21 import os
22 import os
22
23
23 from pyramid.renderers import render
24 from pyramid.renderers import render
@@ -26,6 +27,9 b' from rhodecode.model.db import RepoGroup'
26 from . import config_keys
27 from . import config_keys
27
28
28
29
30 log = logging.getLogger(__name__)
31
32
29 def generate_mod_dav_svn_config(settings):
33 def generate_mod_dav_svn_config(settings):
30 """
34 """
31 Generate the configuration file for use with subversion's mod_dav_svn
35 Generate the configuration file for use with subversion's mod_dav_svn
@@ -33,14 +37,21 b' def generate_mod_dav_svn_config(settings'
33 available repository group because the mod_dav_svn module does not support
37 available repository group because the mod_dav_svn module does not support
34 repositories organized in sub folders.
38 repositories organized in sub folders.
35 """
39 """
36 filepath = settings[config_keys.config_file_path]
40 config = _render_mod_dav_svn_config(
37 parent_path_root = settings[config_keys.parent_path_root]
41 settings[config_keys.parent_path_root],
38 list_parent_path = settings[config_keys.list_parent_path]
42 settings[config_keys.list_parent_path],
39 location_root = settings[config_keys.location_root]
43 settings[config_keys.location_root],
44 RepoGroup.get_all_repo_groups())
45 _write_mod_dav_svn_config(config, settings[config_keys.config_file_path])
46
40
47
41 # Prepare render context.
48 def _render_mod_dav_svn_config(
49 parent_path_root, list_parent_path, location_root, repo_groups):
50 """
51 Render mod_dav_svn configuration to string.
52 """
42 repo_group_paths = []
53 repo_group_paths = []
43 for repo_group in RepoGroup.get_all_repo_groups():
54 for repo_group in repo_groups:
44 group_path = repo_group.full_path_splitted
55 group_path = repo_group.full_path_splitted
45 location = os.path.join(location_root, *group_path)
56 location = os.path.join(location_root, *group_path)
46 parent_path = os.path.join(parent_path_root, *group_path)
57 parent_path = os.path.join(parent_path_root, *group_path)
@@ -55,8 +66,16 b' def generate_mod_dav_svn_config(settings'
55
66
56 # Render the configuration template to string.
67 # Render the configuration template to string.
57 template = 'rhodecode:svn_support/templates/mod-dav-svn.conf.mako'
68 template = 'rhodecode:svn_support/templates/mod-dav-svn.conf.mako'
58 mod_dav_svn_config = render(template, context)
69 return render(template, context)
70
59
71
60 # Write configuration to file.
72 def _write_mod_dav_svn_config(config, filepath):
61 with open(filepath, 'w') as file_:
73 """
62 file_.write(mod_dav_svn_config)
74 Write mod_dav_svn config to file. Log on exceptions but do not raise.
75 """
76 try:
77 with open(filepath, 'w') as file_:
78 file_.write(config)
79 except Exception:
80 log.exception(
81 'Can not write mod_dav_svn configuration to "%s"', filepath)
General Comments 0
You need to be logged in to leave comments. Login now