-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
120 lines (101 loc) · 3.71 KB
/
__init__.py
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# -*- coding: utf-8 -*-
"""
:synopsis: the Django Q&A forum application
Functions in the openode module perform various
basic actions on behalf of the forum application
"""
import os
import platform
# from django.conf import settings
VERSION = (1, 1, 6)
#keys are module names used by python imports,
#values - the package qualifier to use for pip
#ATTENTION - only importable modlules may be listed, due to automatic testing, i.e. ipython cannot be imported, so violates tests
REQUIREMENTS = {
'akismet': 'akismet==0.2.0',
'django': 'Django==1.3.7',
'jinja2': 'Jinja2==2.6',
'coffin': 'Coffin==0.3.7',
'oauth2': 'oauth2==1.5.211',
'markdown2': 'markdown2==2.1.0',
'html5lib': 'html5lib==0.95',
'keyedcache': 'django-keyedcache==1.4-6',
# 'threaded_multihost': 'django-threaded-multihost',
#'robots': 'django-robots==0.9.1',
'unidecode': 'Unidecode==0.04.10',
'django_countries': 'django-countries==1.0.5',
'djcelery': 'django-celery==3.0.17',
# 'celery_with_redis': 'celery-with-redis==3.0',
'redis': "redis==2.7.4",
# 'djkombu': 'django-kombu==0.9.4',
# 'followit': 'django-followit==0.0.3', # following user is not available in Openode anymore
'recaptcha_works': 'django-recaptcha-works==0.3.4',
'openid': 'python-openid==2.2.5',
# 'pystache': 'pystache==0.3.1',
'pytz': 'pytz==2012j',
# 'longerusername': 'longerusername==0.4',
'bs4': 'beautifulsoup4==4.1.3',
'mptt': 'django-mptt==0.5.4',
'Pyro4': 'Pyro4==4.17',
'gunicorn': 'gunicorn==0.17.2',
'rosetta': 'django-rosetta==0.7.1',
'admin_tools': 'django-admin-tools==0.4.1',
'bleach': 'bleach==1.2.1',
"magic": "python-magic==0.4.3",
"sorl.thumbnail": "sorl-thumbnail==11.12",
"PIL": "Pillow==2.0.0",
"psycopg2": "psycopg2==2.5",
"haystack": "django-haystack==2.0.0",
"pyelasticsearch": "pyelasticsearch==0.5",
"psi": "PSI==0.3b2",
"nagios": "nagios-nsca==1.1.0",
}
# TODO remove feature Ask/Answer by email
if platform.system() != 'Windows':
REQUIREMENTS['lamson'] = 'lamson==1.1'
#necessary for interoperability of django and coffin
try:
from openode import patches
from openode.deployment.assertions import assert_package_compatibility
assert_package_compatibility()
patches.patch_django()
patches.patch_coffin() # must go after django
except ImportError:
pass
def get_install_directory():
"""returns path to directory
where code of the openode django application
is installed
"""
return os.path.dirname(__file__)
def get_path_to(relative_path):
"""returns absolute path to a file
relative to ``openode`` directory
``relative_path`` must use only forward slashes
and must not start with a slash
"""
root_dir = get_install_directory()
assert(relative_path[0] != 0)
path_bits = relative_path.split('/')
return os.path.join(root_dir, *path_bits)
def get_version():
"""returns version of the openode app
this version is meaningful for pypi only
"""
return '.'.join([str(subversion) for subversion in VERSION])
def get_database_engine_name():
"""returns name of the database engine,
independently of the version of django
- for django >=1.2 looks into ``settings.DATABASES['default']``,
(i.e. assumes that openode uses database named 'default')
, and for django 1.1 and below returns settings.DATABASE_ENGINE
"""
import django
from django.conf import settings as django_settings
major_version = django.VERSION[0]
minor_version = django.VERSION[1]
if major_version == 1:
if minor_version > 1:
return django_settings.DATABASES['default']['ENGINE']
else:
return django_settings.DATABASE_ENGINE