comparison src/twisted/plugins/libervia_server.py @ 856:fd438e51bda8

server: version check: - added C.APP_VERSIOn to server/constants, to override value from sat.core.constants, this allow checking version mismatch - libervia.__version__ is set - in case of version mismatch with sat module version, an error message is printend and execution is stopped
author Goffi <goffi@goffi.org>
date Sun, 24 Jan 2016 18:45:35 +0100
parents f8a7a046ff9c
children e17b15f1f260
comparison
equal deleted inserted replaced
855:de17f7313cbe 856:fd438e51bda8
29 pdb.post_mortem = ipdb.post_mortem 29 pdb.post_mortem = ipdb.post_mortem
30 except ImportError: 30 except ImportError:
31 pass 31 pass
32 32
33 import os.path 33 import os.path
34 import libervia
35 import sat
34 36
35 from libervia.server.constants import Const as C 37 from libervia.server.constants import Const as C
36 38
37 from sat.core.i18n import _ 39 from sat.core.i18n import _
38 from sat.tools import config 40 from sat.tools import config
44 from twisted.application.service import IServiceMaker 46 from twisted.application.service import IServiceMaker
45 import ConfigParser 47 import ConfigParser
46 48
47 49
48 CONFIG_SECTION = C.APP_NAME.lower() 50 CONFIG_SECTION = C.APP_NAME.lower()
51 if libervia.__version__ != sat.__version__:
52 import sys
53 sys.stderr.write(u"""sat module version ({sat_version}) and {current_app} version ({current_version}) mismatch
54
55 sat module is located at {sat_path}
56 libervia module is located at {libervia_path}
57
58 Please be sure to have the same version running
59 """.format(
60 sat_version = sat.__version__,
61 current_app = C.APP_NAME,
62 current_version = libervia.__version__,
63 sat_path = os.path.dirname(sat.__file__),
64 libervia_path = os.path.dirname(libervia.__file__),
65 ).encode('utf-8'))
66 sys.stderr.flush()
67 # we call os._exit to avoid help to be printed by twisted
68 import os
69 os._exit(1)
49 70
50 71
51 def coerceConnectionType(value): # called from Libervia.OPT_PARAMETERS 72 def coerceConnectionType(value): # called from Libervia.OPT_PARAMETERS
52 allowed_values = ('http', 'https', 'both') 73 allowed_values = ('http', 'https', 'both')
53 if value not in allowed_values: 74 if value not in allowed_values: