Encore reimporter ces trucs pour on ne sais quelle raison
darcs-hash:20050614172004-c3cc4-0a23476a0a94e0a1fd514734d19f74ace6e0cdb4.gz
This commit is contained in:
parent
08f772d84e
commit
bc7fab26cd
2 changed files with 121 additions and 0 deletions
61
impression/filter/crans_pdftops
Executable file
61
impression/filter/crans_pdftops
Executable file
|
@ -0,0 +1,61 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: iso-8859-15 -*-
|
||||
#
|
||||
# Filtre CRANS nettoant les postscripts
|
||||
# Codé par Braice
|
||||
# Licence : GNU General Public Licence, version 2
|
||||
|
||||
import sys,os
|
||||
import tempfile
|
||||
|
||||
|
||||
sys.stderr.write("DEBUG: Debut du filtre PDF2PS\n.\n.\n.\n.\n.\n.\n.\n.\n.\n")
|
||||
tmpdir=os.getenv('TMPDIR')
|
||||
sys.stderr.write("DEBUG: Répertoire temporaire : %s\n" % tmpdir)
|
||||
|
||||
if len(sys.argv) == 1 :
|
||||
print '%s devis "Crans" "Mail un devis au demandeur"' % sys.argv[0]
|
||||
sys.exit(0)
|
||||
|
||||
if len(sys.argv) not in (6, 7) :
|
||||
sys.stderr.write("ERROR: %s job-id user title copies options [file]\n" % sys.argv[0])
|
||||
sys.exit(1) # Cela stoppe l'imprimante
|
||||
|
||||
if len(sys.argv) == 7 :
|
||||
# Fichier fourni
|
||||
sys.stderr.write("DEBUG: lecture depuis %s\n" % sys.argv[-1])
|
||||
entree = sys.argv[-1]
|
||||
else :
|
||||
# Lecture sur stdin
|
||||
sys.stderr.write("DEBUG: Lecture depuis stdin\n")
|
||||
entree_fic = tempfile.NamedTemporaryFile(dir=tmpdir)
|
||||
entree = entree_fic.name
|
||||
ligne=sys.stdin.readline()
|
||||
while ligne:
|
||||
entree_fic.write(ligne)
|
||||
ligne = sys.stdin.readline()
|
||||
entree_fic.flush()
|
||||
|
||||
|
||||
if sys.argv[5].find('PageSize') == -1 :
|
||||
sys.stderr.write("DEBUG: Pas de pagesize, on froce du A4\n")
|
||||
sys.argv[5]+=' PageSize=A4'
|
||||
|
||||
temp_fic = tempfile.NamedTemporaryFile(dir=tmpdir)
|
||||
|
||||
|
||||
sys.stderr.write("DEBUG: On envoie a pdf2ps\n")
|
||||
|
||||
os.system("/usr/bin/pdf2ps %s %s 1>&2" %(entree,temp_fic.name))
|
||||
|
||||
if len(sys.argv) == 7 :
|
||||
sys.argv[6]=temp_fic.name
|
||||
else:
|
||||
sys.argv.append(temp_fic.name)
|
||||
|
||||
sys.stderr.write("DEBUG: On envoie au filtre normal\n")
|
||||
|
||||
os.spawnv('P_WAIT', '/usr/lib/cups/filter/pstops',sys.argv)
|
||||
|
||||
sys.stderr.write("DEBUG: Fin du filtre pdftops\n")
|
||||
|
60
impression/filter/crans_pstops
Executable file
60
impression/filter/crans_pstops
Executable file
|
@ -0,0 +1,60 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: iso-8859-15 -*-
|
||||
#
|
||||
# Filtre CRANS nettoant les postscripts
|
||||
# Codé par Braice
|
||||
# Licence : GNU General Public Licence, version 2
|
||||
|
||||
import sys,os
|
||||
import tempfile
|
||||
|
||||
|
||||
sys.stderr.write("ERROR: Debut du filtre\n.\n.\n.\n.\n.\n.\n.\n.\n.\n")
|
||||
tmpdir=os.getenv('TMPDIR')
|
||||
sys.stderr.write("DEBUG: Répertoire temporaire : %s\n" % tmpdir)
|
||||
|
||||
if len(sys.argv) == 1 :
|
||||
print '%s devis "Crans" "Mail un devis au demandeur"' % sys.argv[0]
|
||||
sys.exit(0)
|
||||
|
||||
if len(sys.argv) not in (6, 7) :
|
||||
sys.stderr.write("ERROR: %s job-id user title copies options [file]\n" % sys.argv[0])
|
||||
sys.exit(1) # Cela stoppe l'imprimante
|
||||
|
||||
if len(sys.argv) == 7 :
|
||||
# Fichier fourni
|
||||
sys.stderr.write("DEBUG: lecture depuis %s\n" % sys.argv[-1])
|
||||
entree = sys.argv[-1]
|
||||
else :
|
||||
# Lecture sur stdin
|
||||
sys.stderr.write("DEBUG: Lecture depuis stdin\n")
|
||||
entree_fic = tempfile.NamedTemporaryFile(dir=tmpdir)
|
||||
entree = entree_fic.name
|
||||
ligne=sys.stdin.readline()
|
||||
while ligne:
|
||||
entree_fic.write(ligne)
|
||||
ligne = sys.stdin.readline()
|
||||
entree_fic.flush()
|
||||
|
||||
|
||||
|
||||
if sys.argv[5].find('PageSize') == -1 :
|
||||
sys.stderr.write("DEBUG: Pas de pagesize, on froce du A4\n")
|
||||
sys.argv[5]+=' PageSize=A4'
|
||||
|
||||
sys.stderr.write("DEBUG: On envoie a ps2ps\n")
|
||||
|
||||
temp_fic = tempfile.NamedTemporaryFile(dir=tmpdir)
|
||||
|
||||
os.system("/usr/bin/ps2ps %s %s 1>&2" % (entree,temp_fic.name))
|
||||
|
||||
if len(sys.argv) == 7 :
|
||||
sys.argv[6]=temp_fic.name
|
||||
else:
|
||||
sys.argv.append(temp_fic.name)
|
||||
|
||||
sys.stderr.write("DEBUG: On envoie au filtre normal\n")
|
||||
|
||||
os.spawnv('P_WAIT', '/usr/lib/cups/filter/pstops',sys.argv)
|
||||
|
||||
sys.stderr.write("DEBUG: Fin du filtre\n")
|
Loading…
Add table
Add a link
Reference in a new issue