correction pour les noms de fichier. os.path ne comprend pas "\ ". J'ai
entoure le nom du fichier avec des guillemets dans les commandes shell. darcs-hash:20061020152319-f46e9-5693447aa5b32a8e0415ddb78dcf8e4090ffda39.gz
This commit is contained in:
parent
f4bf83a69e
commit
fdd441a6ee
2 changed files with 12 additions and 5 deletions
|
@ -157,8 +157,8 @@ class impression:
|
||||||
def __init__(self, path_to_pdf, adh = None):
|
def __init__(self, path_to_pdf, adh = None):
|
||||||
self._fichier = path_to_pdf
|
self._fichier = path_to_pdf
|
||||||
if not os.path.isfile(path_to_pdf):
|
if not os.path.isfile(path_to_pdf):
|
||||||
raise FichierInvalide, "Fichier invalide"
|
raise FichierInvalide, "Nom de fichier invalide"
|
||||||
os.system("/usr/scripts/impression/compatibilise %s" % path_to_pdf)
|
os.system("/usr/scripts/impression/compatibilise \"%s\"" % path_to_pdf)
|
||||||
|
|
||||||
|
|
||||||
self._adh = adh
|
self._adh = adh
|
||||||
|
@ -324,7 +324,7 @@ class impression:
|
||||||
options += ' -o pdf-level3'
|
options += ' -o pdf-level3'
|
||||||
|
|
||||||
# Pour donner le titre de l'impression
|
# Pour donner le titre de l'impression
|
||||||
options += " -T '%s'" % self._fichier
|
options += " -T '%s'" % self._fichier.replace(' ', '\ ')
|
||||||
|
|
||||||
# Pour donner le login de l'adherent
|
# Pour donner le login de l'adherent
|
||||||
if (self._adh != None):
|
if (self._adh != None):
|
||||||
|
@ -357,7 +357,7 @@ class impression:
|
||||||
options += LPR_OPTIONS[self._settings['couleurs']]
|
options += LPR_OPTIONS[self._settings['couleurs']]
|
||||||
|
|
||||||
|
|
||||||
liste_nom_fichier_pdf=(' '+self._fichier)*self._settings['copies']
|
liste_nom_fichier_pdf=(' "'+self._fichier + "\"")*self._settings['copies']
|
||||||
import commands
|
import commands
|
||||||
#(status,rep) = commands.getstatusoutput("lpr %s %s" % (options, self.nom_fichier_pdf))
|
#(status,rep) = commands.getstatusoutput("lpr %s %s" % (options, self.nom_fichier_pdf))
|
||||||
(status,rep) = commands.getstatusoutput("lpr %s %s" % (options, liste_nom_fichier_pdf))
|
(status,rep) = commands.getstatusoutput("lpr %s %s" % (options, liste_nom_fichier_pdf))
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006 by www.crans.org
|
# Copyright (c) 2006 by www.crans.org
|
||||||
# #############################################################
|
# #############################################################
|
||||||
import sys, time, tempfile, os, commands, string, random
|
import sys, time, tempfile, os, commands, string, random, re
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
import config
|
import config
|
||||||
def __init__():
|
def __init__():
|
||||||
|
@ -59,6 +59,9 @@ class FichierInvalide(Exception):
|
||||||
def base_prix_couleurs(path_fichier_pdf):
|
def base_prix_couleurs(path_fichier_pdf):
|
||||||
# nom_rep seras le dossier dans tmp ou tous les fichier créé par
|
# nom_rep seras le dossier dans tmp ou tous les fichier créé par
|
||||||
# convert seront entreposé
|
# convert seront entreposé
|
||||||
|
|
||||||
|
path_fichier_pdf = re.sub(r"(?<=[^\\]) ", "\\ ", path_fichier_pdf)
|
||||||
|
|
||||||
nom_rep = tempfile.mkdtemp(prefix='tmpimpr')
|
nom_rep = tempfile.mkdtemp(prefix='tmpimpr')
|
||||||
nom_png = "%s/convert.png" % nom_rep # Nom prefixe et chemin des png créé par convert
|
nom_png = "%s/convert.png" % nom_rep # Nom prefixe et chemin des png créé par convert
|
||||||
|
|
||||||
|
@ -103,6 +106,10 @@ def base_prix_couleurs(path_fichier_pdf):
|
||||||
def base_prix_nb(path_fichier_pdf):
|
def base_prix_nb(path_fichier_pdf):
|
||||||
# nom_rep seras le dossier dans tmp ou tous les fichier créé par
|
# nom_rep seras le dossier dans tmp ou tous les fichier créé par
|
||||||
# convert seront entreposé
|
# convert seront entreposé
|
||||||
|
|
||||||
|
# on tranforme les espaces en "\ "
|
||||||
|
path_fichier_pdf = re.sub(r"(?<=[^\\]) ", "\\ ", path_fichier_pdf)
|
||||||
|
|
||||||
nom_rep = tempfile.mkdtemp(prefix='tmpimpr')
|
nom_rep = tempfile.mkdtemp(prefix='tmpimpr')
|
||||||
nom_png = "%s/convert.png" % nom_rep # Nom prefixe et chemin des png créé par convert
|
nom_png = "%s/convert.png" % nom_rep # Nom prefixe et chemin des png créé par convert
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue