diff --git a/impression/impression_canon.py b/impression/impression_canon.py index fb89d4ca..6c388d69 100755 --- a/impression/impression_canon.py +++ b/impression/impression_canon.py @@ -176,7 +176,10 @@ class impression: raise FichierInvalide, ("Le fichier ne semble pas etre un PDF", path_to_pdf) # on compte les pages - self._pages = int(os.popen("pdfinfo %s | grep Pages " % (self._fichier)).readline().split()[1]) + try: + self._pages = int(os.popen("pdfinfo %s | grep Pages " % (self._fichier)).readline().split()[1]) + except Exception, e: + raise FichierInvalide, u"pdfinfo n'arrive à lire le fichier (fichier protégé par mot de passe?)" # calcule le prix de l'encre tout de suite self._calcule_prix() diff --git a/intranet/modules/impression/main.py b/intranet/modules/impression/main.py index dab5daf1..a42c2d3a 100644 --- a/intranet/modules/impression/main.py +++ b/intranet/modules/impression/main.py @@ -33,6 +33,7 @@ from re import compile sys.path.append('/usr/scripts/impression') import digicode, etat_imprimante from impression_canon import FichierInvalide,SoldeInsuffisant,impression +from traceback import format_exception BOOK_REGEXP = compile('book.pdf') FILE_UPLOAD_BASE_FOLDER = cherrypy.config.get('fileUpload.folder', "/var/impression/fichiers/") @@ -41,6 +42,8 @@ class FileError(Exception): pass from ClassesIntranet.ModuleBase import ModuleBase +def fmt_exc(e): + return '
'.join(format_exception(e)) # ############################################################# # Classe d'impression en multithread @@ -225,7 +228,7 @@ class main(ModuleBase): adh = cherrypy.session['LDAP'].getProprio(cherrypy.session['uid']) return {"solde" : adh.solde() } except Exception, e: - return {"erreure" : str(e)} + return {"erreur" : str(e)} AJAXGetSolde.exposed = True diff --git a/intranet/modules/impression/static/impression.js b/intranet/modules/impression/static/impression.js index 9a8bcb09..e3fa38bc 100644 --- a/intranet/modules/impression/static/impression.js +++ b/intranet/modules/impression/static/impression.js @@ -32,7 +32,7 @@ Impression.settings.images = [ "portrait_transparent_couleurs.png", "portrait_transparent_nb.png", ]; - +/* Impression.settings.preloadImage = function(imageName) { var image = new Image(); image.src = "./static/"+imageName; @@ -42,7 +42,7 @@ Impression.settings.preloadAllImages = function() { log("Preloading images..."); map(this.preloadImage,this.images); } - +*/ // //// init : parse every field and display preview // diff --git a/intranet/modules/impression/templates/impression.tmpl b/intranet/modules/impression/templates/impression.tmpl index d2801b3d..8bcfdf60 100644 --- a/intranet/modules/impression/templates/impression.tmpl +++ b/intranet/modules/impression/templates/impression.tmpl @@ -151,7 +151,7 @@ nounous

Impression.settings.init(); //Impression..AJAX.updateSolde(); Impression.AJAX.usefile('$fileName'); - Impression.settings.preloadAllImages(); + /* Impression.settings.preloadAllImages();*/ //--> #else diff --git a/intranet/static/scripts/crans.js b/intranet/static/scripts/crans.js index 72b491f5..c5ee3fe2 100644 --- a/intranet/static/scripts/crans.js +++ b/intranet/static/scripts/crans.js @@ -4,8 +4,8 @@ * Si firebug est présent, utilisation de la console intégrée * à la place de celle de MockieKit */ -try { - if (console.firebug) { +try { +/* if (console.firebug) { log("Using Firebug console"); log = function(m) {console.log(m)}; logWarning = function(m){console.warn(m)}; @@ -13,7 +13,10 @@ try { logDebug = function(m){console.debug(m)}; logError = function(m){console.error(m)}; logFatal = function(m){console.error(m)}; - } } + } +*/ +MochiKit.Logging.logger.useNativeConsole = true +} catch (Exception) {} @@ -35,7 +38,7 @@ Crans.messages.initialized = false; Crans.messages.init = function() { - if (!Crans.messages.initialized) + if (!Crans.messages.initialized) { //updateNodeAttributes(document.body, {'onclick':'Crans.messages.setMessage();'}); appendChildNodes(document.body, DIV({'id':'_crans_main_message_place_holder'})); @@ -45,14 +48,14 @@ Crans.messages.init = function() } -Crans.messages.setMessage = function(m, messageClass) +Crans.messages.setMessage = function(m, messageClass) { if (!Crans.messages.initialized) Crans.messages.init(); if (m == null) { var messageBox = ''; } else { - if (messageClass==null) + if (messageClass==null) messageClass='message'; if (messageClass == "errorMessage") logWarning(m); @@ -66,8 +69,8 @@ Crans.messages.setMessage = function(m, messageClass) var messagePlace = document.getElementById("_crans_main_message_place_holder"); replaceChildNodes(messagePlace,messageBox); try {roundElement(messageBox);} catch (error) {} - } - catch (error) { + } + catch (error) { logError("élement _crans_main_message_place_holder introuvable") return } @@ -94,7 +97,7 @@ Crans.loading.display = function(bool) { if (!Crans.loading.initialized) Crans.loading.init(); var loadingEl = document.getElementById("_crans_main_message_chargement"); - if (loadingEl) { + if (loadingEl) { if (bool) { appear(loadingEl); } else { @@ -112,37 +115,37 @@ Crans.keys = {} Crans.keys.handled = false; -Crans.keys.handleF1 = function() +Crans.keys.handleF1 = function() { createLoggingPane(true); }; -Crans.keys.keyMap = +Crans.keys.keyMap = { 'KEY_F1': Crans.keys.handleF1 // , 'KEY_ESCAPE':alert }; -connect(document, 'onkeydown', - function(e) +connect(document, 'onkeydown', + function(e) { - // We're storing a handled flag to work around a Safari bug: - if (true)//(!Crans.keys.handled) + // We're storing a handled flag to work around a Safari bug: + if (true)//(!Crans.keys.handled) { - + var key = e.key(); var fn = Crans.keys.keyMap[key.string]; - if (fn) + if (fn) { fn(); } - + //replaceChildNodes('onkeydown_code', key.code); //replaceChildNodes('onkeydown_string', key.string); //KeyEvents.updateModifiers(e); } - + Crans.keys.handled = true; } ); \ No newline at end of file