Meilleure utilisation des fichiers temporaires.
darcs-hash:20050708120633-061a7-fdf70336ee32293071cefe0d8b2924492d3a324e.gz
This commit is contained in:
parent
4c898c21f8
commit
55e53c7219
1 changed files with 5 additions and 5 deletions
|
@ -57,8 +57,9 @@ class cout:
|
||||||
# on compte le nb de copies et on enlève les balises pour ne pas recalculer
|
# on compte le nb de copies et on enlève les balises pour ne pas recalculer
|
||||||
nb_copie_ps=0
|
nb_copie_ps=0
|
||||||
original = open(fichierps)
|
original = open(fichierps)
|
||||||
fichier = tempfile.NamedTemporaryFile().name
|
tmpfichier = tempfile.NamedTemporaryFile()
|
||||||
fic = open(fichier,'w')
|
fichier = tmpfichier.name
|
||||||
|
fic = tmpfichier.file
|
||||||
ligne = original.readline()
|
ligne = original.readline()
|
||||||
while ligne:
|
while ligne:
|
||||||
if ligne.startswith('%%BeginFeature: *PageSize') or ligne.startswith('%%BeginFeature: *PageRegion'):
|
if ligne.startswith('%%BeginFeature: *PageSize') or ligne.startswith('%%BeginFeature: *PageRegion'):
|
||||||
|
@ -87,7 +88,7 @@ class cout:
|
||||||
self.taille=taille
|
self.taille=taille
|
||||||
if not (taille=="A4" or taille=="A3"):
|
if not (taille=="A4" or taille=="A3"):
|
||||||
self.erreur="Taille invalide"
|
self.erreur="Taille invalide"
|
||||||
os.remove(fichier)
|
del tmpfichier
|
||||||
return
|
return
|
||||||
|
|
||||||
if recto_v == "None" or recto_v == "Recto":
|
if recto_v == "None" or recto_v == "Recto":
|
||||||
|
@ -117,8 +118,7 @@ class cout:
|
||||||
c_taille = impression.c_a4
|
c_taille = impression.c_a4
|
||||||
|
|
||||||
(status,rep) = commands.getstatusoutput("nice -n 10 gs -sDEVICE=%s -r100 -dBATCH -dNOPAUSE -dSAFER -dPARANOIDSAFER -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dMaxBitmap=50000000 -sOutputFile='%s' -q '%s'" % (device, fichier+"%d.png", fichier) )
|
(status,rep) = commands.getstatusoutput("nice -n 10 gs -sDEVICE=%s -r100 -dBATCH -dNOPAUSE -dSAFER -dPARANOIDSAFER -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dMaxBitmap=50000000 -sOutputFile='%s' -q '%s'" % (device, fichier+"%d.png", fichier) )
|
||||||
# On n'a plus besoin du fichier temp, donc on le supprime.
|
del tmpfichier
|
||||||
os.remove(fichier)
|
|
||||||
|
|
||||||
if (status != 0):
|
if (status != 0):
|
||||||
self.erreur="ERREUR : Ghostscript : Fichier Postscript invalide.\n"
|
self.erreur="ERREUR : Ghostscript : Fichier Postscript invalide.\n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue