annotate src/core/constants.py @ 1195:aac1285edcac

we are in dev version again
author Goffi <goffi@goffi.org>
date Mon, 15 Sep 2014 12:07:40 +0200
parents a090e5ee83c2
children 008c8ccd5dcc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
914
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
3
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SàT: a XMPP client
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
6
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
11
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
16
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
19
1112
e51e69b7732d core (constants): better management of xdg import
Goffi <goffi@goffi.org>
parents: 1111
diff changeset
20 try:
e51e69b7732d core (constants): better management of xdg import
Goffi <goffi@goffi.org>
parents: 1111
diff changeset
21 from xdg import BaseDirectory
1004
191f440d11b4 core (constants): use realpath instead of abspath + do not import it when building libervia
souliane <souliane@mailoo.org>
parents: 1003
diff changeset
22 from os.path import expanduser, realpath
1112
e51e69b7732d core (constants): better management of xdg import
Goffi <goffi@goffi.org>
parents: 1111
diff changeset
23 except ImportError:
e51e69b7732d core (constants): better management of xdg import
Goffi <goffi@goffi.org>
parents: 1111
diff changeset
24 BaseDirectory = None
930
cbf4122baae7 core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents: 926
diff changeset
25
914
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
26
1a3ba959f0ab core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff changeset
27 class Const(object):
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
28
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
29 ## Application ##
923
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
30 APP_NAME = u'Salut à Toi'
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
31 APP_NAME_SHORT = u'SàT'
1003
52ec79aa5bbe memory: fixes the method fixLocalDir for pid_dir and log_dir to use local_dir as default
souliane <souliane@mailoo.org>
parents: 1001
diff changeset
32 APP_NAME_FILE = u'sat'
923
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
33 APP_NAME_FULL = u'%s (%s)' % (APP_NAME_SHORT, APP_NAME)
1195
aac1285edcac we are in dev version again
Goffi <goffi@goffi.org>
parents: 1192
diff changeset
34 APP_VERSION = u'0.5.0D' # Please add 'D' at the end for dev versions
967
242bd4fc654c core, frontends (constants): frontends Const inheritates from core Const
souliane <souliane@mailoo.org>
parents: 944
diff changeset
35 APP_URL = 'http://salut-a-toi.org'
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
36
994
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
37
1089
8e0072754413 core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents: 1088
diff changeset
38 # Protocol
8e0072754413 core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents: 1088
diff changeset
39 XMPP_C2S_PORT = 5222
8e0072754413 core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents: 1088
diff changeset
40
8e0072754413 core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents: 1088
diff changeset
41
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
42 ## Parameters ##
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
43 NO_SECURITY_LIMIT = -1
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
44 INDIVIDUAL = "individual"
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
45 GENERAL = "general"
1088
b29452cab50b core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:
souliane <souliane@mailoo.org>
parents: 1043
diff changeset
46 # Parameters related to connection
b29452cab50b core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:
souliane <souliane@mailoo.org>
parents: 1043
diff changeset
47 FORCE_SERVER_PARAM = "Force server"
b29452cab50b core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:
souliane <souliane@mailoo.org>
parents: 1043
diff changeset
48 FORCE_PORT_PARAM = "Force port"
1030
15f43b54d697 core, memory, bridge: added profile password + password encryption:
souliane <souliane@mailoo.org>
parents: 1020
diff changeset
49 # Parameters related to encryption
15f43b54d697 core, memory, bridge: added profile password + password encryption:
souliane <souliane@mailoo.org>
parents: 1020
diff changeset
50 PROFILE_PASS_PATH = ('General', 'Password')
15f43b54d697 core, memory, bridge: added profile password + password encryption:
souliane <souliane@mailoo.org>
parents: 1020
diff changeset
51 MEMORY_CRYPTO_NAMESPACE = 'crypto' # for the private persistent binary dict
15f43b54d697 core, memory, bridge: added profile password + password encryption:
souliane <souliane@mailoo.org>
parents: 1020
diff changeset
52 MEMORY_CRYPTO_KEY = 'personal_key'
1020
adbde4a3a52f plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents: 1017
diff changeset
53 # Parameters for static blog pages
adbde4a3a52f plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents: 1017
diff changeset
54 STATIC_BLOG_KEY = "Blog page"
adbde4a3a52f plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents: 1017
diff changeset
55 STATIC_BLOG_PARAM_TITLE = "Title"
adbde4a3a52f plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents: 1017
diff changeset
56 STATIC_BLOG_PARAM_BANNER = "Banner"
adbde4a3a52f plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents: 1017
diff changeset
57 STATIC_BLOG_PARAM_KEYWORDS = "Keywords"
adbde4a3a52f plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents: 1017
diff changeset
58 STATIC_BLOG_PARAM_DESCRIPTION = "Description"
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
59
1171
0abce7f17782 core: a new "info" type is used in newMessage for system messages (not comming from outside)
Goffi <goffi@goffi.org>
parents: 1143
diff changeset
60
1092
0eefc74c346b core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
61 ## Menus ##
0eefc74c346b core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
62 MENU_GLOBAL = "GLOBAL"
0eefc74c346b core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
63 MENU_ROOM = "ROOM"
0eefc74c346b core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
64 MENU_SINGLE = "SINGLE"
0eefc74c346b core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
65 MENU_JID_CONTEXT = "JID_CONTEXT"
0eefc74c346b core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
66 MENU_ROSTER_JID_CONTEXT = "ROSTER_JID_CONTEXT"
0eefc74c346b core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
67 MENU_ROSTER_GROUP_CONTEXT = "MENU_ROSTER_GROUP_CONTEXT"
0eefc74c346b core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
68
1171
0abce7f17782 core: a new "info" type is used in newMessage for system messages (not comming from outside)
Goffi <goffi@goffi.org>
parents: 1143
diff changeset
69
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
70 ## Profile and entities ##
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
71 PROF_KEY_NONE = '@NONE@'
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
72 PROF_KEY_DEFAULT = '@DEFAULT@'
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
73 ENTITY_ALL = '@ALL@'
944
e1842ebcb2f3 core, plugin XEP-0115: discovery refactoring:
Goffi <goffi@goffi.org>
parents: 943
diff changeset
74 ENTITY_LAST_RESOURCE = 'LAST_RESOURCE'
e1842ebcb2f3 core, plugin XEP-0115: discovery refactoring:
Goffi <goffi@goffi.org>
parents: 943
diff changeset
75 ENTITY_CAP_HASH = 'CAP_HASH'
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
76
994
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
77
1171
0abce7f17782 core: a new "info" type is used in newMessage for system messages (not comming from outside)
Goffi <goffi@goffi.org>
parents: 1143
diff changeset
78 ## Messages ##
0abce7f17782 core: a new "info" type is used in newMessage for system messages (not comming from outside)
Goffi <goffi@goffi.org>
parents: 1143
diff changeset
79 MESS_TYPE_INFO = 'info'
0abce7f17782 core: a new "info" type is used in newMessage for system messages (not comming from outside)
Goffi <goffi@goffi.org>
parents: 1143
diff changeset
80
994
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
81 ## Configuration ##
1113
edd3fc4b4aaf core (constants): minor comment change
Goffi <goffi@goffi.org>
parents: 1112
diff changeset
82 if BaseDirectory: # skipped when xdg module is not available (should not happen in backend)
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
83
967
242bd4fc654c core, frontends (constants): frontends Const inheritates from core Const
souliane <souliane@mailoo.org>
parents: 944
diff changeset
84 ## Configuration ##
242bd4fc654c core, frontends (constants): frontends Const inheritates from core Const
souliane <souliane@mailoo.org>
parents: 944
diff changeset
85 DEFAULT_CONFIG = {
1003
52ec79aa5bbe memory: fixes the method fixLocalDir for pid_dir and log_dir to use local_dir as default
souliane <souliane@mailoo.org>
parents: 1001
diff changeset
86 'media_dir': '/usr/share/' + APP_NAME_FILE + '/media',
52ec79aa5bbe memory: fixes the method fixLocalDir for pid_dir and log_dir to use local_dir as default
souliane <souliane@mailoo.org>
parents: 1001
diff changeset
87 'local_dir': BaseDirectory.save_data_path(APP_NAME_FILE),
52ec79aa5bbe memory: fixes the method fixLocalDir for pid_dir and log_dir to use local_dir as default
souliane <souliane@mailoo.org>
parents: 1001
diff changeset
88 'pid_dir': '%(local_dir)s',
52ec79aa5bbe memory: fixes the method fixLocalDir for pid_dir and log_dir to use local_dir as default
souliane <souliane@mailoo.org>
parents: 1001
diff changeset
89 'log_dir': '%(local_dir)s',
967
242bd4fc654c core, frontends (constants): frontends Const inheritates from core Const
souliane <souliane@mailoo.org>
parents: 944
diff changeset
90 }
923
e77948faaef3 core: removed default_config:
Goffi <goffi@goffi.org>
parents: 919
diff changeset
91
967
242bd4fc654c core, frontends (constants): frontends Const inheritates from core Const
souliane <souliane@mailoo.org>
parents: 944
diff changeset
92 # List of the configuration filenames sorted by ascending priority
1004
191f440d11b4 core (constants): use realpath instead of abspath + do not import it when building libervia
souliane <souliane@mailoo.org>
parents: 1003
diff changeset
93 CONFIG_FILES = [realpath(expanduser(path) + APP_NAME_FILE + '.conf') for path in
1001
eb3601ff73bc core: fixes constants.py
souliane <souliane@mailoo.org>
parents: 994
diff changeset
94 ['/etc/', '~/', '~/.', '', '.'] +
1003
52ec79aa5bbe memory: fixes the method fixLocalDir for pid_dir and log_dir to use local_dir as default
souliane <souliane@mailoo.org>
parents: 1001
diff changeset
95 ['%s/' % path for path in list(BaseDirectory.load_config_paths(APP_NAME_FILE))]
994
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
96 ]
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
97
926
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 923
diff changeset
98
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
99 ## Plugins ##
926
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 923
diff changeset
100 # names of widely used plugins
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 923
diff changeset
101 TEXT_CMDS = 'TEXT-COMMANDS'
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
102
994
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
103
1104
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
104 ## XMLUI ##
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
105 XMLUI_WINDOW = 'window'
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
106 XMLUI_POPUP = 'popup'
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
107 XMLUI_FORM = 'form'
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
108 XMLUI_PARAM = 'param'
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
109 XMLUI_DIALOG = 'dialog'
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
110 XMLUI_DIALOG_CONFIRM = "confirm"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
111 XMLUI_DIALOG_MESSAGE = "message"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
112 XMLUI_DIALOG_NOTE = "note"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
113 XMLUI_DIALOG_FILE = "file"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
114 XMLUI_DATA_ANSWER = "answer"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
115 XMLUI_DATA_CANCELLED = "cancelled"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
116 XMLUI_DATA_TYPE = "type"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
117 XMLUI_DATA_MESS = "message"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
118 XMLUI_DATA_LVL = "level"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
119 XMLUI_DATA_LVL_INFO = "info"
1108
6bdcaeafca11 core (constants): fixed bad XMLUI level constants
Goffi <goffi@goffi.org>
parents: 1104
diff changeset
120 XMLUI_DATA_LVL_WARNING = "warning"
6bdcaeafca11 core (constants): fixed bad XMLUI level constants
Goffi <goffi@goffi.org>
parents: 1104
diff changeset
121 XMLUI_DATA_LVL_ERROR = "error"
1104
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
122 XMLUI_DATA_LVL_DEFAULT = XMLUI_DATA_LVL_INFO
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
123 XMLUI_DATA_BTNS_SET = "buttons_set"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
124 XMLUI_DATA_BTNS_SET_OKCANCEL = "ok/cancel"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
125 XMLUI_DATA_BTNS_SET_YESNO = "yes/no"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
126 XMLUI_DATA_BTNS_SET_DEFAULT = XMLUI_DATA_BTNS_SET_OKCANCEL
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
127 XMLUI_DATA_FILETYPE = 'filetype'
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
128 XMLUI_DATA_FILETYPE_FILE = "file"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
129 XMLUI_DATA_FILETYPE_DIR = "dir"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
130 XMLUI_DATA_FILETYPE_DEFAULT = XMLUI_DATA_FILETYPE_FILE
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
131
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
132
991
05e02f8b7eb4 core: logging refactoring, first step:
Goffi <goffi@goffi.org>
parents: 990
diff changeset
133 ## Logging ##
05e02f8b7eb4 core: logging refactoring, first step:
Goffi <goffi@goffi.org>
parents: 990
diff changeset
134 LOG_BACKEND_STANDARD = 'standard'
05e02f8b7eb4 core: logging refactoring, first step:
Goffi <goffi@goffi.org>
parents: 990
diff changeset
135 LOG_BACKEND_TWISTED = 'twisted'
05e02f8b7eb4 core: logging refactoring, first step:
Goffi <goffi@goffi.org>
parents: 990
diff changeset
136 LOG_BACKEND_BASIC = 'basic'
1017
0ea97f483464 core (log): added "custom" backend
Goffi <goffi@goffi.org>
parents: 1010
diff changeset
137 LOG_BACKEND_CUSTOM = 'custom'
991
05e02f8b7eb4 core: logging refactoring, first step:
Goffi <goffi@goffi.org>
parents: 990
diff changeset
138 LOG_BASE_LOGGER = 'root'
1007
a7d33c7a8277 core (log): refactoring + twisted backend:
Goffi <goffi@goffi.org>
parents: 1005
diff changeset
139 LOG_TWISTED_LOGGER = 'twisted'
1010
73a0b7f94674 primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
140 LOG_OPT_SECTION = 'DEFAULT' # section of sat.conf where log options should be
994
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
141 LOG_OPT_PREFIX = 'log_'
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
142 # (option_name, default_value) tuples
1005
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
143 LOG_OPT_COLORS = ('colors', 'true') # true for auto colors, force to have colors even if stdout is not a tty, false for no color
994
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
144 LOG_OPT_LEVEL = ('level', 'info')
1005
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
145 LOG_OPT_FORMAT = ('fmt', '%(message)s') # similar to logging format.
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
146 LOG_OPT_LOGGER = ('logger', '') # regex to filter logger name
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
147 LOG_OPT_OUTPUT_SEP = '//'
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
148 LOG_OPT_OUTPUT_DEFAULT = 'default'
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
149 LOG_OPT_OUTPUT_MEMORY = 'memory'
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
150 LOG_OPT_OUTPUT_MEMORY_LIMIT = 50
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
151 LOG_OPT_OUTPUT_FILE = 'file' # file is implicit if only output
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
152 LOG_OPT_OUTPUT = ('output', LOG_OPT_OUTPUT_SEP + LOG_OPT_OUTPUT_DEFAULT) # //default = normal output (stderr or a file with twistd), path/to/file for a file (must be the first if used), //memory for memory (options can be put in parenthesis, e.g.: //memory(500) for a 500 lines memory)
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
153 LOG_LVL_DEBUG = 'DEBUG'
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
154 LOG_LVL_INFO = 'INFO'
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
155 LOG_LVL_WARNING = 'WARNING'
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
156 LOG_LVL_ERROR = 'ERROR'
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
157 LOG_LVL_CRITICAL = 'CRITICAL'
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
158 LOG_LEVELS = (LOG_LVL_DEBUG, LOG_LVL_INFO, LOG_LVL_WARNING, LOG_LVL_ERROR, LOG_LVL_CRITICAL)
994
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
159
991
05e02f8b7eb4 core: logging refactoring, first step:
Goffi <goffi@goffi.org>
parents: 990
diff changeset
160
1104
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
161 ## HARD-CODED ACTIONS IDS (generated with uuid.uuid4) ##
1032
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents: 1030
diff changeset
162 AUTHENTICATE_PROFILE_ID = u'b03bbfa8-a4ae-4734-a248-06ce6c7cf562'
1043
066308706dc6 core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents: 1032
diff changeset
163 CHANGE_XMPP_PASSWD_ID = u'878b9387-de2b-413b-950f-e424a147bcd0'
1032
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents: 1030
diff changeset
164
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents: 1030
diff changeset
165
1104
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
166 ## Text values ##
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
167 BOOL_TRUE = "true"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
168 BOOL_FALSE = "false"
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
169
490a8a4536b6 core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents: 1092
diff changeset
170
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
171 ## Misc ##
1003
52ec79aa5bbe memory: fixes the method fixLocalDir for pid_dir and log_dir to use local_dir as default
souliane <souliane@mailoo.org>
parents: 1001
diff changeset
172 SAVEFILE_DATABASE = APP_NAME_FILE + ".db"
942
598fc223cf59 core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents: 930
diff changeset
173 IQ_SET = '/iq[@type="set"]'
994
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
174 ENV_PREFIX = 'SAT_' # Prefix used for environment variables
652c01ca69b1 core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents: 991
diff changeset
175
990
f0e407709d8e core (constants): added some basic ANSI escape codes
Goffi <goffi@goffi.org>
parents: 971
diff changeset
176
f0e407709d8e core (constants): added some basic ANSI escape codes
Goffi <goffi@goffi.org>
parents: 971
diff changeset
177 ## ANSI escape sequences ##
f0e407709d8e core (constants): added some basic ANSI escape codes
Goffi <goffi@goffi.org>
parents: 971
diff changeset
178 # XXX: used for logging
1005
b4af31a8a4f2 core (logs): added formatting, name filter and outputs management:
Goffi <goffi@goffi.org>
parents: 1004
diff changeset
179 # XXX: they will be probably moved in a dedicated module in the future
990
f0e407709d8e core (constants): added some basic ANSI escape codes
Goffi <goffi@goffi.org>
parents: 971
diff changeset
180 ANSI_RESET = '\033[0m'
f0e407709d8e core (constants): added some basic ANSI escape codes
Goffi <goffi@goffi.org>
parents: 971
diff changeset
181 ANSI_NORMAL_WEIGHT = '\033[22m'
f0e407709d8e core (constants): added some basic ANSI escape codes
Goffi <goffi@goffi.org>
parents: 971
diff changeset
182 ANSI_FG_BLACK, ANSI_FG_RED, ANSI_FG_GREEN, ANSI_FG_YELLOW, ANSI_FG_BLUE, ANSI_FG_MAGENTA, ANSI_FG_CYAN, ANSI_FG_WHITE = ('\033[3%dm' % nb for nb in xrange(8))
f0e407709d8e core (constants): added some basic ANSI escape codes
Goffi <goffi@goffi.org>
parents: 971
diff changeset
183 ANSI_BOLD = '\033[1m'
f0e407709d8e core (constants): added some basic ANSI escape codes
Goffi <goffi@goffi.org>
parents: 971
diff changeset
184 ANSI_BLINK = '\033[5m'
f0e407709d8e core (constants): added some basic ANSI escape codes
Goffi <goffi@goffi.org>
parents: 971
diff changeset
185 ANSI_BLINK_OFF = '\033[25m'
1010
73a0b7f94674 primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
186
73a0b7f94674 primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
187 @classmethod
73a0b7f94674 primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
188 def LOG_OPTIONS(cls):
73a0b7f94674 primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
189 """Return options checked for logs"""
73a0b7f94674 primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
190 # XXX: we use a classmethod so we can use Const inheritance to change default options
73a0b7f94674 primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
191 return(cls.LOG_OPT_COLORS, cls.LOG_OPT_LEVEL, cls.LOG_OPT_FORMAT, cls.LOG_OPT_LOGGER, cls.LOG_OPT_OUTPUT)
73a0b7f94674 primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
192
1143
3164b509bc99 core (constants): Bool method allow to convert from python bool to string constant for true/false (in both directions)
Goffi <goffi@goffi.org>
parents: 1113
diff changeset
193 @classmethod
3164b509bc99 core (constants): Bool method allow to convert from python bool to string constant for true/false (in both directions)
Goffi <goffi@goffi.org>
parents: 1113
diff changeset
194 def bool(cls, value):
1171
0abce7f17782 core: a new "info" type is used in newMessage for system messages (not comming from outside)
Goffi <goffi@goffi.org>
parents: 1143
diff changeset
195 """retour str text value for bool, or bool value for str"""
1143
3164b509bc99 core (constants): Bool method allow to convert from python bool to string constant for true/false (in both directions)
Goffi <goffi@goffi.org>
parents: 1113
diff changeset
196 if isinstance(value, bool):
3164b509bc99 core (constants): Bool method allow to convert from python bool to string constant for true/false (in both directions)
Goffi <goffi@goffi.org>
parents: 1113
diff changeset
197 return cls.BOOL_TRUE if value else cls.BOOL_FALSE
3164b509bc99 core (constants): Bool method allow to convert from python bool to string constant for true/false (in both directions)
Goffi <goffi@goffi.org>
parents: 1113
diff changeset
198 return value.lower() == cls.BOOL_TRUE