Commit 10decef0828cf1a4e067c2862d2085eddbdd5c17

Authored by Olivier Duvernois
1 parent a237dba4

*** empty log message ***

Showing 1 changed file with 79 additions and 38 deletions   Show diff stats
anubis_dev/library/tools/latex.anubis
... ... @@ -199,6 +199,27 @@ public define String
199 199 Compilation LaTeX (to PDF)
200 200 --------------------------
201 201  
  202 +
  203 +define Bool
  204 + execute_control
  205 + (
  206 + ExecuteControl ec,
  207 + Int32 max_time
  208 + ) =
  209 + checking every 2000 milliseconds,
  210 + wait for true
  211 + then if check_execute_status(ec) is
  212 + {
  213 + still_running then
  214 + if now>max_time
  215 + then print("Time over \n"); false
  216 + else execute_control(ec,max_time),
  217 + abnormal_termination then print("abnormal_termination \n"); false
  218 + finished(i) then
  219 + if i = 0 then true else print("Error: finished <> 0 \n"); false
  220 + }.
  221 +
  222 +
202 223 define One
203 224 make_pdf_file
204 225 (
... ... @@ -208,28 +229,67 @@ define One
208 229 ) =
209 230 if (Maybe(ExecuteControl))execute(mb_execution_directory,"dvipdf",[file_name+".dvi"]) is
210 231 {
211   - failure then print("Error execute making pdf file \n"),
212   - success(s) then
213   - if check_execute_status(s) is
214   - {
215   - still_running then print("compilation is still running 2 \n"),
216   - abnormal_termination then print("abnormal_termination 2\n"),
217   - finished(i) then
218   - if i = 0 then
  232 + failure then print("Error execute making pdf file \n"),
  233 + success(ec) then
  234 + print("dvipdf : ");
  235 + if execute_control(ec,now+30)
  236 + then print("OK \n");
219 237 if mb_pdf_directory is
220 238 {
221   - failure then unique,
222   - success(pdf_dir) then
223   - if (Maybe(Int8))execute(mb_execution_directory,"mv",[file_name+".pdf",pdf_dir]) is
224   - {
225   - failure then print("Error execute mv pdf \n"),
226   - success(mv) then
227   - if mv = 0 then print("mv pdf = OK ") else print("Error mv PDF \n")
228   - }}
229   - else print("Error making pdf file \n")}
  239 + failure then unique,
  240 + success(pdf_dir) then
  241 + if (Maybe(ExecuteControl))execute(mb_execution_directory,"mv",[file_name+".pdf",pdf_dir]) is
  242 + {
  243 + failure then print("Error execute mv pdf \n"),
  244 + success(mv) then
  245 + print("mv pdf file -> pdf_directory : ");
  246 + if execute_control(mv,now+10)
  247 + then print("OK \n")
  248 + else print("Error mv PDF \n")
  249 + }}
  250 +
  251 + else print("Error making pdf file \n")
230 252 }.
231 253  
232 254  
  255 +
  256 +public define One
  257 + latex_compilation
  258 + (
  259 + String file_name, // without extension
  260 + Maybe(String) mb_execution_directory,
  261 + Maybe(String) mb_pdf_directory,
  262 + Int32 compilation_number // 2 if table-of-contents is required
  263 + ) =
  264 + if (Maybe(ExecuteControl))
  265 + execute(mb_execution_directory,"latex",[file_name+".tex"]) is
  266 + {
  267 + failure then print("Error executing compilation n°"+compilation_number+"\n"),
  268 + success(ec) then
  269 + print("Compilation n°"+compilation_number+" : ");
  270 + if execute_control(ec,now+60)
  271 + then print("OK\n");
  272 + if compilation_number = 1
  273 + then make_pdf_file(file_name,mb_execution_directory,mb_pdf_directory)
  274 + else latex_compilation(file_name,mb_execution_directory,
  275 + mb_pdf_directory,compilation_number-1)
  276 + else print("Error compilation n°"+compilation_number+"\n")
  277 + }.
  278 +
  279 +
  280 +
  281 +
  282 +
  283 +
  284 + - Compilation par un 'execute produisant un Maybe(Int8))
  285 + --------------------------------------------------------
  286 + define One
  287 + make_pdf_file
  288 + (
  289 + String file_name,
  290 + Maybe(String) mb_execution_directory,
  291 + Maybe(String) mb_pdf_directory,
  292 + ) =
233 293 if (Maybe(Int8))execute(mb_execution_directory,"dvipdf",[file_name+".dvi"]) is
234 294 {
235 295 failure then print("Error execute making pdf file \n"),
... ... @@ -248,7 +308,8 @@ define One
248 308 else print("Error making pdf file \n")
249 309 }.
250 310  
251   -public define One
  311 +
  312 + public define One
252 313 latex_compilation
253 314 (
254 315 String file_name, // without extension
... ... @@ -256,26 +317,6 @@ public define One
256 317 Maybe(String) mb_pdf_directory,
257 318 Int32 compilation_number // 2 if table-of-contents is required
258 319 ) =
259   - if (Maybe(ExecuteControl))
260   - execute(mb_execution_directory,"latex",[file_name+".tex"]) is
261   - {
262   - failure then print("Error executing compilation n°"+compilation_number+"\n"),
263   - success(s) then
264   - if check_execute_status(s) is
265   - {
266   - still_running then print("compilation is still running 1 \n"),
267   - abnormal_termination then print("abnormal_termination 1\n"),
268   - finished(i) then
269   - if i = 0
270   - then if compilation_number = 1
271   - then make_pdf_file(file_name,mb_execution_directory,mb_pdf_directory)
272   - else latex_compilation(file_name,mb_execution_directory,
273   - mb_pdf_directory,compilation_number-1)
274   - else print("Error compilation n°"+compilation_number+"\n")
275   - }
276   - }.
277   -
278   -
279 320 if (Maybe(Int8))
280 321 execute(mb_execution_directory,"latex",[file_name+".tex"]) is
281 322 {
... ...