-
Notifications
You must be signed in to change notification settings - Fork 24
/
config.py
301 lines (260 loc) · 10.8 KB
/
config.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# The location of the extracted scilab_for_xcos_on_cloud. This can be either
# relative to SendLog.py or an absolute path.
SCILAB_DIR = '../scilab_for_xcos_on_cloud'
# The location to keep the flask session data on server.
FLASKSESSIONDIR = '/tmp/flask-sessiondir'
# The scilab branch
BRANCH = 'master'
# The location to keep the session data on server.
SESSIONDIR = '/tmp/sessiondir'
SESSIONTIMEOUT = 21600
SESSION_COOKIE_SAMESITE = 'Strict'
SESSION_COOKIE_SECURE = False
# The location to keep the flask caching data on server.
FLASKCACHINGDEFAULTTIMEOUT = 900
FLASKCACHINGDIR = '/tmp/flask-caching-dir'
# The location of the logs on server.
LOGDIR = '/tmp/xcos-on-cloud-logs'
LOGFILE = 'xcos.log'
LOGBACKUPCOUNT = 10
# The location of the xcos files on server.
XCOSSOURCEDIR = 'uploads'
# the http server settings
HTTP_SERVER_HOST = '127.0.0.1'
HTTP_SERVER_PORT = 8001
# the database server settings
DB_NAME = 'scilab.sqlite3'
# the instances
SCILAB_MIN_INSTANCES = 2
SCILAB_START_INSTANCES = 4
SCILAB_MAX_INSTANCES = 8
SCILAB_INSTANCE_RETRY_INTERVAL = 3
# the delay
TKSCALE_START_DELAY = 1.5
SCILAB_INSTANCE_TIMEOUT_INTERVAL = 300
MAX_LOG_SIZE = 512 * 1024
# the versioned files
VERSIONED_FILES = [
"chart.js",
"combined.js",
"custom.js",
"dependencies.js",
"details.js",
"example.html",
"finalmodsheet.xsl",
"importparameters.js",
"indexfunctions.js",
"LOOKUP_CURV.js",
"only_scifunc_code.js",
"orientation.js",
"prerequisitefile.js",
"setup.js",
"Sigbuilder-graph.js",
]
VERSIONED_CHECK_INTERVAL = 15
# the database queries
QUERY_ID_EXAMPLE_FILE = (
"SELECT loc.id, pe.id, tcc.id, tce.id "
"FROM textbook_companion_preference pe "
"JOIN textbook_companion_proposal po ON pe.proposal_id = po.id "
"JOIN list_of_category loc ON pe.category = loc.id "
"JOIN textbook_companion_chapter tcc ON pe.id = tcc.preference_id "
"JOIN xcos_on_cloud_enable_book xceb ON pe.id = xceb.book_id "
"JOIN textbook_companion_example tce ON tcc.id = tce.chapter_id "
"JOIN textbook_companion_example_files tcef ON tce.id = tcef.example_id "
"WHERE tcef.filetype = 'X' AND po.proposal_status = 3 AND "
"tcef.xcos_cloud_example_file_error_status = 0 AND "
"pe.approval_status = 1 AND "
"tcef.id = ? "
"LIMIT 1")
QUERY_ID_EXAMPLE = (
"SELECT loc.id, pe.id, tcc.id "
"FROM textbook_companion_preference pe "
"JOIN textbook_companion_proposal po ON pe.proposal_id = po.id "
"JOIN list_of_category loc ON pe.category = loc.id "
"JOIN textbook_companion_chapter tcc ON pe.id = tcc.preference_id "
"JOIN xcos_on_cloud_enable_book xceb ON pe.id = xceb.book_id "
"JOIN textbook_companion_example tce ON tcc.id = tce.chapter_id "
"JOIN textbook_companion_example_files tcef ON tce.id = tcef.example_id "
"WHERE tcef.filetype = 'X' AND po.proposal_status = 3 AND "
"tcef.xcos_cloud_example_file_error_status = 0 AND "
"pe.approval_status = 1 AND "
"tce.id = ? "
"LIMIT 1")
QUERY_ID_CHAPTER = (
"SELECT loc.id, pe.id "
"FROM textbook_companion_preference pe "
"JOIN textbook_companion_proposal po ON pe.proposal_id = po.id "
"JOIN list_of_category loc ON pe.category = loc.id "
"JOIN textbook_companion_chapter tcc ON pe.id = tcc.preference_id "
"JOIN xcos_on_cloud_enable_book xceb ON pe.id = xceb.book_id "
"JOIN textbook_companion_example tce ON tcc.id = tce.chapter_id "
"JOIN textbook_companion_example_files tcef ON tce.id = tcef.example_id "
"WHERE tcef.filetype = 'X' AND po.proposal_status = 3 AND "
"tcef.xcos_cloud_example_file_error_status = 0 AND "
"pe.approval_status = 1 AND "
"tcc.id = ? "
"LIMIT 1")
QUERY_ID_BOOK = (
"SELECT loc.id "
"FROM textbook_companion_preference pe "
"JOIN textbook_companion_proposal po ON pe.proposal_id = po.id "
"JOIN list_of_category loc ON pe.category = loc.id "
"JOIN textbook_companion_chapter tcc ON pe.id = tcc.preference_id "
"JOIN xcos_on_cloud_enable_book xceb ON pe.id = xceb.book_id "
"JOIN textbook_companion_example tce ON tcc.id = tce.chapter_id "
"JOIN textbook_companion_example_files tcef ON tce.id = tcef.example_id "
"WHERE tcef.filetype = 'X' AND po.proposal_status = 3 AND "
"tcef.xcos_cloud_example_file_error_status = 0 AND "
"pe.approval_status = 1 AND "
"pe.id = ? "
"LIMIT 1")
QUERY_COUNT = (
"SELECT COUNT(*), COUNT(DISTINCT(pe.id)) "
"FROM textbook_companion_preference pe "
"JOIN textbook_companion_proposal po ON pe.proposal_id = po.id "
"JOIN list_of_category loc ON pe.category = loc.id "
"JOIN textbook_companion_chapter tcc ON pe.id = tcc.preference_id "
"JOIN xcos_on_cloud_enable_book xceb ON pe.id = xceb.book_id "
"JOIN textbook_companion_example tce ON tcc.id = tce.chapter_id "
"JOIN textbook_companion_example_files tcef ON tce.id = tcef.example_id "
"WHERE tcef.filetype = 'X' AND po.proposal_status = 3 AND "
"tcef.xcos_cloud_example_file_error_status = 0 AND "
"pe.approval_status = 1")
QUERY_CATEGORY = (
"SELECT loc.id, loc.category_name, COUNT(*), COUNT(DISTINCT(pe.id)) "
"FROM textbook_companion_preference pe "
"JOIN textbook_companion_proposal po ON pe.proposal_id = po.id "
"JOIN list_of_category loc ON pe.category = loc.id "
"JOIN textbook_companion_chapter tcc ON pe.id = tcc.preference_id "
"JOIN xcos_on_cloud_enable_book xceb ON pe.id = xceb.book_id "
"JOIN textbook_companion_example tce ON tcc.id = tce.chapter_id "
"JOIN textbook_companion_example_files tcef ON tce.id = tcef.example_id "
"WHERE tcef.filetype = 'X' AND po.proposal_status = 3 AND "
"tcef.xcos_cloud_example_file_error_status = 0 AND "
"pe.approval_status = 1 "
"GROUP BY 1 "
"ORDER BY 2 ASC")
QUERY_BOOK = (
"SELECT pe.id, pe.book, pe.author, COUNT(*) "
"FROM textbook_companion_preference pe "
"JOIN textbook_companion_proposal po ON pe.proposal_id = po.id "
"JOIN list_of_category loc ON pe.category = loc.id "
"JOIN textbook_companion_chapter tcc ON pe.id = tcc.preference_id "
"JOIN xcos_on_cloud_enable_book xceb ON pe.id = xceb.book_id "
"JOIN textbook_companion_example tce ON tcc.id = tce.chapter_id "
"JOIN textbook_companion_example_files tcef ON tce.id = tcef.example_id "
"WHERE tcef.filetype = 'X' AND po.proposal_status = 3 AND "
"tcef.xcos_cloud_example_file_error_status = 0 AND "
"pe.approval_status = 1 AND "
"pe.category = ? "
"GROUP BY 1 "
"ORDER BY 2 ASC")
QUERY_CHAPTER = (
"SELECT tcc.id, tcc.number, tcc.name, COUNT(*) "
"FROM textbook_companion_preference pe "
"JOIN textbook_companion_proposal po ON pe.proposal_id = po.id "
"JOIN list_of_category loc ON pe.category = loc.id "
"JOIN textbook_companion_chapter tcc ON pe.id = tcc.preference_id "
"JOIN xcos_on_cloud_enable_book xceb ON pe.id = xceb.book_id "
"JOIN textbook_companion_example tce ON tcc.id = tce.chapter_id "
"JOIN textbook_companion_example_files tcef ON tce.id = tcef.example_id "
"WHERE tcef.filetype = 'X' AND po.proposal_status = 3 AND "
"tcef.xcos_cloud_example_file_error_status = 0 AND "
"pe.approval_status = 1 AND "
"tcc.preference_id = ? "
"GROUP BY 1 "
"ORDER BY 2 ASC")
QUERY_EXAMPLE = (
"SELECT DISTINCT(tce.id), tce.number, tce.caption "
"FROM textbook_companion_preference pe "
"JOIN textbook_companion_proposal po ON pe.proposal_id = po.id "
"JOIN list_of_category loc ON pe.category = loc.id "
"JOIN textbook_companion_chapter tcc ON pe.id = tcc.preference_id "
"JOIN xcos_on_cloud_enable_book xceb ON pe.id = xceb.book_id "
"JOIN textbook_companion_example tce ON tcc.id = tce.chapter_id "
"JOIN textbook_companion_example_files tcef ON tce.id = tcef.example_id "
"WHERE tcef.filetype = 'X' AND po.proposal_status = 3 AND "
"tcef.xcos_cloud_example_file_error_status = 0 AND "
"pe.approval_status = 1 AND "
"tce.chapter_id = ? "
"ORDER BY tce.number ASC")
QUERY_EXAMPLE_FILE = (
"SELECT id as example_file_id, filename, filetype "
"FROM textbook_companion_example_files "
"WHERE filetype IN ('X', 'S') AND "
"xcos_cloud_example_file_error_status = 0 AND example_id = ? "
"ORDER BY filetype DESC")
QUERY_EXAMPLE_FILE_BY_ID = (
"SELECT filename, filepath, example_id "
"FROM textbook_companion_example_files "
"WHERE filetype = 'X' AND id = ?"
)
QUERY_PREREQUISITE_FILE_BY_ID = (
"SELECT filename, filepath "
"FROM textbook_companion_example_files "
"WHERE filetype = 'S' AND id = ?"
)
QUERY_PREREQUISITE_FILE_BY_EXAMPLE_ID = (
"SELECT filename, filepath, id as prerequisite_file_id "
"FROM textbook_companion_example_files "
"WHERE filetype = 'S' AND example_id = ?"
)
QUERY_CONTRIBUTOR_DETAILS = (
"SELECT pe.id, pe.book, pe.author, pe.isbn, pe.publisher, "
"po.full_name as proposal_full_name, po.branch as proposal_branch, "
"po.university as proposal_university "
"FROM textbook_companion_proposal po "
"LEFT JOIN textbook_companion_preference pe ON po.id = pe.proposal_id "
"WHERE pe.id = ?")
# Following are system command which are not permitted in sci files
# (Reference scilab-on-cloud project)
SYSTEM_COMMANDS = (
r'unix\(.*\)|unix_g\(.*\)|unix_w\(.*\)|unix_x\(.*\)|unix_s\(.*\)|host'
r'|newfun|execstr|ascii|mputl|dir\(\)'
)
SPECIAL_CHARACTERS = r'["\'\\]'
# The directory where images are created
IMAGEDIR = 'res_imgs'
# Set CREATEIMAGE to True to create img_test.jpg in IMAGEDIR
CREATEIMAGE = False
REMOVEFILE = True
SCILAB_CURVE_C_SCI = "macros/Sources/CURVE_c.sci"
SCILAB_EXPRESSION_SCI = "macros/Misc/EXPRESSION.sci"
CONT_FRM_WRITE = "ajax-scilab/cont_frm_write.sci"
CLEANDATA_SCI_FUNC_WRITE = "ajax-scilab/scifunc-cleandata-do_spline.sci"
EXP_SCI_FUNC_WRITE = "ajax-scilab/expression-sci-function.sci"
GET_COLORMAP_VALUES_SCI_FUNC_WRITE = "ajax-scilab/get_colormap_values.sci"
RANDFUNC = "ajax-scilab/randfunc.sci"
INTERNAL = {
'getOutput': {
'scriptfiles': [CONT_FRM_WRITE],
'function': 'calculate_cont_frm',
'parameters': ['num', 'den'],
},
'getExpressionOutput': {
'scriptfiles': [SCILAB_EXPRESSION_SCI, EXP_SCI_FUNC_WRITE],
'function': 'callFunctionAcctoMethod',
'parameters': ['head', 'exx'],
},
'cleandata': {
'scriptfiles': [SCILAB_CURVE_C_SCI, CLEANDATA_SCI_FUNC_WRITE],
'function': 'callFunctioncleandata',
'parameters': ['xye'],
},
'do_Spline': {
'scriptfiles': [SCILAB_CURVE_C_SCI, CLEANDATA_SCI_FUNC_WRITE],
'function': 'callFunction_do_Spline',
'parameters': ['N', 'order', 'x', 'y'],
},
'get_colormap_values': {
'scriptfiles': [GET_COLORMAP_VALUES_SCI_FUNC_WRITE],
'function': 'getvaluesfromcolormap',
'parameters': ['colormapString'],
},
'randfunc': {
'scriptfiles': [RANDFUNC],
'function': 'randfunc',
'parameters': ['inputvalue'],
}
}