Commit fbd4c242 authored by Antoine Durand-Gasselin's avatar Antoine Durand-Gasselin
Browse files

[impresion, intranet/impression] on relinke correctement

darcs-hash:20090518195027-bd074-77ce9fbfa381a4dd60a3cf75f2acac609e95a9e9.gz
parent f9343f33
......@@ -5,7 +5,7 @@
Rcupre, filtre et formate l'tat actuel de l'imprimante
Copyright (c) 2006 by www.crans.org
Copyright (c) 2006, 2007, 2008, 2009 by Cr@ns (http://www.crans.org)
"""
......@@ -20,17 +20,29 @@ class ErreurCommunication(Exception):
pass
def etat():
exec ("etat_%s()" % impression.imprimante)
exec ("a = etat_%s()" % impression.imprimante)
return a
def etat_canon():
_dico = {
'idle(3)\nrunning(2)' : u'Pas configur comme une imprimante',
'printing(4)\nrunning(2)' : u'Impression en cours',
'other(1)\ndown(5)' : u"Erreur [grave] de l'imprimante",
'other(1)\nrunning(2)' : u'Imprimante en veille',
'warmup(5)\nrunning(2)' : u'Imprimante en attente',
'idle(3)\nwarning(3)' : u'Warning: ne fonctionne pas',
'printing(4)\nwarning(3)' : u'Warning: imprime (mais warning)',
}
try:
liste_msg = []
msg = liste_msg = []
comm = snmp(host="imprimante.adm.crans.org", version="1", community="public")
for oid in [".hrPrinterStatus.1", ".hrPrinterDetectedErrorState.1"]:
msg = comm.get_string(oid)
if msg: liste_msg.append(msg)
for oid in [".hrPrinterStatus.1", ".hrDeviceStatus.1"]:
#".hrPrinterDetectedErrorState.1"
msg.append(comm.get_string(oid))
liste_msg = [ _dico['\n'.join(msg)] ]
except Exception,err:
liste_msg.append("[%s]" % unicode(err))
return liste_msg
def etat_laserjet():
......
#! /usr/bin/env python
import cherrypy, tempfile, shutil, os
import crans.impression
import crans.impression.digicode
import crans.cp
import cherrypy, tempfile, shutil, os, sys
sys.path.append('/usr/scripts/impression')
import crans.cp, digicode
from ClassesIntranet.ModuleBase import ModuleBase
......@@ -36,7 +36,7 @@ class main(ModuleBase):
#
def codeList(self):
try:
listeBrute = crans.impression.digicode.list_code()
listeBrute = digicode.list_code()
liste_formatee = []
for aCode in listeBrute:
age = aCode[1]
......@@ -70,9 +70,9 @@ class main(ModuleBase):
raise
except:
return {'formatErreur':1}
code = crans.impression.digicode.save_code(code, adherent)
code = digicode.save_code(code, adherent)
else:
code = crans.impression.digicode.gen_code(adherent)
code = digicode.gen_code(adherent)
crans.cp.log("code cree : %s" % code, 'DIGICODE')
return {'code': code, "age" : "new", "desc":adherent}
except Exception, e:
......
#import crans.impression
#import digicode
<div id="globalDiv">
<h1>Gestion des codes pour le local impression</h1>
......
......@@ -21,7 +21,7 @@
#
# interface d'impression
#
# Copyright (c) 2006 by www.crans.org
# Copyright (c) 2006, 2007, 2008, 2009 by Cr@ns (http://www.crans.org)
# #############################################################
import cherrypy, tempfile, shutil, os, commands, sys
......@@ -30,7 +30,7 @@ import crans.cp
from threading import Thread
from re import compile
os.append('/usr/scripts/impression')
sys.path.append('/usr/scripts/impression')
import digicode, etat_imprimante
from impression_canon import FichierInvalide,SoldeInsuffisant,impression
......@@ -93,7 +93,7 @@ class main(ModuleBase):
data['fileList'] = self.getUploadedFileListFor(cherrypy.session['uid'])
try:
crans.impression.etat_imprimante.etat()
etat_imprimante.etat()
except Exception, e:
data['Erreur_imprimante'] = str(e).replace("\"", "\\\"")
data['errorMsg'] = u"Imprimante injoignable"
......@@ -147,7 +147,7 @@ class main(ModuleBase):
#
def codeList(self):
try:
listeBrute = crans.impression.digicode.list_code()
listeBrute = digicode.list_code()
# liste de la forme :
# [(code, age, description),...]
listeBrute = [item[0] for item in listeBrute if item[2] == cherrypy.session['uid']]
......@@ -203,7 +203,7 @@ class main(ModuleBase):
return {"erreur":str(e)}
crans.cp.log("impression", 'IMPRESSION')
return {
'code':str(crans.impression.digicode.gen_code(cherrypy.session['uid'])) + "#",
'code':str(digicode.gen_code(cherrypy.session['uid'])) + "#",
'code_bat_j': cherrypy.config.get('crans.impression.codes.batJ', u"Non disponible")
}
lancerImpression.exposed = True
......@@ -215,7 +215,7 @@ class main(ModuleBase):
if not cherrypy.config.get('crans.activate', True):
return {"printer_state" : u"Systme down"}
try:
return {"printer_state" : u"\\n".join(crans.impression.etat_imprimante.etat())}
return {"printer_state" : u"\\n".join(etat_imprimante.etat())}
except Exception, e:
return {"printer_state" : 'Imprimante hors ligne'}
etatImprimante.exposed = True
......
#import crans.impression
#import impression_canon
#if $getVar('errorMsg',False)
<script type="text/javascript">
......@@ -32,14 +32,14 @@ Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
<label for="papier" class="labelInput">Papier:</label>
<select name="papier" id="papier" class="selectOne" onchange="Impression.settings.update(this);">
#for type_papier in ['A4', 'A3']
<option value="$type_papier">$crans.impression.impression_canon.DICT_PAPIER[type_papier]</option>
<option value="$type_papier">$impression_canon.DICT_PAPIER[type_papier]</option>
#end for
</select>
<br />
<label for="agrafage" class="labelInput">Agrafes:</label>
<select name="agrafage" id="agrafage" class="selectOne" onchange="Impression.settings.update(this);">
#for type_agrafes in $crans.impression.impression_canon.DICT_AGRAFAGE.keys()
<option value="$type_agrafes">$crans.impression.impression_canon.DICT_AGRAFAGE[type_agrafes]</option>
#for type_agrafes in $impression_canon.DICT_AGRAFAGE.keys()
<option value="$type_agrafes">$impression_canon.DICT_AGRAFAGE[type_agrafes]</option>
#end for
</select>
<br />
......@@ -67,7 +67,8 @@ Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
<div class="clear bouttons">
<input type="reset" value="Reset" onclick="Impression.settings.reset();return false;" />
<input type="button" value="Devis" onclick="window.open('devis')" />
<!-- <input type="button" value="Devis"
onclick="window.open('devis')" /> -->
<input type="button" value="Imprimer" onclick="Impression.AJAX.lancerImpression();"/>
</div>
</fieldset>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment