Changeset 16 for trunk/Obsolete
- Timestamp:
- 05/02/06 11:17:47 (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Obsolete/imprime.pro
r14 r16 7 7 ; 8 8 ; PURPOSE: 9 ; visualise puis imprime eventuellement un fichier Postcript. 10 ; depuis rhodes, le LODYC ou L''IPSL vers les imprimantes du LODYC ou 11 ; de l''IPSL. si le 12 ; fichier n''est pas ds le repertoire courant, on va voir s''il est 13 ; sur gaya dans POSTSCRIPT, si oui, on se propose de le rammener. 14 ; 15 ; CATEGORY: 16 ; traitement fichiers 17 ; 18 ; CALLING SEQUENCE: 19 ; imprime [,nomfichier] 20 ; 21 ; INPUTS: 22 ; 23 ; nomfichier: nom du fichier a imprimer. si nomfichier n''est 24 ; pas precise on prend le dernier postscript cree ds le 25 ; repertoire courant. 26 ; 27 ; KEYWORD PARAMETERS: 28 ; 29 ; /TRANS:imprime -si on le desire- sur un transparant 30 ; 31 ; /NB: obsolete 32 ; 33 ; COMMON BLOCKS: 34 ; common.pro 35 ; 36 ; SIDE EFFECTS: 37 ; 38 ; dans le cas ou le fichier est imprime, il y a possibilite de faire 39 ; un archivage sur gaya ds le repertoire POSTSCRIPT. l''archivage se 40 ; fait en fonction de la valeur de sauveps (variable globale) : 41 ; sauveps=1 : achivage automatique 42 ; sauveps=0 : on n''archive pas 43 ; sauveps a une autre valeur: on demande si on veut archiver a 44 ; chaque ps imprime. 45 ; 46 ; le nom du ps archive est le suivant: 47 ; un numero lorsque le ps s''appelle idl.ps 48 ; son nom ds les autres cas. 49 ; ce nom et la date apparaissent en bas a gauche du ps (ainsi que la 50 ; date de creation) 51 ; 52 ; Rq: avant d''etre envoye sur gaya le fichier est zippe. 53 ; 54 ; Dans le cas ou loginipsl est definit et la machipsl ne l''est 55 ; pas, on passe par la liaison ATM (bcp plus rapide) pour rappatrier le 56 ; fichier en local, sur le repertoire temporaire, avant de l''imprimer. 57 ; 58 ; RESTRICTIONS: verifier que rhodes est bien declare ds vos .rhosts en 59 ; local. 60 ; sur rhodes ds le .rhosts il faut : 61 ; 192.168.111.64 ipsllogin 62 ; a l''ipsl ds le .rhosts il faut : 63 ; rhodes-atm idrislogin 64 ; 65 ; EXAMPLE: 66 ; 67 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 68 ; 21/12/98 69 ; 25/8/19999 utilisation des widgets 70 ; 8/9/1999 utilisation de cw_bgroup 9 ; obsolete, use printps instead... 10 ; 11 ; MODIFICATION HISTORY: 12 ; June 2005: Sebastien Masson, english version 71 13 ;- 72 14 ;------------------------------------------------------------ 73 15 ;------------------------------------------------------------ 74 16 ;------------------------------------------------------------ 75 PRO imprime_event, event 76 @common 77 ; quel est le type d''evenement? 78 widget_control, event.id, get_uvalue=uval 79 ; case sur le type d''evenement 80 case uval.name OF 17 PRO imprime, filename, TRANS = trans, NB = nb 18 ; 19 ; this is working only with unix/linux/osX machines 20 thisOS = strupcase(strmid(!version.os_family, 0, 3)) 21 CASE thisOS OF 22 'MAC':return 23 'WIN':return 24 ELSE: 25 ENDCASE 81 26 ;------------------------------------------------------------ 82 ; visualisation du Postscript27 ; call printps 83 28 ;------------------------------------------------------------ 84 'Visualiser':BEGIN 85 if key_portrait EQ 1 then sens = 'portrait' ELSE sens = 'seascape' 86 case event.value of 87 'Ghostview':spawn,'ghostview -a4 -quiet -'+sens+' '+psdir+uval.nomfich 88 'Ghostscript':spawn,'gs -sPAPERSIZE=a4 -q '+psdir+uval.nomfich 89 'Kghostview':spawn,'kghostview '+psdir+uval.nomfich 90 endcase 91 end 92 'Imprimer':BEGIN 29 CASE N_PARAMS() OF 30 0:printps 31 1:printps, filename 32 ELSE: BEGIN 33 ras = report('imprime accept only one element: psfilename') 34 return 35 END 36 ENDCASE 93 37 ;------------------------------------------------------------ 94 ; sauvegarde eventuelle sur gaya, lorsque sauveps ne 0 et que le 95 ; fichier vient d''etre cree 96 ;------------------------------------------------------------ 97 cd, current = olddir 98 cd, psdir 99 spawn,'which "ls"' , ls 100 spawn,ls[n_elements(ls)-1]+' -t *ps' , nomps 101 nomps=nomps[n_elements(nomps)-1] 102 cd, olddir 103 if sauveps NE 0 AND nomps[0] EQ uval.nomfich then begin 104 ;------------------------------------------------------------ 105 ; ds le cas ou sauveps ne 0 et ne 1 on pause une question pour savoir 106 ; si on doit le sauver 107 ;------------------------------------------------------------ 108 if sauveps NE 1 then begin 109 onsauve = report('Voulez-vous sauver le Postscript ?', /defaul_no, /question) 110 if onsauve EQ 0 THEN GOTO, passauver 111 endif 112 ;------------------------------------------------------------ 113 ; on change de nom qd le fichier s''appelle idl.ps 114 ;------------------------------------------------------------ 115 ; qd le fichier s''appelle idl.ps 116 if uval.nomfich eq 'idl.ps' then begin 117 ; on recupere le numero du dernier fichier sauvegarde 118 restore,'derniernumps.dat' 119 ; on lui change de nom : idl.ps en numero.ps 120 spawn, 'cp '+psdir+uval.nomfich+' '+psdir+strtrim(numfichps, 1)+'.ps' 121 nomfichgaya = strtrim(numfichps, 1)+'.ps' 122 ; on incremente le numero 123 numfichps = numfichps+1 124 save,numfichps,filename='derniernumps.dat' 125 ENDIF ELSE nomfichgaya = uval.nomfich 126 ;------------------------------------------------------------ 127 ; on gzip, on envoie sur gaya 128 ;------------------------------------------------------------ 129 spawn, 'gzip '+psdir+nomfichgaya ; on zip 130 spawn, 'maiaput '+psdir+nomfichgaya+'.gz POSTSCRIPT/'+nomfichgaya+'.gz' ; envoie sur gaya 131 if uval.nomfich eq 'idl.ps' then spawn, '\rm '+psdir+nomfichgaya+'.gz' $ ; on efface le fichier zipe 132 ELSE spawn, 'gunzip '+psdir+nomfichgaya+'.gz' ; on dezipe 133 ;------------------------------------------------------------ 134 endif 135 passauver: 136 ;------------------------------------------------------------ 137 ; selection de l''imprimante 138 ;------------------------------------------------------------ 139 case event.value of 140 'Phaser 740 T26':imprimante = 'ph26' 141 'Phaser 740 trans T26':imprimante = 'ph26T' 142 'Phaser 740 R/V T26':imprimante = 'ph26RV' 143 'HP Laser Jet Tour 26':imprimante = 'hpl26' 144 'HP Laser Jet Tour 26 R/V':imprimante = 'hpl26RV' 145 'sparc T26':imprimante = 'sparc' 146 'Phaser 740 T15':imprimante = 'ph15' 147 'Phaser 740 trans T15':imprimante = 'ph15T' 148 'Phaser 740 R/V T15':imprimante = 'ph15RV' 149 'HP Laser Jet Tour 15':imprimante = 'hpl15' 150 'HP Laser Jet Tour 15 R/V':imprimante = 'hpl15RV' 151 'sparc T15':imprimante = 'sparc2' 152 'CX T15':BEGIN & imprimante = 'CX' & GOTO, lodyc & end 153 'CX-trans T15':BEGIN & imprimante = 'CXtrans' & GOTO, lodyc & END 154 'SUN IPSL':imprimante = 'SUN' 155 'QMS-IPSL':imprimante = 'QMS' 156 'QMS-trans-IPSL':imprimante = 'QMS-trans' 157 ELSE: 158 endcase 159 ;------------------------------------------------------------ 160 ; ou je suis ??? 161 ;------------------------------------------------------------ 162 spawn, 'hostname', hostname & hostname = hostname[n_elements(hostname)-1] 163 if hostname EQ 'rhodes' then domainname = 'idris.fr' $ 164 ELSE spawn, 'domainname', domainname 165 domainname = domainname[n_elements(domainname)-1] 166 if domainname NE 'lodyc.jussieu.fr' AND domainname NE 'ipsl.jussieu.fr' $ 167 AND domainname NE 'idris.fr' then return 168 if domainname EQ 'lodyc.jussieu.fr' then GOTO, lodyc 169 ;------------------------------------------------------------ 170 ; choix du reseau surlequel on renvoie : IPSL ou LODYC et 171 ; specification du login, de la machine et du repertoire temporel ds 172 ; les 2 cas 173 ;------------------------------------------------------------ 174 if domainname EQ 'ipsl.jussieu.fr' then begin 175 machipsl = hostname 176 spawn, 'whoami', loginipsl & loginipsl = loginipsl[n_elements(loginipsl)-1] 177 endif 178 if n_elements(loginipsl) NE 0 THEN BEGIN 179 if loginipsl Eq '' THEN GOTO, lodyc 180 login = loginipsl ; si on a un login a l''ipsl et que machipsl n''est pas stipule 181 ; alors on utilise la liaison ATM entre perouse et rhodes. 182 if n_elements(machipsl) EQ 0 then machine = '192.168.111.64' $ 183 ELSE BEGIN 184 if machipsl EQ '' then machine = '192.168.111.64' $ 185 ELSE machine = machipsl+'.ipsl.jussieu.fr' 186 ENDELSE 187 reptemp = '/temp/'+login+'/' 188 ENDIF ELSE BEGIN 189 lodyc: 190 if domainname EQ 'lodyc.jussieu.fr' then begin 191 machlodyc = hostname 192 spawn, 'whoami', loginlodyc & loginlodyc = loginlodyc[n_elements(loginlodyc)-1] 193 endif 194 if n_elements(loginlodyc) EQ 0 THEN BEGIN 195 loginlodyc = xquestion('Quel est votre login au LODYC ?') 196 ENDIF 197 login = loginlodyc 198 machine = machlodyc+'.lodyc.jussieu.fr' 199 reptemp = '/usr/temp/'+login+'/' 200 ; on change le nom des imprimantes qd on est sur le reseau du lodyc 201 case imprimante of 202 'SUN':imprimante = 'sun-ipsl' 203 'QMS':imprimante = 'qms-ipsl' 204 'QMS-trans': imprimante = 'qmst-ipsl' 205 ELSE: 206 endcase 207 ENDELSE 208 ;------------------------------------------------------------ 209 ; je suis deja sur le bon reseau ou il faut faire des rsh? 210 ;------------------------------------------------------------ 211 spawn, 'whoami', whoami & whoami = whoami[n_elements(whoami)-1] 212 if whoami EQ login then BEGIN 213 spawn,'lpr -P'+imprimante+' '+psdir+uval.nomfich 214 spawn,'lpq -P'+imprimante+' -l', info 215 ENDIF ELSE BEGIN 216 ;------------------------------------------------------------ 217 ; copie du Postscript sur le repertoire temporel a jussieu 218 ;------------------------------------------------------------ 219 spawn,'rcp '+psdir+uval.nomfich+' '+login+'@'+machine+':'+reptemp+'.' 220 ;------------------------------------------------------------ 221 ; impression puis destruction du Postscript 222 ;------------------------------------------------------------ 223 ; print, 'rsh '+machine+' -l '+login+' lpr -P'+imprimante+' '+reptemp+uval.nomfich 224 spawn,'rsh '+machine+' -l '+login+' lpr -P'+imprimante+' '+reptemp+uval.nomfich 225 ;------------------------------------------------------------ 226 ; squate de l'imprimante utilisee 227 ;------------------------------------------------------------ 228 ; print, 'rsh '+machine+' -l '+login+' lpq -P'+imprimante+' -l' 229 spawn,'rsh '+machine+' -l '+login+' lpq -P'+imprimante+' -l', info 230 ; 231 ENDELSE 232 xdisplayfile, 'bidon', text = info, title = 'Info impression '+uval.nomfich $ 233 , height = n_elements(info) < 24 234 widget_control, event.top, /destroy ; on tue le widget 235 236 END 237 'quit':widget_control, event.top, /destroy ; on tue le widget 238 239 endcase 240 return 241 end 242 pro imprime,nomfichier,TRANS=trans, NB = nb 243 ; 244 thisOS = strupcase(strmid(!version.os_family, 0, 3)) 245 CASE thisOS OF 246 'MAC':return 247 'WIN':return 248 ELSE: 249 ENDCASE 250 ; 251 @common 252 ;------------------------------------------------------------ 253 ; attribution du nom du fichier a imprimer 254 ;------------------------------------------------------------ 255 CASE N_PARAMS() OF 256 0: BEGIN 257 cd, current = olddir 258 cd, psdir 259 spawn,'which "ls"' , ls 260 spawn,ls[n_elements(ls)-1]+' -t *ps' , nomfich 261 nomfich=nomfich[n_elements(ls)-1] 262 cd, olddir 263 END 264 1: nomfich=nomfichier 265 else: BEGIN 266 ras = report('Mauvais nombre de parametre dans l''appel de IMPRIME') 267 return 268 END 269 endcase 270 ;------------------------------------------------------------ 271 ; on verifie que le fichier est ds le reertoire courant. 272 ; si il n''y est pas et on va voir s''il est sur gaya. 273 ;------------------------------------------------------------ 274 quelsfichiers = findfile(psdir+nomfich) 275 IF quelsfichiers[0] EQ '' THEN BEGIN ; il faut aller chercher le fichier sur gaya 276 spawn, 'whoami', whoami ; login a l''idris 277 ; le fichier zippe existe sur gaya ? 278 spawn,'rsh '+whoami+'@gaya.idris.fr ls POSTSCRIPT/'+nomfich+'.gz', resultat 279 if resultat[n_elements(resultat)-1] NE '' then BEGIN ; s''il existe on le rappatrie 280 gaya = report('le postscript est archive sur gaya. faire le gayaget?', /question, /defualt_no) 281 if gaya EQ 0 then return 282 print, 'gayaget POSTSCRIPT/'+nomfich+'.gz '+nomfich+'.gz ...' 283 spawn, 'gayaget POSTSCRIPT/'+nomfich+'.gz '+nomfich+'.gz' ; on le rappatrie sur rhodes 284 spawn, 'gunzip '+nomfich+'.gz ' ; on le dezippe 285 ENDIF ELSE BEGIN 286 print, 'le fichier '+nomfich+' n''existe pas' 287 print, 'le fichier '+nomfich+'.gz n''existe pas sur gaya ds le repertoire POSTSCRIPT' 288 return 289 ENDELSE 290 ENDIF 291 ;------------------------------------------------------------ 292 ;------------------------------------------------------------ 293 base = widget_base(/row, title = 'fichier Postscript: '+nomfich) 294 rien = cw_bgroup(base, ['Kghostview', 'Ghostview', 'Ghostscript'], /frame, label_top = 'Visualiser' $ 295 , uvalue = {name:'Visualiser', nomfich:nomfich}, /column, /return_name) 296 rien = cw_bgroup(base, ['Phaser 740 T26','Phaser 740 trans T26', 'Phaser 740 R/V T26' $ 297 , 'HP Laser Jet Tour 26', 'HP Laser Jet Tour 26 R/V' $ 298 , 'sparc T26', 'Phaser 740 T15', 'Phaser 740 trans T15' $ 299 , 'Phaser 740 R/V T15', 'CX T15', 'CX-trans T15'$ 300 , 'HP Laser Jet Tour 15', 'HP Laser Jet Tour 15 R/V', 'sparc T15' $ 301 , 'SUN IPSL', 'QMS-IPSL', 'QMS-trans-IPSL'], /frame $ 302 , label_top = 'Imprimer', uvalue = {name:'Imprimer', nomfich:nomfich} $ 303 , /column, /return_name) 304 rien = widget_button(base,value='quit', uvalue={name:'quit'}) 305 ;------------------------------------------------------------ 306 ;execution de la fentre de base et des sous-fenetres 307 widget_control,base,/realize 308 ;------------------------------------------------------------ 309 xmanager,'imprime',base, /no_block 310 ;------------------------------------------------------------ 311 return 312 end 38 return 39 END 313 40 314 41
Note: See TracChangeset
for help on using the changeset viewer.