forked from adamlaska/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecks.py
More file actions
69 lines (62 loc) · 2.49 KB
/
Copy pathchecks.py
File metadata and controls
69 lines (62 loc) · 2.49 KB
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
import os
from django.conf import settings
from django.core import checks
@checks.register('directories')
def check_cdn_directory_exists(app_configs, **kwargs):
"""This checks that the path from which the CDN will serve static files for
this version of the datatracker actually exists. In development and test
mode STATIC_ROOT will normally be just static/, but in production it will be
set to a different part of the file system which is served via CDN, and the
path will contain the datatracker release version.
"""
errors = []
if settings.SERVER_MODE == 'production' and not os.path.exists(settings.STATIC_ROOT):
errors.append(checks.Error(
"The static files directory has not been set up.",
hint="Please run 'ietf/manage.py collectstatic'.",
obj=None,
id='datatracker.E001',
))
return errors
@checks.register('files')
def check_group_email_aliases_exists(app_configs, **kwargs):
from ietf.group.info import get_group_email_aliases
errors = []
try:
aliases = get_group_email_aliases(None, None)
if not aliases:
errors.append(checks.Error(
"Found no aliases in the group email aliases file",
hint="Please run ietf/bin/generate-wg-aliases to generate them.",
obj=None,
id="datatracker.E0002",
))
except IOError as e:
errors.append(checks.Error(
"Could not read group email aliases:\n %s" % e,
hint="Please run ietf/bin/generate-wg-aliases to generate them.",
obj=None,
id="datatracker.E0003",
))
return errors
@checks.register('files')
def check_doc_email_aliases_exists(app_configs, **kwargs):
from ietf.doc.views_doc import get_doc_email_aliases
errors = []
try:
aliases = get_doc_email_aliases(None)
if not aliases:
errors.append(checks.Critical(
"Found no aliases in the document email aliases file.",
hint="Please run ietf/bin/generate-draft-aliases to generate them.",
obj=None,
id="datatracker.E0004",
))
except IOError as e:
errors.append(checks.Critical(
"Could not read document email aliases:\n %s" % e,
hint="Please run ietf/bin/generate-draft-aliases to generate them.",
obj=None,
id="datatracker.E0005",
))
return errors