Show More
@@ -18,6 +18,7 b'' | |||
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | import logging | |
|
21 | 22 | import os |
|
22 | 23 | |
|
23 | 24 | from pyramid.renderers import render |
@@ -26,6 +27,9 b' from rhodecode.model.db import RepoGroup' | |||
|
26 | 27 | from . import config_keys |
|
27 | 28 | |
|
28 | 29 | |
|
30 | log = logging.getLogger(__name__) | |
|
31 | ||
|
32 | ||
|
29 | 33 | def generate_mod_dav_svn_config(settings): |
|
30 | 34 | """ |
|
31 | 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 | 37 | available repository group because the mod_dav_svn module does not support |
|
34 | 38 | repositories organized in sub folders. |
|
35 | 39 | """ |
|
36 | filepath = settings[config_keys.config_file_path] | |
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 | config = _render_mod_dav_svn_config( | |
|
41 | settings[config_keys.parent_path_root], | |
|
42 | settings[config_keys.list_parent_path], | |
|
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 | 53 | repo_group_paths = [] |
|
43 |
for repo_group in |
|
|
54 | for repo_group in repo_groups: | |
|
44 | 55 | group_path = repo_group.full_path_splitted |
|
45 | 56 | location = os.path.join(location_root, *group_path) |
|
46 | 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 | 67 | # Render the configuration template to string. |
|
57 | 68 | template = 'rhodecode:svn_support/templates/mod-dav-svn.conf.mako' |
|
58 |
|
|
|
69 | return render(template, context) | |
|
70 | ||
|
59 | 71 | |
|
60 | # Write configuration to file. | |
|
61 | with open(filepath, 'w') as file_: | |
|
62 | file_.write(mod_dav_svn_config) | |
|
72 | def _write_mod_dav_svn_config(config, filepath): | |
|
73 | """ | |
|
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