Mercurial > libervia-web
comparison src/twisted/plugins/libervia_server.py @ 449:981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
- browser_side --> src/browser
- public --> src/browser_side/public
- libervia.py --> src/browser/libervia_main.py
- libervia_server --> src/server
- libervia_server/libervia.sh --> src/libervia.sh
- twisted --> src/twisted
- new module src/common
- split constants.py in 3 files:
- src/common/constants.py
- src/browser/constants.py
- src/server/constants.py
- output --> html (generated by pyjsbuild during the installation)
- new option/parameter "data_dir" (-d) to indicates the directory containing html and server_css
- setup.py installs libervia to the following paths:
- src/common --> <LIB>/libervia/common
- src/server --> <LIB>/libervia/server
- src/twisted --> <LIB>/twisted
- html --> <SHARE>/libervia/html
- server_side --> <SHARE>libervia/server_side
- LIBERVIA_INSTALL environment variable takes 2 new options with prompt confirmation:
- clean: remove previous installation directories
- purge: remove building and previous installation directories
You may need to update your sat.conf and/or launching script to update the following options/parameters:
- ssl_certificate
- data_dir
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 20 May 2014 06:41:16 +0200 |
parents | twisted/plugins/libervia.py@c406e46fe9c0 |
children | 1a0cec9b0f1e |
comparison
equal
deleted
inserted
replaced
448:14c35f7f1ef5 | 449:981ed669d3b3 |
---|---|
1 #!/usr/bin/python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # Libervia: a Salut à Toi frontend | |
5 # Copyright (C) 2013 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 from twisted.internet import defer | |
21 if defer.Deferred.debug: | |
22 # if we are in debug mode, we want to use ipdb instead of pdb | |
23 try: | |
24 import ipdb | |
25 import pdb | |
26 pdb.set_trace = ipdb.set_trace | |
27 pdb.post_mortem = ipdb.post_mortem | |
28 except ImportError: | |
29 pass | |
30 | |
31 # XXX: We need to configure logs before any log method is used, so here is the best place. | |
32 from libervia.server.constants import Const as C | |
33 from sat.core import log_config | |
34 log_config.satConfigure(C.LOG_BACKEND_TWISTED, C) | |
35 | |
36 from zope.interface import implements | |
37 | |
38 from twisted.python import usage | |
39 from twisted.plugin import IPlugin | |
40 from twisted.application.service import IServiceMaker | |
41 | |
42 from ConfigParser import SafeConfigParser, NoSectionError, NoOptionError | |
43 try: | |
44 from libervia.server.server import Libervia | |
45 opt_params = Libervia.OPT_PARAMETERS | |
46 except (ImportError, SystemExit): | |
47 # avoid raising an error when you call twisted and sat is not launched | |
48 opt_params = [] | |
49 | |
50 | |
51 class Options(usage.Options): | |
52 | |
53 # optArgs is not really useful in our case, we need more than a flag | |
54 optParameters = opt_params | |
55 | |
56 def __init__(self): | |
57 """You want to read SàT configuration file now in order to overwrite the hard-coded default values. | |
58 This is because the priority for the usage of the values is (from lowest to highest): | |
59 - hard-coded default values | |
60 - values from SàT configuration files | |
61 - values passed on the command line | |
62 If you do it later: after the command line options have been parsed, there's no good way to know | |
63 if the options values are the hard-coded ones or if they have been passed on the command line. | |
64 """ | |
65 config = SafeConfigParser() | |
66 config.read(C.CONFIG_FILES) | |
67 for index, param in list(enumerate(self.optParameters)): | |
68 # index is only used to not modify the loop variable "param" | |
69 name = param[0] | |
70 try: | |
71 value = config.get('libervia', name) | |
72 self.optParameters[index][2] = param[4](value) | |
73 except (NoSectionError, NoOptionError): | |
74 pass | |
75 usage.Options.__init__(self) | |
76 | |
77 | |
78 class LiberviaMaker(object): | |
79 implements(IServiceMaker, IPlugin) | |
80 | |
81 tapname = 'libervia' | |
82 # FIXME: twistd bugs when printing 'à' on "Unknown command" error (works on normal command listing) | |
83 description = u'The web frontend of Salut a Toi' | |
84 options = Options | |
85 | |
86 def makeService(self, options): | |
87 return Libervia(**dict(options)) # get rid of the usage.Option overload | |
88 | |
89 | |
90 # affectation to some variable is necessary for twisted introspection to work | |
91 serviceMaker = LiberviaMaker() | |
92 |