From 661288cf55b78dac825c9bcc58972323f37a7e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Liard?= Date: Sat, 7 Mar 2015 18:44:21 +0100 Subject: [PATCH 1/2] Correct the sytem call with the "cd" command --- lib/GenerateBJP.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/GenerateBJP.pm b/lib/GenerateBJP.pm index 788f75e..e423fb7 100644 --- a/lib/GenerateBJP.pm +++ b/lib/GenerateBJP.pm @@ -108,13 +108,13 @@ sub displayBJP { system("rm", "-f", "$script_path/latex/bjp.pdf", "$script_path/latex/bjp.aux", "$script_path/latex/bjp.fls", "$script_path/latex/bjp.log", "$script_path/latex/bjp.fdb_latexmk"); print STDERR "-outdir=$script_path/latex"; - system("cd" "latex"); + system("cd latex"); system("latexmk", "-pdf", "-outdir=$script_path/latex", "latex/bjp.tex"); if ( $? == -1 ) { print STDERR "command failed: $!\n"; } - system("cd" ".."); + system("cd $script_path"); return "bjp.pdf"; } From 7b11b78e01848ecd53733d56f5cdfd6ef5eff18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Liard?= Date: Mon, 9 Mar 2015 01:06:35 +0100 Subject: [PATCH 2/2] Convert the yaml bjp info into a sqlite info Add a sqlite db to store informations Modify the bjp.py to deals with a sqlite database --- latex/bjp.py | 42 ++++++++++++++++++++++++------------------ sql/bjp.db | Bin 0 -> 6144 bytes 2 files changed, 24 insertions(+), 18 deletions(-) create mode 100644 sql/bjp.db diff --git a/latex/bjp.py b/latex/bjp.py index 7255595..2c62e75 100755 --- a/latex/bjp.py +++ b/latex/bjp.py @@ -2,14 +2,18 @@ import calendar import sys -import yaml +import sqlite argc = len ( sys.argv ) if argc != 2 : - sys.exit ( 'Usage: bjp.py fichier.yaml' ) + sys.exit ( 'Usage: bjp.py bjp_id' ) -with open ( sys.argv[1] , 'r' ) as f : - bjp = yaml.load ( f ) +bjp = sys.argv[2] + +connection = connect ('bjp.db') +cur = connection.cursor() +infos = cur.execute("select name, contact, address, intervenant, responsable, prestation, projet, nature from client inner join mission on client.bjp_id = mission.bjp_id inner join fournisseur on mission.bjp_id = fournisseur.bjp_id where client.bjp_id= '%s'" %bjp) +[ name, contact, address, intervenant, responsable, prestation, projet, nature ] = infos.fetchone() with open ( 'latex/cartouche.tex' , 'w' ) as cartouche : @@ -19,11 +23,11 @@ print ( '\\multicolumn{1}{c|}{\\titre{LINAGORA}} \\\\' , file = cartouche ) print ( '\\hline' , file = cartouche ) print ( '\\begin{tabular}{ll}' , file = cartouche ) - print ( 'Nom :\t\t&' , bjp['client']['nom'] , '\\\\[1ex]' , file = cartouche ) + print ( 'Nom :\t\t&' , name , '\\\\[1ex]' , file = cartouche ) print ( 'Contact :\t& ' , end = '' , file = cartouche ) prems = True - for l in bjp['client']['contact'].split ( '\n' ) : + for l in contact.split ( '\n' ) : if l != '' : if prems : print ( l , '\\\\' , end = '' , file = cartouche ) @@ -35,7 +39,7 @@ print ( 'Adresse :\t& ' , end = '' , file = cartouche ) prems = True - for l in bjp['client']['adresse'].split ( '\n' ) : + for l in address.split ( '\n' ) : if l != '' : if prems : print ( l , '\\\\' , file = cartouche ) @@ -46,8 +50,8 @@ print ( '\\end{tabular}' , file = cartouche ) print ( '&' , file = cartouche ) print ( '\\begin{tabular}{ll}' , file = cartouche ) - print ( 'Responsable :\t& ', bjp['linagora']['responsable'] , '\\\\[1ex]' , file = cartouche ) - print ( 'Intervenant :\t& ', bjp['linagora']['intervenant'] , file = cartouche ) + print ( 'Responsable :\t& ', responsable, '\\\\[1ex]' , file = cartouche ) + print ( 'Intervenant :\t& ', intervenant, file = cartouche ) print ( '\\end{tabular}' , file = cartouche ) print ( '\\\\' , file = cartouche ) print ( '\\hline' , file = cartouche ) @@ -56,17 +60,17 @@ print ( '\\begin{tabularx}{\\textwidth}{|>{\\columncolor[gray]{0.9}}r|X|}' , file = cartouche ) print ( '\\hline' , file = cartouche ) - print ( 'Intitulé de la prestation\t&' , bjp['mission']['prestation'] , '\\\\' , file = cartouche ) + print ( 'Intitulé de la prestation\t&' , prestation, '\\\\' , file = cartouche ) print ( '\\hline' , file = cartouche ) - print ( 'Référence du projet\t\t&' , bjp['mission']['projet'] , '\\\\' , file = cartouche ) + print ( 'Référence du projet\t\t&' , projet , '\\\\' , file = cartouche ) print ( '\\hline' , file = cartouche ) - print ( 'Nature de la mission\t\t&' , bjp['mission']['nature'] , '\\\\' , file = cartouche ) + print ( 'Nature de la mission\t\t&' , nature , '\\\\' , file = cartouche ) print ( '\\hline' , file = cartouche ) print ( '\\end{tabularx}' , file = cartouche ) print ( file = cartouche ) - annee = bjp['annee'] - mois = bjp['mois'] + annee = cur.execute("SELECT annee FROM calendrier WHERE bjp_id = '%s'" % bjp) + mois = cur.execute("SELECT mois FROM calendrier WHERE bjp_id = '%s'" % bjp) nom_mois = ( '' , 'Janvier' , 'Février' , 'Mars' , 'Avril' , 'Mai' , 'Juin' , 'Juillet' , 'Août' , 'Septembre' , @@ -101,25 +105,27 @@ nom_jour = ( 'lundi' , 'mardi' , 'mercredi' , 'jeudi' , 'vendredi' , 'samedi' , 'dimanche' ) + days = cur.execute("SELECT day, period from calendrier WHERE bjp_id= '%s'" %bjp) for j in calendrier.itermonthdays2 ( annee , mois ) : if j[0] != 0 : # jour dans le mois x = j[1] * 2 - if j[0] in bjp['calendrier'] : - if bjp['calendrier'][j[0]] == 'OK' : # journée entière + if j[0] in days.fetchall() : + [day, period] = days.fetchone() + if period == 'OK' : # journée entière print ( '\\filldraw [ fill = yellow!100!blue!30 ] (' , x , ',' , y , ') rectangle (' , x + 2 , ',' , y + 1 , ') ;' , file = tikz ) - elif bjp['calendrier'][j[0]] == 'ma' : # matin + elif period == 'ma' : # matin print ( '\\filldraw [ fill = yellow!100!blue!30 ] (' , x , ',' , y , ') -- (' , x , ',' , y + 1 , ') -- (' , x + 2 , ',' , y + 1 , ') -- cycle ;' , file = tikz ) - elif bjp['calendrier'][j[0]] == 'am' : # après-midi + elif period == 'am' : # après-midi print ( '\\filldraw [ fill = yellow!100!blue!30 ] (' , x , ',' , y , ') -- (' , x + 2 , ',' , y , ') -- (' , diff --git a/sql/bjp.db b/sql/bjp.db new file mode 100644 index 0000000000000000000000000000000000000000..d0732a29dc7fcc5d6f30cdd06b7d5a2f2082380a GIT binary patch literal 6144 zcmeHLL2uJA7`5x9ZK^TE0aev5o+`wqZjf#(W8wg%bkf+QjjbGzCQV-Afw#oT90zR& z4&Be-AMDO;$DO!vW>*eKNL=BFaFR`JvkC1;A)o5x^|PD4_Y}vUv+-huNs4zo;Sz~w zfd(K1PcQ}mjHs4Z?IJV4ts)dd-Rr0A|p52$&-u1VVtEr@jM@@F`X@zpN3XiHWw;eAOoCN_5 zMIY1$*!6W>n_i?qyrrCQnWiad;CnoXoJn^L5Kd%Gc4ttbJT?Z89>s)RMV5K|{G<&K zJx^YnBquTymq_@Epd?cLNt&K7yj^-p&sC(?a`|$t24BULgMCL$hOL0^hm>11^%V_B zNOewd;?gPg%gJsH7Rr?hJgO)6l*80*V8zGWz!j3*wLKuVt@H+Isg}nju`X$i=%j~U zr9YaR5PbmZlSSr0=D-j*@EqpB%l2(!u8u`Wu}yL74Uv?DcE~ryCdcy)(_Fx7&Gn^? zwqVvCenuUl)+hA{y^qbhIb+V6b7o_sv$Pn^e+_*E=m+|S&J@TZb0BkI_#7D3&^YXs zr}`*DRim#UEalLcab9;B5LJw%{7BaS6M#;JPjbdMbKpOApry)y$F+H*BM1+6sE|=5 zV0o^8dMxAZ%VNB#kG4m|b{X$2{HhA5*JsSev{_H){~17M|FM&q^vr>O&4D{m2X|+U z*6Fc&p=IF}MugpT=mAkLxZ(|iPaVhO(frrZCxCvU@8}EqtY8+I1DOLu=|EA}!OdI7 f!s>ESi_t@u6j6-kiCfIY=z&7&;h@GfR+oPRS$lKD literal 0 HcmV?d00001