[print_status.py] notif pour les jobs via wrapper
Il reste un bug de notification pour le club Crans: la liste des imprimeurs de ce club semble vide. En attendant, le cron va envoyer des mails si ça arrive.
This commit is contained in:
parent
ebe94de094
commit
2ca9b45851
3 changed files with 14 additions and 4 deletions
|
@ -177,8 +177,11 @@ def do_print(args):
|
||||||
cook = requests.get(build_url('root')).cookies
|
cook = requests.get(build_url('root')).cookies
|
||||||
syslog('Sending pdf (%d bytes)...' % os.stat(temppdf.name).st_size)
|
syslog('Sending pdf (%d bytes)...' % os.stat(temppdf.name).st_size)
|
||||||
temppdf.seek(0)
|
temppdf.seek(0)
|
||||||
|
filename = args.jobname
|
||||||
|
if not filename.endswith('.pdf'):
|
||||||
|
filename += '.pdf'
|
||||||
req = requests.post(build_url('do_print'), cookies=cook, data=opt,
|
req = requests.post(build_url('do_print'), cookies=cook, data=opt,
|
||||||
files={'File': (args.jobname + '.pdf', temppdf)})
|
files={'File': (filename, temppdf)})
|
||||||
#files={'File': (args.jobname + '.pdf', proc.stdout)})
|
#files={'File': (args.jobname + '.pdf', proc.stdout)})
|
||||||
temppdf.close()
|
temppdf.close()
|
||||||
if "ms_err.gif" in req.text:
|
if "ms_err.gif" in req.text:
|
||||||
|
|
|
@ -39,5 +39,5 @@ class impression(impression_canon.impression):
|
||||||
opt += ['--duplex-type', 'one-sided']
|
opt += ['--duplex-type', 'one-sided']
|
||||||
opt += ['--staple-position', self._settings['agrafage']]
|
opt += ['--staple-position', self._settings['agrafage']]
|
||||||
opt.append(self._fichier)
|
opt.append(self._fichier)
|
||||||
self.log.info("Impression(%d) : %s" % (self._jid, repr(opt)))
|
self.log.info("Impression(%d) : %s" % (self._jid, " ".join(opt)))
|
||||||
subprocess.Popen(['/usr/scripts/impression/canon_wrapper.py'] + opt)
|
subprocess.Popen(['/usr/scripts/impression/canon_wrapper.py'] + opt)
|
||||||
|
|
|
@ -136,9 +136,13 @@ tasks_to_treat.reverse()
|
||||||
|
|
||||||
for item in tasks_to_treat:
|
for item in tasks_to_treat:
|
||||||
fields = item.split(',', 6)
|
fields = item.split(',', 6)
|
||||||
if fields[3].strip('"') == "root":
|
if fields[3].strip('"') in ["root",'DIRECT PRINT']:
|
||||||
result = fields[1].strip('"')
|
result = fields[1].strip('"')
|
||||||
taskID, user, _ = fields[2].strip('"').split(':',2)
|
jobinfos = fields[2].strip('"').split(':', 2)
|
||||||
|
if len(jobinfos) <= 2:
|
||||||
|
print "Skipping: %s" % fields[2]
|
||||||
|
continue
|
||||||
|
taskID, user, _ = jobinfos
|
||||||
user = user.split('@').pop() # On récupère le nom du club si besoin.
|
user = user.split('@').pop() # On récupère le nom du club si besoin.
|
||||||
date = buildDate(fields[5])
|
date = buildDate(fields[5])
|
||||||
match_taskID = re.compile(r"impression\(%s\)" % taskID)
|
match_taskID = re.compile(r"impression\(%s\)" % taskID)
|
||||||
|
@ -155,6 +159,9 @@ for item in tasks_to_treat:
|
||||||
target = db_query['club'][0]
|
target = db_query['club'][0]
|
||||||
full_name = u"Club " + target.nom()
|
full_name = u"Club " + target.nom()
|
||||||
send_to = map(lambda aid : db.search("aid=" + aid)['adherent'][0].mail(), target.imprimeurs())
|
send_to = map(lambda aid : db.search("aid=" + aid)['adherent'][0].mail(), target.imprimeurs())
|
||||||
|
if send_to == []:
|
||||||
|
print "Skipping sending to %s, empty recipient" % full_name
|
||||||
|
continue
|
||||||
historique = target.historique()
|
historique = target.historique()
|
||||||
historique.reverse() # Ce qu'on cherche a des chances d'être récent et donc d'être à la fin de l'historique.
|
historique.reverse() # Ce qu'on cherche a des chances d'être récent et donc d'être à la fin de l'historique.
|
||||||
file_dirname = files_directory + user + r"/"
|
file_dirname = files_directory + user + r"/"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue