- fax jobs can be given an addressee and a subject now (resolves #18, reported

by Achim Bohnet)


git-svn-id: https://svn.ibp.de/svn/capisuite/trunk/capisuite@135 4ebea2bb-67d4-0310-8558-a5799e421b66
This commit is contained in:
gernot 2003-06-26 11:53:17 +00:00
parent e79f3f0d09
commit 72fc7cf0ad
5 changed files with 95 additions and 43 deletions

3
NEWS
View File

@ -17,6 +17,9 @@
* scripts: number of needed tries reported after sending a fax was * scripts: number of needed tries reported after sending a fax was
wrong (bug #29, thx to Eckhard Rüggeberg) wrong (bug #29, thx to Eckhard Rüggeberg)
* scripts: fax jobs can be given a literal addressee and a subject
for informational purposes now (bug #18 reported by Achim Bohnet)
0.4.2 (CVS tag CAPISUITE_042): 0.4.2 (CVS tag CAPISUITE_042):
============================== ==============================
* manual now available as PDF * manual now available as PDF

View File

@ -794,7 +794,7 @@ make install</screen>
<term><option>dial_prefix=""</option></term> <term><option>dial_prefix=""</option></term>
<listitem> <listitem>
<para>Wenn hier etwas angegeben ist, wird es als Präfix vor jede Nummer <para>Wenn hier etwas angegeben ist, wird es als Präfix vor jede Nummer
eingefügt, die an <command>capisuitefax</command> übergeben wird. eingefügt, die an <command>capisuitefax</command> übergeben wird.
Dies ist z.B. sehr nützlich, wenn Ihr ISDN-Adapter an einer Telefonanlage Dies ist z.B. sehr nützlich, wenn Ihr ISDN-Adapter an einer Telefonanlage
hängt, die eine "0" für externe Anrufe benötigt. Es kann aber auch später hängt, die eine "0" für externe Anrufe benötigt. Es kann aber auch später
für ein einzelnes Fax-Dokument deaktiviert werden, sodass diese Einstellung für ein einzelnes Fax-Dokument deaktiviert werden, sodass diese Einstellung
@ -1206,9 +1206,10 @@ make install</screen>
<para><command>capisuitefax</command> kennt die folgenden Optionen:</para> <para><command>capisuitefax</command> kennt die folgenden Optionen:</para>
<screen>capisuitefax [-q] [-n] [-u username] -d dialstring file1 [file2...]</screen> <screen>capisuitefax [-q] [-n] [-u user] [-A addr] [-S subj] -d number file1 [file2...]</screen>
<screen>capisuitefax [-q] -a id</screen> <screen>capisuitefax [-q] -a id</screen>
<screen>capisuitefax [-h] [-l]</screen> <screen>capisuitefax -l</screen>
<screen>capisuitefax -h</screen>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><option>-a id</option></term> <term><option>-a id</option></term>
@ -1216,6 +1217,12 @@ make install</screen>
Auftrags zu ermittelen, können Sie die Option <option>-l</option> Auftrags zu ermittelen, können Sie die Option <option>-l</option>
verwenden.</para></listitem> verwenden.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-A adr</option></term>
<listitem><para>Der Adressat des Faxes. Diese Angabe dient (zur Zeit) nur
zur leichteren Identifikation eines Jobs. Sie wird in der versandten Status-Mail
später zitiert.</para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-d dialstring</option></term> <term><option>-d dialstring</option></term>
<listitem><para>Die Nummer, die angerufen werden soll (Empfänger des Faxes). <listitem><para>Die Nummer, die angerufen werden soll (Empfänger des Faxes).
@ -1232,7 +1239,7 @@ make install</screen>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>-n</option></term> <term><option>-n</option></term>
<listitem><para>Nicht den konfigurierten Präfix für diesen Auftrag verwenden. <listitem><para>Nicht den konfigurierten Präfix für diesen Auftrag verwenden.
Dies ist nützlich für interne Aufträge.</para></listitem> Dies ist nützlich für interne Aufträge.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -1240,6 +1247,12 @@ make install</screen>
<listitem><para>Sei still, gib keine informativen Meldungen aus! <listitem><para>Sei still, gib keine informativen Meldungen aus!
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-S subj</option></term>
<listitem><para>Der Betreff des Faxes. Diese Angabe dient (zur Zeit) nur
zur leichteren Identifikation eines Jobs. Sie wird in der versandten Status-Mail
später zitiert.</para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-u user</option></term> <term><option>-u user</option></term>
<listitem><para> <listitem><para>
@ -1250,7 +1263,7 @@ make install</screen>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>file1 [file2...]</option></term> <term><option>file1 [file2...]</option></term>
<listitem><para>Eine oder mehrere PostScript-Dateien, die an diesen Empfänger <listitem><para>Eine oder mehrere PostScript-Dateien, die an diesen Empfänger
verschickt werden sollen. Mehrere PostScript-Dateien erzeugen mehrere separate verschickt werden sollen. Mehrere PostScript-Dateien erzeugen mehrere separate
Fax-Aufträge). Fax-Aufträge).
</para></listitem> </para></listitem>

View File

@ -1051,9 +1051,10 @@ make install</screen>
<para>The following options are recognized by <command>capisuitefax</command>:</para> <para>The following options are recognized by <command>capisuitefax</command>:</para>
<screen>capisuitefax [-q] [-n] [-u username] -d dialstring file1 [file2...]</screen> <screen>capisuitefax [-q] [-n] [-u user] [-A adr] [-S subj] -d number file1 [file2 ...]</screen>
<screen>capisuitefax [-q] -a id</screen> <screen>capisuitefax [-q] -a id</screen>
<screen>capisuitefax [-h] [-l]</screen> <screen>capisuitefax -h</screen>
<screen>capisuitefax -l</screen>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><option>-a id</option></term> <term><option>-a id</option></term>
@ -1061,7 +1062,12 @@ make install</screen>
option.</para></listitem> option.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>-d dialstring</option></term> <term><option>-A adr</option></term>
<listitem><para>The addressee of the fax. This option is (currently) only
for informational purposes and will be quoted in the sent status mail.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-d number</option></term>
<listitem><para>The number which should be called (destination of the fax)</para></listitem> <listitem><para>The number which should be called (destination of the fax)</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -1080,6 +1086,11 @@ make install</screen>
<term><option>-q</option></term> <term><option>-q</option></term>
<listitem><para>Be quiet, don't output informational messages</para></listitem> <listitem><para>Be quiet, don't output informational messages</para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-S subj</option></term>
<listitem><para>A subject for the fax. This option is (currently) only
for informational purposes and will be quoted in the sent status mail.</para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-u user</option></term> <term><option>-u user</option></term>
<listitem><para> <listitem><para>

View File

@ -4,7 +4,7 @@
# --------------------------------------------------- # ---------------------------------------------------
# copyright : (C) 2002 by Gernot Hillier # copyright : (C) 2002 by Gernot Hillier
# email : gernot@hillier.de # email : gernot@hillier.de
# version : $Revision: 1.5 $ # version : $Revision: 1.6 $
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -16,6 +16,8 @@ import getopt,os,sys,re,time,pwd,errno,fcntl,string
import cs_helpers import cs_helpers
dialstring="" dialstring=""
addressee=""
subject=""
abort="" abort=""
user="" user=""
quiet=0 quiet=0
@ -26,20 +28,26 @@ def usage(error=""):
print """capisuitefax - capisuite tool for enqueueing faxes print """capisuitefax - capisuite tool for enqueueing faxes
usage: usage:
capisuitefax [-q] [-n] [-u <user>] -d <dial> file1 [file2...] or capisuitefax [<send options>] -d <number> file1 [file2...] or
capisuitefax [-q] -a <id> or capisuitefax [-q] -a <id>
capisuitefax [-h] [-l] capisuitefax -l
capisuitefax -h
possible options are: possible send options are:
-a <id>, --abort=<id> abort fax job with id (id is a number) -d <dial>, --dialstring=<dial> send fax to this number (mandatory)
-d <dial>, --dialstring=<dial> send fax to this number
-h, --help print this usage information
-l, --list print jobs in the send queue
-n, --noprefix ignore configured dial prefix for this call -n, --noprefix ignore configured dial prefix for this call
(for internal calls) (for internal calls)
-u <user>, --user=<user> send fax as <user> (only when called as root!) -u <user>, --user=<user> send fax as <user> (only when called as root!)
-A <addr>, --addressee=<addr> addressee (for informational purposes)
-S <subj>, --subject=<subj> some subject (for informational purposes)
other options:
-q, --quiet be quiet, don't output informational messages -q, --quiet be quiet, don't output informational messages
-a <id>, --abort=<id> abort fax job with id (id is a number)
-h, --help print this usage information
-l, --list print jobs in the send queue
The given files must be in Adobe PostScript format""" The given files must be in Adobe PostScript format"""
if (error!=""): if (error!=""):
@ -54,7 +62,7 @@ def showlist(config,user):
sys.exit(1) sys.exit(1)
sendq=os.path.join(sendq,user,"sendq")+"/" sendq=os.path.join(sendq,user,"sendq")+"/"
print "ID Number Tries Next try" print "ID Nr./Addressee Tries Next try Subject"
files=os.listdir(sendq) files=os.listdir(sendq)
files=filter (lambda s: re.match("fax-.*\.txt",s),files) files=filter (lambda s: re.match("fax-.*\.txt",s),files)
@ -65,13 +73,15 @@ def showlist(config,user):
control=cs_helpers.readConfig(sendq+job) control=cs_helpers.readConfig(sendq+job)
sys.stdout.write(re.match("fax-([0-9]+)\.txt",job).group(1)) sys.stdout.write(re.match("fax-([0-9]+)\.txt",job).group(1))
sys.stdout.write("\t") sys.stdout.write("\t")
sys.stdout.write(control.get("GLOBAL","dialstring")) dest=cs_helpers.getOption(control,"GLOBAL","addressee","")
if (len(control.get("GLOBAL","dialstring"))<8): if (dest==""):
dest=control.get("GLOBAL","dialstring")
sys.stdout.write(dest+"\t")
if (len(dest)<8):
sys.stdout.write("\t") sys.stdout.write("\t")
sys.stdout.write("\t") sys.stdout.write(control.get("GLOBAL","tries")+"\t")
sys.stdout.write(control.get("GLOBAL","tries")) sys.stdout.write(control.get("GLOBAL","starttime")+"\t")
sys.stdout.write("\t\t") sys.stdout.write(cs_helpers.getOption(control,"GLOBAL","subject","")+"\n")
sys.stdout.write(control.get("GLOBAL","starttime")+"\n")
sys.exit(0) sys.exit(0)
@ -99,10 +109,10 @@ def abortjob(config,user,job):
if (err.errno in (errno.EACCES,errno.EAGAIN)): if (err.errno in (errno.EACCES,errno.EAGAIN)):
print "Job is currently in transmission. Can't abort." print "Job is currently in transmission. Can't abort."
try: try:
optlist,args = getopt.getopt(sys.argv[1:], "d:a:u:lhqn" optlist,args = getopt.getopt(sys.argv[1:], "d:a:u:lhqnA:S:"
,['dialstring=','noprefix','help',"abort=","list","quiet","user="]) ,['dialstring=','noprefix','help',"abort=","list","quiet","user=",
'addressee=','subject='])
except getopt.GetoptError, e: except getopt.GetoptError, e:
usage(e.msg) usage(e.msg)
@ -110,6 +120,8 @@ except getopt.GetoptError, e:
# read options # read options
for option,param in optlist: for option,param in optlist:
if option in ('-d','--dialstring'): dialstring=param if option in ('-d','--dialstring'): dialstring=param
if option in ('-A','--addressee'): addressee=param
if option in ('-S','--subject'): subject=param
if option in ('-n','--noprefix'): useprefix=0 if option in ('-n','--noprefix'): useprefix=0
if option in ('-h','--help'): usage() if option in ('-h','--help'): usage()
if option in ('-l','--list'): listqueue=1 if option in ('-l','--list'): listqueue=1
@ -190,7 +202,8 @@ for i in args:
cs_helpers.writeDescription(newname,"dialstring=\""+dialstring+"\"\n" cs_helpers.writeDescription(newname,"dialstring=\""+dialstring+"\"\n"
+"starttime=\""+time.ctime()+"\"\ntries=\"0\"\n" +"starttime=\""+time.ctime()+"\"\ntries=\"0\"\n"
+"user=\""+user+"\"\n") +"user=\""+user+"\"\naddressee=\""+addressee+"\"\nsubject=\""
+subject+"\"\n")
os.chmod(newname,0600) os.chmod(newname,0600)
os.chmod(newname[:-3]+"txt",0600) os.chmod(newname[:-3]+"txt",0600)
if (os.getuid()==0): if (os.getuid()==0):

View File

@ -2,7 +2,7 @@
# --------------------------------------------- # ---------------------------------------------
# copyright : (C) 2002 by Gernot Hillier # copyright : (C) 2002 by Gernot Hillier
# email : gernot@hillier.de # email : gernot@hillier.de
# version : $Revision: 1.7 $ # version : $Revision: 1.8 $
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -87,6 +87,8 @@ def idle(capi):
tries=control.getint("GLOBAL","tries") tries=control.getint("GLOBAL","tries")
dialstring=control.get("GLOBAL","dialstring") dialstring=control.get("GLOBAL","dialstring")
addressee=cs_helpers.getOption(control,"GLOBAL","addressee","")
subject=cs_helpers.getOption(control,"GLOBAL","subject","")
mailaddress=cs_helpers.getOption(config,user,"fax_email","") mailaddress=cs_helpers.getOption(config,user,"fax_email","")
if (mailaddress==""): if (mailaddress==""):
mailaddress=user mailaddress=user
@ -99,11 +101,14 @@ def idle(capi):
if (result in (0,0x3400,0x3480,0x3490) and resultB3==0): if (result in (0,0x3400,0x3480,0x3490) and resultB3==0):
movejob(job_fax,sendq,done,user) movejob(job_fax,sendq,done,user)
capisuite.log("job "+job_fax+": finished successfully",1) capisuite.log("job "+job_fax+": finished successfully",1)
cs_helpers.sendSimpleMail(user,mailaddress,"Fax to "+dialstring+" sent successfully.", mailtext="Your fax job to "+addressee+" ("+dialstring+") was sent successfully.\n\n" \
"Your fax job to "+dialstring+" was sent successfully.\n\n" +"Subject: "+subject+"\nFilename: "+job_fax \
+"Filename: "+job_fax+"\nNeeded tries: "+str(tries) +"\nNeeded tries: "+str(tries) \
+("\nLast result: 0x%x/0x%x" % (result,resultB3)) +("\nLast result: 0x%x/0x%x" % (result,resultB3)) \
+"\n\nIt was moved to file://"+done+user+"-"+job_fax) +"\n\nIt was moved to file://"+done+user+"-"+job_fax
cs_helpers.sendSimpleMail(user,mailaddress,
"Fax to "+addressee+" ("+dialstring+") sent successfully.",
mailtext)
else: else:
max_tries=int(cs_helpers.getOption(config,"","send_tries","10")) max_tries=int(cs_helpers.getOption(config,"","send_tries","10"))
delays=cs_helpers.getOption(config,"","send_delays","60,60,60,300,300,3600,3600,18000,36000").split(",") delays=cs_helpers.getOption(config,"","send_delays","60,60,60,300,300,3600,3600,18000,36000").split(",")
@ -115,16 +120,19 @@ def idle(capi):
starttime=time.time()+next_delay starttime=time.time()+next_delay
capisuite.log("job "+job_fax+": delayed for "+str(next_delay)+" seconds",2) capisuite.log("job "+job_fax+": delayed for "+str(next_delay)+" seconds",2)
cs_helpers.writeDescription(sendq+job_fax,"dialstring=\""+dialstring+"\"\n" cs_helpers.writeDescription(sendq+job_fax,"dialstring=\""+dialstring+"\"\n"
+"starttime=\""+time.ctime(starttime)+"\"\ntries=\""+str(tries)+"\"\n" +"starttime=\""+time.ctime(starttime)+"\"\ntries=\""+str(tries)+"\"\n"
+"user=\""+user+"\"") +"user=\""+user+"\"\naddressee=\""+addressee+"\"\nsubject=\""+subject+"\"\n")
if (tries>=max_tries): if (tries>=max_tries):
movejob(job_fax,sendq,failed,user) movejob(job_fax,sendq,failed,user)
capisuite.log("job "+job_fax+": failed finally",1) capisuite.log("job "+job_fax+": failed finally",1)
cs_helpers.sendSimpleMail(user,mailaddress,"Fax to "+dialstring+" FAILED.", mailtext="I'm sorry, but your fax job to "+addressee+" ("+dialstring \
"I'm sorry, but your fax job to "+dialstring+" failed finally.\n\n" +") failed finally.\n\nSubject: "+subject \
+"Filename: "+job_fax+"\nTries: "+str(tries) +"\nFilename: "+job_fax+"\nTries: "+str(tries) \
+"\nLast result: 0x%x/0x%x" % (result,resultB3) +"\nLast result: 0x%x/0x%x" % (result,resultB3) \
+"\n\nIt was moved to file://"+failed+user+"-"+job_fax) +"\n\nIt was moved to file://"+failed+user+"-"+job_fax
cs_helpers.sendSimpleMail(user,mailaddress,
"Fax to "+addressee+" ("+dialstring+") FAILED.",
mailtext)
fcntl.lockf(lockfile,fcntl.LOCK_UN) fcntl.lockf(lockfile,fcntl.LOCK_UN)
lockfile.close() lockfile.close()
@ -132,11 +140,11 @@ def idle(capi):
def sendfax(capi,job,outgoing_nr,dialstring,user,config): def sendfax(capi,job,outgoing_nr,dialstring,user,config):
try: try:
controller=int(cs_helpers.getOption(config,"","send_controller","1")) controller=int(cs_helpers.getOption(config,"","send_controller","1"))
timeout=int(cs_helpers.getOption(config,user,"outgoing_timeout","60")) timeout=int(cs_helpers.getOption(config,user,"outgoing_timeout","60"))
stationID=cs_helpers.getOption(config,user,"fax_stationID") stationID=cs_helpers.getOption(config,user,"fax_stationID")
if (stationID==None): if (stationID==None):
capisuite.error("Warning: fax_stationID for user "+user+" not set") capisuite.error("Warning: fax_stationID for user "+user+" not set")
stationID="" stationID=""
headline=cs_helpers.getOption(config,user,"fax_headline","") headline=cs_helpers.getOption(config,user,"fax_headline","")
(call,result)=capisuite.call_faxG3(capi,controller,outgoing_nr,dialstring,timeout,stationID,headline) (call,result)=capisuite.call_faxG3(capi,controller,outgoing_nr,dialstring,timeout,stationID,headline)
@ -155,6 +163,10 @@ def movejob(job,olddir,newdir,user):
# History: # History:
# #
# $Log: idle.py,v $ # $Log: idle.py,v $
# Revision 1.8 2003/06/26 11:53:17 gernot
# - fax jobs can be given an addressee and a subject now (resolves #18, reported
# by Achim Bohnet)
#
# Revision 1.7 2003/06/19 14:58:43 gernot # Revision 1.7 2003/06/19 14:58:43 gernot
# - fax_numbers is now really optional (bug #23) # - fax_numbers is now really optional (bug #23)
# - tries counter was wrongly reported (bug #29) # - tries counter was wrongly reported (bug #29)