Projet

Général

Profil

« Précédent | Suivant » 

Révision 80f5b222

Ajouté par Thomas Noël il y a plus de 9 ans

get CONFIG_XML path from settings or os.environ

Voir les différences:

usr/local/univnautes/sp/sp/pfconfigxml.py
16 16
# You should have received a copy of the GNU Affero General Public License
17 17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 18

  
19
import os
19 20
import sys
20 21
import re
21 22
import xml.etree.ElementTree as ET
22 23
from operator import itemgetter
23 24

  
24
CONFIG_XML='/cf/conf/config.xml'
25
from django.conf import settings
25 26

  
26 27
def root():
27
    with open(CONFIG_XML,'r') as f:
28
    with open(settings.CONFIG_XML,'r') as f:
28 29
        x = ET.fromstring(f.read())
29 30
    return x
30 31

  
......
157 158
                },
158 159
            }
159 160

  
160
if __name__ == '__main__':
161
    if len(sys.argv) > 1:
162
        CONFIG_XML = sys.argv[1]
163
    print 'read config from', CONFIG_XML
164
    #print root()
165
    #print get_ca('53a4638d45954')
166
    #print get_cert('53a4644d846a4')
167
    #print get_saml_cps()
168
    #print get_sp()
169

  
170

  
usr/local/univnautes/sp/sp/settings.py
6 6

  
7 7
PROJECT_PATH = os.path.dirname(os.path.dirname(__file__))
8 8

  
9
DEBUG = False
9
DEBUG = os.environ.get('DEBUG') == 'yes'
10 10
TEMPLATE_DEBUG = DEBUG
11 11

  
12 12
# fastcgi (see http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/)
13 13
FORCE_SCRIPT_NAME=''
14 14

  
15
ADMINS = (
16
    # ('Your Name', 'your_email@example.com'),
17
)
15
ADMINS = ()
18 16
MANAGERS = ADMINS
19 17

  
20 18
DATABASES = {
......
187 185
# get some values from config.xml
188 186
# => server must be restarted if config.xml is changed
189 187

  
188
if 'CONFIG_XML' in os.environ:
189
    # for run this application outside a real pfSense
190
    CONFIG_XML = os.environ['CONFIG_XML']
191
else:
192
    CONFIG_XML = '/cf/conf/config.xml'
193

  
190 194
sp = pfconfigxml.get_sp()
191 195
# SAML certificate
192 196
SAML_SIGNATURE_PUBLIC_KEY = sp.get('saml_cert', {}).get('crt')

Formats disponibles : Unified diff