##// END OF EJS Templates
tests: move test data to top level 'data' folder - make grepping in kallithea/ easier...
Mads Kiilerich -
r6001:9358211e default
parent child Browse files
Show More
@@ -1,31 +1,31 b''
1 syntax: glob
1 syntax: glob
2 *.pyc
2 *.pyc
3 *.swp
3 *.swp
4 *.sqlite
4 *.sqlite
5 *.tox
5 *.tox
6 *.egg-info
6 *.egg-info
7 *.egg
7 *.egg
8 *.mo
8 *.mo
9 .eggs/
9 .eggs/
10 tarballcache/
10 tarballcache/
11
11
12 syntax: regexp
12 syntax: regexp
13 ^rcextensions
13 ^rcextensions
14 ^build
14 ^build
15 ^dist/
15 ^dist/
16 ^docs/build/
16 ^docs/build/
17 ^docs/_build/
17 ^docs/_build/
18 ^data$
18 ^data$
19 ^kallithea/tests/data$
20 ^sql_dumps/
19 ^sql_dumps/
21 ^\.settings$
20 ^\.settings$
22 ^\.project$
21 ^\.project$
23 ^\.pydevproject$
22 ^\.pydevproject$
24 ^\.coverage$
23 ^\.coverage$
25 ^kallithea\.db$
24 ^kallithea\.db$
26 ^test\.db$
25 ^test\.db$
27 ^Kallithea\.egg-info$
26 ^Kallithea\.egg-info$
28 ^my\.ini$
27 ^my\.ini$
29 ^fabfile.py
28 ^fabfile.py
30 ^\.idea$
29 ^\.idea$
31 ^\.cache$
30 ^\.cache$
31 /__pycache__$
@@ -1,605 +1,610 b''
1 ################################################################################
1 ################################################################################
2 ################################################################################
2 ################################################################################
3 # Kallithea - config for tests: #
3 # Kallithea - config for tests: #
4 # initial_repo_scan = true #
4 # initial_repo_scan = true #
5 # sqlalchemy and kallithea_test.sqlite #
5 # sqlalchemy and kallithea_test.sqlite #
6 # custom logging #
6 # custom logging #
7 # #
7 # #
8 # The %(here)s variable will be replaced with the parent directory of this file#
8 # The %(here)s variable will be replaced with the parent directory of this file#
9 ################################################################################
9 ################################################################################
10 ################################################################################
10 ################################################################################
11
11
12 [DEFAULT]
12 [DEFAULT]
13 debug = true
13 debug = true
14 pdebug = false
14 pdebug = false
15
15
16 ################################################################################
16 ################################################################################
17 ## Email settings ##
17 ## Email settings ##
18 ## ##
18 ## ##
19 ## Refer to the documentation ("Email settings") for more details. ##
19 ## Refer to the documentation ("Email settings") for more details. ##
20 ## ##
20 ## ##
21 ## It is recommended to use a valid sender address that passes access ##
21 ## It is recommended to use a valid sender address that passes access ##
22 ## validation and spam filtering in mail servers. ##
22 ## validation and spam filtering in mail servers. ##
23 ################################################################################
23 ################################################################################
24
24
25 ## 'From' header for application emails. You can optionally add a name.
25 ## 'From' header for application emails. You can optionally add a name.
26 ## Default:
26 ## Default:
27 #app_email_from = Kallithea
27 #app_email_from = Kallithea
28 ## Examples:
28 ## Examples:
29 #app_email_from = Kallithea <kallithea-noreply@example.com>
29 #app_email_from = Kallithea <kallithea-noreply@example.com>
30 #app_email_from = kallithea-noreply@example.com
30 #app_email_from = kallithea-noreply@example.com
31
31
32 ## Subject prefix for application emails.
32 ## Subject prefix for application emails.
33 ## A space between this prefix and the real subject is automatically added.
33 ## A space between this prefix and the real subject is automatically added.
34 ## Default:
34 ## Default:
35 #email_prefix =
35 #email_prefix =
36 ## Example:
36 ## Example:
37 #email_prefix = [Kallithea]
37 #email_prefix = [Kallithea]
38
38
39 ## Recipients for error emails and fallback recipients of application mails.
39 ## Recipients for error emails and fallback recipients of application mails.
40 ## Multiple addresses can be specified, space-separated.
40 ## Multiple addresses can be specified, space-separated.
41 ## Only addresses are allowed, do not add any name part.
41 ## Only addresses are allowed, do not add any name part.
42 ## Default:
42 ## Default:
43 #email_to =
43 #email_to =
44 ## Examples:
44 ## Examples:
45 #email_to = admin@example.com
45 #email_to = admin@example.com
46 #email_to = admin@example.com another_admin@example.com
46 #email_to = admin@example.com another_admin@example.com
47
47
48 ## 'From' header for error emails. You can optionally add a name.
48 ## 'From' header for error emails. You can optionally add a name.
49 ## Default:
49 ## Default:
50 #error_email_from = pylons@yourapp.com
50 #error_email_from = pylons@yourapp.com
51 ## Examples:
51 ## Examples:
52 #error_email_from = Kallithea Errors <kallithea-noreply@example.com>
52 #error_email_from = Kallithea Errors <kallithea-noreply@example.com>
53 #error_email_from = paste_error@example.com
53 #error_email_from = paste_error@example.com
54
54
55 ## SMTP server settings
55 ## SMTP server settings
56 ## If specifying credentials, make sure to use secure connections.
56 ## If specifying credentials, make sure to use secure connections.
57 ## Default: Send unencrypted unauthenticated mails to the specified smtp_server.
57 ## Default: Send unencrypted unauthenticated mails to the specified smtp_server.
58 ## For "SSL", use smtp_use_ssl = true and smtp_port = 465.
58 ## For "SSL", use smtp_use_ssl = true and smtp_port = 465.
59 ## For "STARTTLS", use smtp_use_tls = true and smtp_port = 587.
59 ## For "STARTTLS", use smtp_use_tls = true and smtp_port = 587.
60 #smtp_server = smtp.example.com
60 #smtp_server = smtp.example.com
61 #smtp_username =
61 #smtp_username =
62 #smtp_password =
62 #smtp_password =
63 #smtp_port = 25
63 #smtp_port = 25
64 #smtp_use_ssl = false
64 #smtp_use_ssl = false
65 #smtp_use_tls = false
65 #smtp_use_tls = false
66
66
67 [server:main]
67 [server:main]
68 ## PASTE ##
68 ## PASTE ##
69 #use = egg:Paste#http
69 #use = egg:Paste#http
70 ## nr of worker threads to spawn
70 ## nr of worker threads to spawn
71 #threadpool_workers = 5
71 #threadpool_workers = 5
72 ## max request before thread respawn
72 ## max request before thread respawn
73 #threadpool_max_requests = 10
73 #threadpool_max_requests = 10
74 ## option to use threads of process
74 ## option to use threads of process
75 #use_threadpool = true
75 #use_threadpool = true
76
76
77 ## WAITRESS ##
77 ## WAITRESS ##
78 use = egg:waitress#main
78 use = egg:waitress#main
79 ## number of worker threads
79 ## number of worker threads
80 threads = 5
80 threads = 5
81 ## MAX BODY SIZE 100GB
81 ## MAX BODY SIZE 100GB
82 max_request_body_size = 107374182400
82 max_request_body_size = 107374182400
83 ## use poll instead of select, fixes fd limits, may not work on old
83 ## use poll instead of select, fixes fd limits, may not work on old
84 ## windows systems.
84 ## windows systems.
85 #asyncore_use_poll = True
85 #asyncore_use_poll = True
86
86
87 ## GUNICORN ##
87 ## GUNICORN ##
88 #use = egg:gunicorn#main
88 #use = egg:gunicorn#main
89 ## number of process workers. You must set `instance_id = *` when this option
89 ## number of process workers. You must set `instance_id = *` when this option
90 ## is set to more than one worker
90 ## is set to more than one worker
91 #workers = 1
91 #workers = 1
92 ## process name
92 ## process name
93 #proc_name = kallithea
93 #proc_name = kallithea
94 ## type of worker class, one of sync, eventlet, gevent, tornado
94 ## type of worker class, one of sync, eventlet, gevent, tornado
95 ## recommended for bigger setup is using of of other than sync one
95 ## recommended for bigger setup is using of of other than sync one
96 #worker_class = sync
96 #worker_class = sync
97 #max_requests = 1000
97 #max_requests = 1000
98 ## amount of time a worker can handle request before it gets killed and
98 ## amount of time a worker can handle request before it gets killed and
99 ## restarted
99 ## restarted
100 #timeout = 3600
100 #timeout = 3600
101
101
102 ## UWSGI ##
102 ## UWSGI ##
103 ## run with uwsgi --ini-paste-logged <inifile.ini>
103 ## run with uwsgi --ini-paste-logged <inifile.ini>
104 #[uwsgi]
104 #[uwsgi]
105 #socket = /tmp/uwsgi.sock
105 #socket = /tmp/uwsgi.sock
106 #master = true
106 #master = true
107 #http = 127.0.0.1:5000
107 #http = 127.0.0.1:5000
108
108
109 ## set as deamon and redirect all output to file
109 ## set as deamon and redirect all output to file
110 #daemonize = ./uwsgi_kallithea.log
110 #daemonize = ./uwsgi_kallithea.log
111
111
112 ## master process PID
112 ## master process PID
113 #pidfile = ./uwsgi_kallithea.pid
113 #pidfile = ./uwsgi_kallithea.pid
114
114
115 ## stats server with workers statistics, use uwsgitop
115 ## stats server with workers statistics, use uwsgitop
116 ## for monitoring, `uwsgitop 127.0.0.1:1717`
116 ## for monitoring, `uwsgitop 127.0.0.1:1717`
117 #stats = 127.0.0.1:1717
117 #stats = 127.0.0.1:1717
118 #memory-report = true
118 #memory-report = true
119
119
120 ## log 5XX errors
120 ## log 5XX errors
121 #log-5xx = true
121 #log-5xx = true
122
122
123 ## Set the socket listen queue size.
123 ## Set the socket listen queue size.
124 #listen = 256
124 #listen = 256
125
125
126 ## Gracefully Reload workers after the specified amount of managed requests
126 ## Gracefully Reload workers after the specified amount of managed requests
127 ## (avoid memory leaks).
127 ## (avoid memory leaks).
128 #max-requests = 1000
128 #max-requests = 1000
129
129
130 ## enable large buffers
130 ## enable large buffers
131 #buffer-size = 65535
131 #buffer-size = 65535
132
132
133 ## socket and http timeouts ##
133 ## socket and http timeouts ##
134 #http-timeout = 3600
134 #http-timeout = 3600
135 #socket-timeout = 3600
135 #socket-timeout = 3600
136
136
137 ## Log requests slower than the specified number of milliseconds.
137 ## Log requests slower than the specified number of milliseconds.
138 #log-slow = 10
138 #log-slow = 10
139
139
140 ## Exit if no app can be loaded.
140 ## Exit if no app can be loaded.
141 #need-app = true
141 #need-app = true
142
142
143 ## Set lazy mode (load apps in workers instead of master).
143 ## Set lazy mode (load apps in workers instead of master).
144 #lazy = true
144 #lazy = true
145
145
146 ## scaling ##
146 ## scaling ##
147 ## set cheaper algorithm to use, if not set default will be used
147 ## set cheaper algorithm to use, if not set default will be used
148 #cheaper-algo = spare
148 #cheaper-algo = spare
149
149
150 ## minimum number of workers to keep at all times
150 ## minimum number of workers to keep at all times
151 #cheaper = 1
151 #cheaper = 1
152
152
153 ## number of workers to spawn at startup
153 ## number of workers to spawn at startup
154 #cheaper-initial = 1
154 #cheaper-initial = 1
155
155
156 ## maximum number of workers that can be spawned
156 ## maximum number of workers that can be spawned
157 #workers = 4
157 #workers = 4
158
158
159 ## how many workers should be spawned at a time
159 ## how many workers should be spawned at a time
160 #cheaper-step = 1
160 #cheaper-step = 1
161
161
162 ## COMMON ##
162 ## COMMON ##
163 host = 127.0.0.1
163 host = 127.0.0.1
164 #port = 5000
164 #port = 5000
165 port = 4999
165 port = 4999
166
166
167 ## middleware for hosting the WSGI application under a URL prefix
167 ## middleware for hosting the WSGI application under a URL prefix
168 #[filter:proxy-prefix]
168 #[filter:proxy-prefix]
169 #use = egg:PasteDeploy#prefix
169 #use = egg:PasteDeploy#prefix
170 #prefix = /<your-prefix>
170 #prefix = /<your-prefix>
171
171
172 [app:main]
172 [app:main]
173 use = egg:kallithea
173 use = egg:kallithea
174 ## enable proxy prefix middleware
174 ## enable proxy prefix middleware
175 #filter-with = proxy-prefix
175 #filter-with = proxy-prefix
176
176
177 full_stack = true
177 full_stack = true
178 static_files = true
178 static_files = true
179 ## Available Languages:
179 ## Available Languages:
180 ## cs de fr hu ja nl_BE pl pt_BR ru sk zh_CN zh_TW
180 ## cs de fr hu ja nl_BE pl pt_BR ru sk zh_CN zh_TW
181 lang =
181 lang =
182 cache_dir = %(here)s/data
182 #cache_dir = %(here)s/data
183 index_dir = %(here)s/data/index
183 cache_dir = %(here)s/../../data/test/cache
184 #index_dir = %(here)s/data/index
185 index_dir = %(here)s/../../data/test/index
184
186
185 ## perform a full repository scan on each server start, this should be
187 ## perform a full repository scan on each server start, this should be
186 ## set to false after first startup, to allow faster server restarts.
188 ## set to false after first startup, to allow faster server restarts.
187 #initial_repo_scan = false
189 #initial_repo_scan = false
188 initial_repo_scan = true
190 initial_repo_scan = true
189
191
190 ## uncomment and set this path to use archive download cache
192 ## uncomment and set this path to use archive download cache
191 archive_cache_dir = %(here)s/tarballcache
193 #archive_cache_dir = %(here)s/tarballcache
194 archive_cache_dir = %(here)s/../../data/test/tarballcache
192
195
193 ## change this to unique ID for security
196 ## change this to unique ID for security
194 app_instance_uuid = test
197 app_instance_uuid = test
195
198
196 ## cut off limit for large diffs (size in bytes)
199 ## cut off limit for large diffs (size in bytes)
197 cut_off_limit = 256000
200 cut_off_limit = 256000
198
201
199 ## force https in Kallithea, fixes https redirects, assumes it's always https
202 ## force https in Kallithea, fixes https redirects, assumes it's always https
200 force_https = false
203 force_https = false
201
204
202 ## use Strict-Transport-Security headers
205 ## use Strict-Transport-Security headers
203 use_htsts = false
206 use_htsts = false
204
207
205 ## number of commits stats will parse on each iteration
208 ## number of commits stats will parse on each iteration
206 commit_parse_limit = 25
209 commit_parse_limit = 25
207
210
208 ## path to git executable
211 ## path to git executable
209 git_path = git
212 git_path = git
210
213
211 ## git rev filter option, --all is the default filter, if you need to
214 ## git rev filter option, --all is the default filter, if you need to
212 ## hide all refs in changelog switch this to --branches --tags
215 ## hide all refs in changelog switch this to --branches --tags
213 #git_rev_filter = --branches --tags
216 #git_rev_filter = --branches --tags
214
217
215 ## RSS feed options
218 ## RSS feed options
216 rss_cut_off_limit = 256000
219 rss_cut_off_limit = 256000
217 rss_items_per_page = 10
220 rss_items_per_page = 10
218 rss_include_diff = false
221 rss_include_diff = false
219
222
220 ## options for showing and identifying changesets
223 ## options for showing and identifying changesets
221 show_sha_length = 12
224 show_sha_length = 12
222 #show_revision_number = false
225 #show_revision_number = false
223 show_revision_number = true
226 show_revision_number = true
224
227
225 ## Canonical URL to use when creating full URLs in UI and texts.
228 ## Canonical URL to use when creating full URLs in UI and texts.
226 ## Useful when the site is available under different names or protocols.
229 ## Useful when the site is available under different names or protocols.
227 ## Defaults to what is provided in the WSGI environment.
230 ## Defaults to what is provided in the WSGI environment.
228 #canonical_url = https://kallithea.example.com/repos
231 #canonical_url = https://kallithea.example.com/repos
229
232
230 ## gist URL alias, used to create nicer urls for gist. This should be an
233 ## gist URL alias, used to create nicer urls for gist. This should be an
231 ## url that does rewrites to _admin/gists/<gistid>.
234 ## url that does rewrites to _admin/gists/<gistid>.
232 ## example: http://gist.example.com/{gistid}. Empty means use the internal
235 ## example: http://gist.example.com/{gistid}. Empty means use the internal
233 ## Kallithea url, ie. http[s]://kallithea.example.com/_admin/gists/<gistid>
236 ## Kallithea url, ie. http[s]://kallithea.example.com/_admin/gists/<gistid>
234 gist_alias_url =
237 gist_alias_url =
235
238
236 ## white list of API enabled controllers. This allows to add list of
239 ## white list of API enabled controllers. This allows to add list of
237 ## controllers to which access will be enabled by api_key. eg: to enable
240 ## controllers to which access will be enabled by api_key. eg: to enable
238 ## api access to raw_files put `FilesController:raw`, to enable access to patches
241 ## api access to raw_files put `FilesController:raw`, to enable access to patches
239 ## add `ChangesetController:changeset_patch`. This list should be "," separated
242 ## add `ChangesetController:changeset_patch`. This list should be "," separated
240 ## Syntax is <ControllerClass>:<function>. Check debug logs for generated names
243 ## Syntax is <ControllerClass>:<function>. Check debug logs for generated names
241 ## Recommended settings below are commented out:
244 ## Recommended settings below are commented out:
242 api_access_controllers_whitelist =
245 api_access_controllers_whitelist =
243 # ChangesetController:changeset_patch,
246 # ChangesetController:changeset_patch,
244 # ChangesetController:changeset_raw,
247 # ChangesetController:changeset_raw,
245 # FilesController:raw,
248 # FilesController:raw,
246 # FilesController:archivefile
249 # FilesController:archivefile
247
250
248 ## default encoding used to convert from and to unicode
251 ## default encoding used to convert from and to unicode
249 ## can be also a comma separated list of encoding in case of mixed encodings
252 ## can be also a comma separated list of encoding in case of mixed encodings
250 default_encoding = utf8
253 default_encoding = utf8
251
254
252 ## issue tracker for Kallithea (leave blank to disable, absent for default)
255 ## issue tracker for Kallithea (leave blank to disable, absent for default)
253 #bugtracker = https://bitbucket.org/conservancy/kallithea/issues
256 #bugtracker = https://bitbucket.org/conservancy/kallithea/issues
254
257
255 ## issue tracking mapping for commits messages
258 ## issue tracking mapping for commits messages
256 ## comment out issue_pat, issue_server, issue_prefix to enable
259 ## comment out issue_pat, issue_server, issue_prefix to enable
257
260
258 ## pattern to get the issues from commit messages
261 ## pattern to get the issues from commit messages
259 ## default one used here is #<numbers> with a regex passive group for `#`
262 ## default one used here is #<numbers> with a regex passive group for `#`
260 ## {id} will be all groups matched from this pattern
263 ## {id} will be all groups matched from this pattern
261
264
262 issue_pat = (?:\s*#)(\d+)
265 issue_pat = (?:\s*#)(\d+)
263
266
264 ## server url to the issue, each {id} will be replaced with match
267 ## server url to the issue, each {id} will be replaced with match
265 ## fetched from the regex and {repo} is replaced with full repository name
268 ## fetched from the regex and {repo} is replaced with full repository name
266 ## including groups {repo_name} is replaced with just name of repo
269 ## including groups {repo_name} is replaced with just name of repo
267
270
268 issue_server_link = https://issues.example.com/{repo}/issue/{id}
271 issue_server_link = https://issues.example.com/{repo}/issue/{id}
269
272
270 ## prefix to add to link to indicate it's an url
273 ## prefix to add to link to indicate it's an url
271 ## #314 will be replaced by <issue_prefix><id>
274 ## #314 will be replaced by <issue_prefix><id>
272
275
273 issue_prefix = #
276 issue_prefix = #
274
277
275 ## issue_pat, issue_server_link, issue_prefix can have suffixes to specify
278 ## issue_pat, issue_server_link, issue_prefix can have suffixes to specify
276 ## multiple patterns, to other issues server, wiki or others
279 ## multiple patterns, to other issues server, wiki or others
277 ## below an example how to create a wiki pattern
280 ## below an example how to create a wiki pattern
278 # wiki-some-id -> https://wiki.example.com/some-id
281 # wiki-some-id -> https://wiki.example.com/some-id
279
282
280 #issue_pat_wiki = (?:wiki-)(.+)
283 #issue_pat_wiki = (?:wiki-)(.+)
281 #issue_server_link_wiki = https://wiki.example.com/{id}
284 #issue_server_link_wiki = https://wiki.example.com/{id}
282 #issue_prefix_wiki = WIKI-
285 #issue_prefix_wiki = WIKI-
283
286
284 ## alternative return HTTP header for failed authentication. Default HTTP
287 ## alternative return HTTP header for failed authentication. Default HTTP
285 ## response is 401 HTTPUnauthorized. Currently Mercurial clients have trouble with
288 ## response is 401 HTTPUnauthorized. Currently Mercurial clients have trouble with
286 ## handling that. Set this variable to 403 to return HTTPForbidden
289 ## handling that. Set this variable to 403 to return HTTPForbidden
287 auth_ret_code =
290 auth_ret_code =
288
291
289 ## locking return code. When repository is locked return this HTTP code. 2XX
292 ## locking return code. When repository is locked return this HTTP code. 2XX
290 ## codes don't break the transactions while 4XX codes do
293 ## codes don't break the transactions while 4XX codes do
291 lock_ret_code = 423
294 lock_ret_code = 423
292
295
293 ## allows to change the repository location in settings page
296 ## allows to change the repository location in settings page
294 allow_repo_location_change = True
297 allow_repo_location_change = True
295
298
296 ## allows to setup custom hooks in settings page
299 ## allows to setup custom hooks in settings page
297 allow_custom_hooks_settings = True
300 allow_custom_hooks_settings = True
298
301
299 ## extra extensions for indexing, space separated and without the leading '.'.
302 ## extra extensions for indexing, space separated and without the leading '.'.
300 # index.extensions =
303 # index.extensions =
301 # gemfile
304 # gemfile
302 # lock
305 # lock
303
306
304 ## extra filenames for indexing, space separated
307 ## extra filenames for indexing, space separated
305 # index.filenames =
308 # index.filenames =
306 # .dockerignore
309 # .dockerignore
307 # .editorconfig
310 # .editorconfig
308 # INSTALL
311 # INSTALL
309 # CHANGELOG
312 # CHANGELOG
310
313
311 ####################################
314 ####################################
312 ### CELERY CONFIG ####
315 ### CELERY CONFIG ####
313 ####################################
316 ####################################
314
317
315 use_celery = false
318 use_celery = false
316 broker.host = localhost
319 broker.host = localhost
317 broker.vhost = rabbitmqhost
320 broker.vhost = rabbitmqhost
318 broker.port = 5672
321 broker.port = 5672
319 broker.user = rabbitmq
322 broker.user = rabbitmq
320 broker.password = qweqwe
323 broker.password = qweqwe
321
324
322 celery.imports = kallithea.lib.celerylib.tasks
325 celery.imports = kallithea.lib.celerylib.tasks
323
326
324 celery.result.backend = amqp
327 celery.result.backend = amqp
325 celery.result.dburi = amqp://
328 celery.result.dburi = amqp://
326 celery.result.serialier = json
329 celery.result.serialier = json
327
330
328 #celery.send.task.error.emails = true
331 #celery.send.task.error.emails = true
329 #celery.amqp.task.result.expires = 18000
332 #celery.amqp.task.result.expires = 18000
330
333
331 celeryd.concurrency = 2
334 celeryd.concurrency = 2
332 #celeryd.log.file = celeryd.log
335 #celeryd.log.file = celeryd.log
333 celeryd.log.level = DEBUG
336 celeryd.log.level = DEBUG
334 celeryd.max.tasks.per.child = 1
337 celeryd.max.tasks.per.child = 1
335
338
336 ## tasks will never be sent to the queue, but executed locally instead.
339 ## tasks will never be sent to the queue, but executed locally instead.
337 celery.always.eager = false
340 celery.always.eager = false
338
341
339 ####################################
342 ####################################
340 ### BEAKER CACHE ####
343 ### BEAKER CACHE ####
341 ####################################
344 ####################################
342
345
343 beaker.cache.data_dir = %(here)s/data/cache/data
346 #beaker.cache.data_dir = %(here)s/data/cache/data
344 beaker.cache.lock_dir = %(here)s/data/cache/lock
347 beaker.cache.data_dir = %(here)s/../../data/test/cache/data
348 #beaker.cache.lock_dir = %(here)s/data/cache/lock
349 beaker.cache.lock_dir = %(here)s/../../data/test/cache/lock
345
350
346 beaker.cache.regions = short_term,long_term,sql_cache_short
351 beaker.cache.regions = short_term,long_term,sql_cache_short
347
352
348 beaker.cache.short_term.type = memory
353 beaker.cache.short_term.type = memory
349 beaker.cache.short_term.expire = 60
354 beaker.cache.short_term.expire = 60
350 beaker.cache.short_term.key_length = 256
355 beaker.cache.short_term.key_length = 256
351
356
352 beaker.cache.long_term.type = memory
357 beaker.cache.long_term.type = memory
353 beaker.cache.long_term.expire = 36000
358 beaker.cache.long_term.expire = 36000
354 beaker.cache.long_term.key_length = 256
359 beaker.cache.long_term.key_length = 256
355
360
356 beaker.cache.sql_cache_short.type = memory
361 beaker.cache.sql_cache_short.type = memory
357 #beaker.cache.sql_cache_short.expire = 10
362 #beaker.cache.sql_cache_short.expire = 10
358 beaker.cache.sql_cache_short.expire = 1
363 beaker.cache.sql_cache_short.expire = 1
359 beaker.cache.sql_cache_short.key_length = 256
364 beaker.cache.sql_cache_short.key_length = 256
360
365
361 ####################################
366 ####################################
362 ### BEAKER SESSION ####
367 ### BEAKER SESSION ####
363 ####################################
368 ####################################
364
369
365 ## Name of session cookie. Should be unique for a given host and path, even when running
370 ## Name of session cookie. Should be unique for a given host and path, even when running
366 ## on different ports. Otherwise, cookie sessions will be shared and messed up.
371 ## on different ports. Otherwise, cookie sessions will be shared and messed up.
367 beaker.session.key = kallithea
372 beaker.session.key = kallithea
368 ## Sessions should always only be accessible by the browser, not directly by JavaScript.
373 ## Sessions should always only be accessible by the browser, not directly by JavaScript.
369 beaker.session.httponly = true
374 beaker.session.httponly = true
370 ## Session lifetime. 2592000 seconds is 30 days.
375 ## Session lifetime. 2592000 seconds is 30 days.
371 beaker.session.timeout = 2592000
376 beaker.session.timeout = 2592000
372
377
373 ## Server secret used with HMAC to ensure integrity of cookies.
378 ## Server secret used with HMAC to ensure integrity of cookies.
374 beaker.session.secret = {74e0cd75-b339-478b-b129-07dd221def1f}
379 beaker.session.secret = {74e0cd75-b339-478b-b129-07dd221def1f}
375 ## Further, encrypt the data with AES.
380 ## Further, encrypt the data with AES.
376 #beaker.session.encrypt_key = <key_for_encryption>
381 #beaker.session.encrypt_key = <key_for_encryption>
377 #beaker.session.validate_key = <validation_key>
382 #beaker.session.validate_key = <validation_key>
378
383
379 ## Type of storage used for the session, current types are
384 ## Type of storage used for the session, current types are
380 ## dbm, file, memcached, database, and memory.
385 ## dbm, file, memcached, database, and memory.
381
386
382 ## File system storage of session data. (default)
387 ## File system storage of session data. (default)
383 #beaker.session.type = file
388 #beaker.session.type = file
384
389
385 ## Cookie only, store all session data inside the cookie. Requires secure secrets.
390 ## Cookie only, store all session data inside the cookie. Requires secure secrets.
386 #beaker.session.type = cookie
391 #beaker.session.type = cookie
387
392
388 ## Database storage of session data.
393 ## Database storage of session data.
389 #beaker.session.type = ext:database
394 #beaker.session.type = ext:database
390 #beaker.session.sa.url = postgresql://postgres:qwe@localhost/kallithea
395 #beaker.session.sa.url = postgresql://postgres:qwe@localhost/kallithea
391 #beaker.session.table_name = db_session
396 #beaker.session.table_name = db_session
392
397
393 ############################
398 ############################
394 ## ERROR HANDLING SYSTEMS ##
399 ## ERROR HANDLING SYSTEMS ##
395 ############################
400 ############################
396
401
397 ####################
402 ####################
398 ### [errormator] ###
403 ### [errormator] ###
399 ####################
404 ####################
400
405
401 ## Errormator is tailored to work with Kallithea, see
406 ## Errormator is tailored to work with Kallithea, see
402 ## http://errormator.com for details how to obtain an account
407 ## http://errormator.com for details how to obtain an account
403 ## you must install python package `errormator_client` to make it work
408 ## you must install python package `errormator_client` to make it work
404
409
405 ## errormator enabled
410 ## errormator enabled
406 errormator = false
411 errormator = false
407
412
408 errormator.server_url = https://api.errormator.com
413 errormator.server_url = https://api.errormator.com
409 errormator.api_key = YOUR_API_KEY
414 errormator.api_key = YOUR_API_KEY
410
415
411 ## TWEAK AMOUNT OF INFO SENT HERE
416 ## TWEAK AMOUNT OF INFO SENT HERE
412
417
413 ## enables 404 error logging (default False)
418 ## enables 404 error logging (default False)
414 errormator.report_404 = false
419 errormator.report_404 = false
415
420
416 ## time in seconds after request is considered being slow (default 1)
421 ## time in seconds after request is considered being slow (default 1)
417 errormator.slow_request_time = 1
422 errormator.slow_request_time = 1
418
423
419 ## record slow requests in application
424 ## record slow requests in application
420 ## (needs to be enabled for slow datastore recording and time tracking)
425 ## (needs to be enabled for slow datastore recording and time tracking)
421 errormator.slow_requests = true
426 errormator.slow_requests = true
422
427
423 ## enable hooking to application loggers
428 ## enable hooking to application loggers
424 #errormator.logging = true
429 #errormator.logging = true
425
430
426 ## minimum log level for log capture
431 ## minimum log level for log capture
427 #errormator.logging.level = WARNING
432 #errormator.logging.level = WARNING
428
433
429 ## send logs only from erroneous/slow requests
434 ## send logs only from erroneous/slow requests
430 ## (saves API quota for intensive logging)
435 ## (saves API quota for intensive logging)
431 errormator.logging_on_error = false
436 errormator.logging_on_error = false
432
437
433 ## list of additional keywords that should be grabbed from environ object
438 ## list of additional keywords that should be grabbed from environ object
434 ## can be string with comma separated list of words in lowercase
439 ## can be string with comma separated list of words in lowercase
435 ## (by default client will always send following info:
440 ## (by default client will always send following info:
436 ## 'REMOTE_USER', 'REMOTE_ADDR', 'SERVER_NAME', 'CONTENT_TYPE' + all keys that
441 ## 'REMOTE_USER', 'REMOTE_ADDR', 'SERVER_NAME', 'CONTENT_TYPE' + all keys that
437 ## start with HTTP* this list be extended with additional keywords here
442 ## start with HTTP* this list be extended with additional keywords here
438 errormator.environ_keys_whitelist =
443 errormator.environ_keys_whitelist =
439
444
440 ## list of keywords that should be blanked from request object
445 ## list of keywords that should be blanked from request object
441 ## can be string with comma separated list of words in lowercase
446 ## can be string with comma separated list of words in lowercase
442 ## (by default client will always blank keys that contain following words
447 ## (by default client will always blank keys that contain following words
443 ## 'password', 'passwd', 'pwd', 'auth_tkt', 'secret', 'csrf'
448 ## 'password', 'passwd', 'pwd', 'auth_tkt', 'secret', 'csrf'
444 ## this list be extended with additional keywords set here
449 ## this list be extended with additional keywords set here
445 errormator.request_keys_blacklist =
450 errormator.request_keys_blacklist =
446
451
447 ## list of namespaces that should be ignores when gathering log entries
452 ## list of namespaces that should be ignores when gathering log entries
448 ## can be string with comma separated list of namespaces
453 ## can be string with comma separated list of namespaces
449 ## (by default the client ignores own entries: errormator_client.client)
454 ## (by default the client ignores own entries: errormator_client.client)
450 errormator.log_namespace_blacklist =
455 errormator.log_namespace_blacklist =
451
456
452 ################
457 ################
453 ### [sentry] ###
458 ### [sentry] ###
454 ################
459 ################
455
460
456 ## sentry is a alternative open source error aggregator
461 ## sentry is a alternative open source error aggregator
457 ## you must install python packages `sentry` and `raven` to enable
462 ## you must install python packages `sentry` and `raven` to enable
458
463
459 sentry.dsn = YOUR_DNS
464 sentry.dsn = YOUR_DNS
460 sentry.servers =
465 sentry.servers =
461 sentry.name =
466 sentry.name =
462 sentry.key =
467 sentry.key =
463 sentry.public_key =
468 sentry.public_key =
464 sentry.secret_key =
469 sentry.secret_key =
465 sentry.project =
470 sentry.project =
466 sentry.site =
471 sentry.site =
467 sentry.include_paths =
472 sentry.include_paths =
468 sentry.exclude_paths =
473 sentry.exclude_paths =
469
474
470 ################################################################################
475 ################################################################################
471 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
476 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
472 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
477 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
473 ## execute malicious code after an exception is raised. ##
478 ## execute malicious code after an exception is raised. ##
474 ################################################################################
479 ################################################################################
475 set debug = false
480 set debug = false
476
481
477 ##################################
482 ##################################
478 ### LOGVIEW CONFIG ###
483 ### LOGVIEW CONFIG ###
479 ##################################
484 ##################################
480
485
481 logview.sqlalchemy = #faa
486 logview.sqlalchemy = #faa
482 logview.pylons.templating = #bfb
487 logview.pylons.templating = #bfb
483 logview.pylons.util = #eee
488 logview.pylons.util = #eee
484
489
485 #########################################################
490 #########################################################
486 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
491 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
487 #########################################################
492 #########################################################
488
493
489 # SQLITE [default]
494 # SQLITE [default]
490 #sqlalchemy.db1.url = sqlite:///%(here)s/kallithea.db?timeout=60
495 #sqlalchemy.db1.url = sqlite:///%(here)s/kallithea.db?timeout=60
491 sqlalchemy.db1.url = sqlite:///%(here)s/kallithea_test.sqlite
496 sqlalchemy.db1.url = sqlite:///%(here)s/kallithea_test.sqlite
492
497
493 # POSTGRESQL
498 # POSTGRESQL
494 #sqlalchemy.db1.url = postgresql://user:pass@localhost/kallithea
499 #sqlalchemy.db1.url = postgresql://user:pass@localhost/kallithea
495
500
496 # MySQL
501 # MySQL
497 #sqlalchemy.db1.url = mysql://user:pass@localhost/kallithea?charset=utf8
502 #sqlalchemy.db1.url = mysql://user:pass@localhost/kallithea?charset=utf8
498
503
499 # see sqlalchemy docs for others
504 # see sqlalchemy docs for others
500
505
501 sqlalchemy.db1.echo = false
506 sqlalchemy.db1.echo = false
502 sqlalchemy.db1.pool_recycle = 3600
507 sqlalchemy.db1.pool_recycle = 3600
503
508
504 ################################
509 ################################
505 ### ALEMBIC CONFIGURATION ####
510 ### ALEMBIC CONFIGURATION ####
506 ################################
511 ################################
507
512
508 [alembic]
513 [alembic]
509 script_location = kallithea:alembic
514 script_location = kallithea:alembic
510
515
511 ################################
516 ################################
512 ### LOGGING CONFIGURATION ####
517 ### LOGGING CONFIGURATION ####
513 ################################
518 ################################
514
519
515 [loggers]
520 [loggers]
516 keys = root, routes, kallithea, sqlalchemy, beaker, templates, whoosh_indexer
521 keys = root, routes, kallithea, sqlalchemy, beaker, templates, whoosh_indexer
517
522
518 [handlers]
523 [handlers]
519 keys = console, console_sql
524 keys = console, console_sql
520
525
521 [formatters]
526 [formatters]
522 keys = generic, color_formatter, color_formatter_sql
527 keys = generic, color_formatter, color_formatter_sql
523
528
524 #############
529 #############
525 ## LOGGERS ##
530 ## LOGGERS ##
526 #############
531 #############
527
532
528 [logger_root]
533 [logger_root]
529 #level = NOTSET
534 #level = NOTSET
530 level = DEBUG
535 level = DEBUG
531 handlers = console
536 handlers = console
532
537
533 [logger_routes]
538 [logger_routes]
534 level = DEBUG
539 level = DEBUG
535 handlers =
540 handlers =
536 qualname = routes.middleware
541 qualname = routes.middleware
537 ## "level = DEBUG" logs the route matched and routing variables.
542 ## "level = DEBUG" logs the route matched and routing variables.
538 propagate = 1
543 propagate = 1
539
544
540 [logger_beaker]
545 [logger_beaker]
541 level = DEBUG
546 level = DEBUG
542 handlers =
547 handlers =
543 qualname = beaker.container
548 qualname = beaker.container
544 propagate = 1
549 propagate = 1
545
550
546 [logger_templates]
551 [logger_templates]
547 level = INFO
552 level = INFO
548 handlers =
553 handlers =
549 qualname = pylons.templating
554 qualname = pylons.templating
550 propagate = 1
555 propagate = 1
551
556
552 [logger_kallithea]
557 [logger_kallithea]
553 level = DEBUG
558 level = DEBUG
554 handlers =
559 handlers =
555 qualname = kallithea
560 qualname = kallithea
556 propagate = 1
561 propagate = 1
557
562
558 [logger_sqlalchemy]
563 [logger_sqlalchemy]
559 #level = INFO
564 #level = INFO
560 level = ERROR
565 level = ERROR
561 #handlers = console_sql
566 #handlers = console_sql
562 handlers = console
567 handlers = console
563 qualname = sqlalchemy.engine
568 qualname = sqlalchemy.engine
564 propagate = 0
569 propagate = 0
565
570
566 [logger_whoosh_indexer]
571 [logger_whoosh_indexer]
567 level = DEBUG
572 level = DEBUG
568 handlers =
573 handlers =
569 qualname = whoosh_indexer
574 qualname = whoosh_indexer
570 propagate = 1
575 propagate = 1
571
576
572 ##############
577 ##############
573 ## HANDLERS ##
578 ## HANDLERS ##
574 ##############
579 ##############
575
580
576 [handler_console]
581 [handler_console]
577 class = StreamHandler
582 class = StreamHandler
578 args = (sys.stderr,)
583 args = (sys.stderr,)
579 #level = INFO
584 #level = INFO
580 level = NOTSET
585 level = NOTSET
581 formatter = generic
586 formatter = generic
582
587
583 [handler_console_sql]
588 [handler_console_sql]
584 class = StreamHandler
589 class = StreamHandler
585 args = (sys.stderr,)
590 args = (sys.stderr,)
586 level = WARN
591 level = WARN
587 formatter = generic
592 formatter = generic
588
593
589 ################
594 ################
590 ## FORMATTERS ##
595 ## FORMATTERS ##
591 ################
596 ################
592
597
593 [formatter_generic]
598 [formatter_generic]
594 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
599 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
595 datefmt = %Y-%m-%d %H:%M:%S
600 datefmt = %Y-%m-%d %H:%M:%S
596
601
597 [formatter_color_formatter]
602 [formatter_color_formatter]
598 class = kallithea.lib.colored_formatter.ColorFormatter
603 class = kallithea.lib.colored_formatter.ColorFormatter
599 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
604 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
600 datefmt = %Y-%m-%d %H:%M:%S
605 datefmt = %Y-%m-%d %H:%M:%S
601
606
602 [formatter_color_formatter_sql]
607 [formatter_color_formatter_sql]
603 class = kallithea.lib.colored_formatter.ColorFormatterSql
608 class = kallithea.lib.colored_formatter.ColorFormatterSql
604 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
609 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
605 datefmt = %Y-%m-%d %H:%M:%S
610 datefmt = %Y-%m-%d %H:%M:%S
@@ -1,171 +1,176 b''
1 #!/usr/bin/env python2
1 #!/usr/bin/env python2
2 """
2 """
3 Based on kallithea/bin/template.ini.mako, generate
3 Based on kallithea/bin/template.ini.mako, generate
4 kallithea/config/deployment.ini_tmpl
4 kallithea/config/deployment.ini_tmpl
5 development.ini
5 development.ini
6 kallithea/tests/test.ini
6 kallithea/tests/test.ini
7 """
7 """
8
8
9 import re
9 import re
10
10
11 makofile = 'kallithea/bin/template.ini.mako'
11 makofile = 'kallithea/bin/template.ini.mako'
12
12
13 # the mako conditionals used in all other ini files and templates
13 # the mako conditionals used in all other ini files and templates
14 selected_mako_conditionals = set([
14 selected_mako_conditionals = set([
15 "database_engine == 'sqlite'",
15 "database_engine == 'sqlite'",
16 "http_server == 'waitress'",
16 "http_server == 'waitress'",
17 "error_aggregation_service == 'errormator'",
17 "error_aggregation_service == 'errormator'",
18 "error_aggregation_service == 'sentry'",
18 "error_aggregation_service == 'sentry'",
19 ])
19 ])
20
20
21 # the mako variables used in all other ini files and templates
21 # the mako variables used in all other ini files and templates
22 mako_variable_values = {
22 mako_variable_values = {
23 'host': '127.0.0.1',
23 'host': '127.0.0.1',
24 'port': '5000',
24 'port': '5000',
25 'here': '%(here)s',
25 'here': '%(here)s',
26 'uuid()': '${app_instance_uuid}',
26 'uuid()': '${app_instance_uuid}',
27 }
27 }
28
28
29 # files to be generated from the mako template
29 # files to be generated from the mako template
30 ini_files = [
30 ini_files = [
31 ('kallithea/config/deployment.ini_tmpl',
31 ('kallithea/config/deployment.ini_tmpl',
32 '''
32 '''
33 Kallithea - Example config
33 Kallithea - Example config
34
34
35 The %(here)s variable will be replaced with the parent directory of this file
35 The %(here)s variable will be replaced with the parent directory of this file
36 ''',
36 ''',
37 {}, # exactly the same settings as template.ini.mako
37 {}, # exactly the same settings as template.ini.mako
38 ),
38 ),
39 ('kallithea/tests/test.ini',
39 ('kallithea/tests/test.ini',
40 '''
40 '''
41 Kallithea - config for tests:
41 Kallithea - config for tests:
42 initial_repo_scan = true
42 initial_repo_scan = true
43 sqlalchemy and kallithea_test.sqlite
43 sqlalchemy and kallithea_test.sqlite
44 custom logging
44 custom logging
45
45
46 The %(here)s variable will be replaced with the parent directory of this file
46 The %(here)s variable will be replaced with the parent directory of this file
47 ''',
47 ''',
48 {
48 {
49 '[server:main]': {
49 '[server:main]': {
50 'port': '4999',
50 'port': '4999',
51 },
51 },
52 '[app:main]': {
52 '[app:main]': {
53 'initial_repo_scan': 'true',
53 'initial_repo_scan': 'true',
54 'app_instance_uuid': 'test',
54 'app_instance_uuid': 'test',
55 'show_revision_number': 'true',
55 'show_revision_number': 'true',
56 'beaker.cache.sql_cache_short.expire': '1',
56 'beaker.cache.sql_cache_short.expire': '1',
57 'beaker.session.secret': '{74e0cd75-b339-478b-b129-07dd221def1f}',
57 'beaker.session.secret': '{74e0cd75-b339-478b-b129-07dd221def1f}',
58 'cache_dir': '%(here)s/../../data/test/cache',
59 'index_dir': '%(here)s/../../data/test/index',
60 'archive_cache_dir': '%(here)s/../../data/test/tarballcache',
61 'beaker.cache.data_dir': '%(here)s/../../data/test/cache/data',
62 'beaker.cache.lock_dir': '%(here)s/../../data/test/cache/lock',
58 'sqlalchemy.db1.url': 'sqlite:///%(here)s/kallithea_test.sqlite',
63 'sqlalchemy.db1.url': 'sqlite:///%(here)s/kallithea_test.sqlite',
59 },
64 },
60 '[logger_root]': {
65 '[logger_root]': {
61 'level': 'DEBUG',
66 'level': 'DEBUG',
62 },
67 },
63 '[logger_sqlalchemy]': {
68 '[logger_sqlalchemy]': {
64 'level': 'ERROR',
69 'level': 'ERROR',
65 'handlers': 'console',
70 'handlers': 'console',
66 },
71 },
67 '[handler_console]': {
72 '[handler_console]': {
68 'level': 'NOTSET',
73 'level': 'NOTSET',
69 },
74 },
70 },
75 },
71 ),
76 ),
72 ('development.ini',
77 ('development.ini',
73 '''
78 '''
74 Kallithea - Development config:
79 Kallithea - Development config:
75 listening on *:5000
80 listening on *:5000
76 sqlite and kallithea.db
81 sqlite and kallithea.db
77 initial_repo_scan = true
82 initial_repo_scan = true
78 set debug = true
83 set debug = true
79 verbose and colorful logging
84 verbose and colorful logging
80
85
81 The %(here)s variable will be replaced with the parent directory of this file
86 The %(here)s variable will be replaced with the parent directory of this file
82 ''',
87 ''',
83 {
88 {
84 '[server:main]': {
89 '[server:main]': {
85 'host': '0.0.0.0',
90 'host': '0.0.0.0',
86 },
91 },
87 '[app:main]': {
92 '[app:main]': {
88 'initial_repo_scan': 'true',
93 'initial_repo_scan': 'true',
89 'set debug': 'true',
94 'set debug': 'true',
90 'app_instance_uuid': 'development-not-secret',
95 'app_instance_uuid': 'development-not-secret',
91 'beaker.session.secret': 'development-not-secret',
96 'beaker.session.secret': 'development-not-secret',
92 },
97 },
93 '[handler_console]': {
98 '[handler_console]': {
94 'level': 'DEBUG',
99 'level': 'DEBUG',
95 'formatter': 'color_formatter',
100 'formatter': 'color_formatter',
96 },
101 },
97 '[handler_console_sql]': {
102 '[handler_console_sql]': {
98 'level': 'DEBUG',
103 'level': 'DEBUG',
99 'formatter': 'color_formatter_sql',
104 'formatter': 'color_formatter_sql',
100 },
105 },
101 },
106 },
102 ),
107 ),
103 ]
108 ]
104
109
105
110
106 def main():
111 def main():
107 # make sure all mako lines starting with '#' (the '##' comments) are marked up as <text>
112 # make sure all mako lines starting with '#' (the '##' comments) are marked up as <text>
108 print 'reading:', makofile
113 print 'reading:', makofile
109 mako_org = file(makofile).read()
114 mako_org = file(makofile).read()
110 mako_no_text_markup = re.sub(r'</?%text>', '', mako_org)
115 mako_no_text_markup = re.sub(r'</?%text>', '', mako_org)
111 mako_marked_up = re.sub(r'\n(##.*)', r'\n<%text>\1</%text>', mako_no_text_markup, flags=re.MULTILINE)
116 mako_marked_up = re.sub(r'\n(##.*)', r'\n<%text>\1</%text>', mako_no_text_markup, flags=re.MULTILINE)
112 if mako_marked_up != mako_org:
117 if mako_marked_up != mako_org:
113 print 'writing:', makofile
118 print 'writing:', makofile
114 file(makofile, 'w').write(mako_marked_up)
119 file(makofile, 'w').write(mako_marked_up)
115
120
116 # select the right mako conditionals for the other less sophisticated formats
121 # select the right mako conditionals for the other less sophisticated formats
117 def sub_conditionals(m):
122 def sub_conditionals(m):
118 """given a %if...%endif match, replace with just the selected
123 """given a %if...%endif match, replace with just the selected
119 conditional sections enabled and the rest as comments
124 conditional sections enabled and the rest as comments
120 """
125 """
121 conditional_lines = m.group(1)
126 conditional_lines = m.group(1)
122 def sub_conditional(m):
127 def sub_conditional(m):
123 """given a conditional and the corresponding lines, return them raw
128 """given a conditional and the corresponding lines, return them raw
124 or commented out, based on whether conditional is selected
129 or commented out, based on whether conditional is selected
125 """
130 """
126 criteria, lines = m.groups()
131 criteria, lines = m.groups()
127 if criteria not in selected_mako_conditionals:
132 if criteria not in selected_mako_conditionals:
128 lines = '\n'.join((l if not l or l.startswith('#') else '#' + l) for l in lines.split('\n'))
133 lines = '\n'.join((l if not l or l.startswith('#') else '#' + l) for l in lines.split('\n'))
129 return lines
134 return lines
130 conditional_lines = re.sub(r'^%(?:el)?if (.*):\n((?:^[^%\n].*\n|\n)*)',
135 conditional_lines = re.sub(r'^%(?:el)?if (.*):\n((?:^[^%\n].*\n|\n)*)',
131 sub_conditional, conditional_lines, flags=re.MULTILINE)
136 sub_conditional, conditional_lines, flags=re.MULTILINE)
132 return conditional_lines
137 return conditional_lines
133 mako_no_conditionals = re.sub(r'^(%if .*\n(?:[^%\n].*\n|%elif .*\n|\n)*)%endif\n',
138 mako_no_conditionals = re.sub(r'^(%if .*\n(?:[^%\n].*\n|%elif .*\n|\n)*)%endif\n',
134 sub_conditionals, mako_no_text_markup, flags=re.MULTILINE)
139 sub_conditionals, mako_no_text_markup, flags=re.MULTILINE)
135
140
136 # expand mako variables
141 # expand mako variables
137 def pyrepl(m):
142 def pyrepl(m):
138 return mako_variable_values.get(m.group(1), m.group(0))
143 return mako_variable_values.get(m.group(1), m.group(0))
139 mako_no_variables = re.sub(r'\${([^}]*)}', pyrepl, mako_no_conditionals)
144 mako_no_variables = re.sub(r'\${([^}]*)}', pyrepl, mako_no_conditionals)
140
145
141 # remove utf-8 coding header
146 # remove utf-8 coding header
142 base_ini = re.sub(r'^## -\*- coding: utf-8 -\*-\n', '', mako_no_variables)
147 base_ini = re.sub(r'^## -\*- coding: utf-8 -\*-\n', '', mako_no_variables)
143
148
144 # create ini files
149 # create ini files
145 for fn, desc, settings in ini_files:
150 for fn, desc, settings in ini_files:
146 print 'updating:', fn
151 print 'updating:', fn
147 ini_lines = re.sub(
152 ini_lines = re.sub(
148 '# Kallithea - config file generated with kallithea-config *#\n',
153 '# Kallithea - config file generated with kallithea-config *#\n',
149 ''.join('# %-77s#\n' % l.strip() for l in desc.strip().split('\n')),
154 ''.join('# %-77s#\n' % l.strip() for l in desc.strip().split('\n')),
150 base_ini)
155 base_ini)
151 def process_section(m):
156 def process_section(m):
152 """process a ini section, replacing values as necessary"""
157 """process a ini section, replacing values as necessary"""
153 sectionname, lines = m.groups()
158 sectionname, lines = m.groups()
154 if sectionname in settings:
159 if sectionname in settings:
155 section_settings = settings[sectionname]
160 section_settings = settings[sectionname]
156 def process_line(m):
161 def process_line(m):
157 """process a section line and update value if necessary"""
162 """process a section line and update value if necessary"""
158 setting, value = m.groups()
163 setting, value = m.groups()
159 line = m.group(0)
164 line = m.group(0)
160 if setting in section_settings:
165 if setting in section_settings:
161 line = '%s = %s' % (setting, section_settings[setting])
166 line = '%s = %s' % (setting, section_settings[setting])
162 if '$' not in value:
167 if '$' not in value:
163 line = '#%s = %s\n%s' % (setting, value, line)
168 line = '#%s = %s\n%s' % (setting, value, line)
164 return line.rstrip()
169 return line.rstrip()
165 lines = re.sub(r'^([^#\n].*) = ?(.*)', process_line, lines, flags=re.MULTILINE)
170 lines = re.sub(r'^([^#\n].*) = ?(.*)', process_line, lines, flags=re.MULTILINE)
166 return sectionname + '\n' + lines
171 return sectionname + '\n' + lines
167 ini_lines = re.sub(r'^(\[.*\])\n((?:(?:[^[\n].*)?\n)*)', process_section, ini_lines, flags=re.MULTILINE)
172 ini_lines = re.sub(r'^(\[.*\])\n((?:(?:[^[\n].*)?\n)*)', process_section, ini_lines, flags=re.MULTILINE)
168 file(fn, 'w').write(ini_lines)
173 file(fn, 'w').write(ini_lines)
169
174
170 if __name__ == '__main__':
175 if __name__ == '__main__':
171 main()
176 main()
General Comments 0
You need to be logged in to leave comments. Login now