From 72fc7cf0adc940d5624e4ada9fb2605533a1f2d2 Mon Sep 17 00:00:00 2001 From: gernot Date: Thu, 26 Jun 2003 11:53:17 +0000 Subject: [PATCH] - 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 --- NEWS | 3 +++ docs/manual-de.docbook | 23 ++++++++++++++---- docs/manual.docbook | 17 ++++++++++--- scripts/capisuitefax.in | 53 +++++++++++++++++++++++++---------------- scripts/idle.py | 42 ++++++++++++++++++++------------ 5 files changed, 95 insertions(+), 43 deletions(-) diff --git a/NEWS b/NEWS index f7e900b..e178540 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,9 @@ * scripts: number of needed tries reported after sending a fax was 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): ============================== * manual now available as PDF diff --git a/docs/manual-de.docbook b/docs/manual-de.docbook index f792892..53ac3fc 100644 --- a/docs/manual-de.docbook +++ b/docs/manual-de.docbook @@ -794,7 +794,7 @@ make install Wenn hier etwas angegeben ist, wird es als Präfix vor jede Nummer - eingefügt, die an capisuitefax übergeben wird. + eingefügt, die an capisuitefax übergeben wird. 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 für ein einzelnes Fax-Dokument deaktiviert werden, sodass diese Einstellung @@ -1206,9 +1206,10 @@ make install capisuitefax kennt die folgenden Optionen: - capisuitefax [-q] [-n] [-u username] -d dialstring file1 [file2...] + capisuitefax [-q] [-n] [-u user] [-A addr] [-S subj] -d number file1 [file2...] capisuitefax [-q] -a id - capisuitefax [-h] [-l] + capisuitefax -l + capisuitefax -h @@ -1216,6 +1217,12 @@ make install Auftrags zu ermittelen, können Sie die Option verwenden. + + + 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. + Die Nummer, die angerufen werden soll (Empfänger des Faxes). @@ -1232,7 +1239,7 @@ make install - Nicht den konfigurierten Präfix für diesen Auftrag verwenden. + Nicht den konfigurierten Präfix für diesen Auftrag verwenden. Dies ist nützlich für interne Aufträge. @@ -1240,6 +1247,12 @@ make install Sei still, gib keine informativen Meldungen aus! + + + 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. + @@ -1250,7 +1263,7 @@ make install - Eine oder mehrere PostScript-Dateien, die an diesen Empfänger + Eine oder mehrere PostScript-Dateien, die an diesen Empfänger verschickt werden sollen. Mehrere PostScript-Dateien erzeugen mehrere separate Fax-Aufträge). diff --git a/docs/manual.docbook b/docs/manual.docbook index 3bb7556..185b622 100644 --- a/docs/manual.docbook +++ b/docs/manual.docbook @@ -1051,9 +1051,10 @@ make install The following options are recognized by capisuitefax: - capisuitefax [-q] [-n] [-u username] -d dialstring file1 [file2...] + capisuitefax [-q] [-n] [-u user] [-A adr] [-S subj] -d number file1 [file2 ...] capisuitefax [-q] -a id - capisuitefax [-h] [-l] + capisuitefax -h + capisuitefax -l @@ -1061,7 +1062,12 @@ make install option. - + + The addressee of the fax. This option is (currently) only + for informational purposes and will be quoted in the sent status mail. + + + The number which should be called (destination of the fax) @@ -1080,6 +1086,11 @@ make install Be quiet, don't output informational messages + + + A subject for the fax. This option is (currently) only + for informational purposes and will be quoted in the sent status mail. + diff --git a/scripts/capisuitefax.in b/scripts/capisuitefax.in index 2e53e46..0d2eb2a 100755 --- a/scripts/capisuitefax.in +++ b/scripts/capisuitefax.in @@ -4,7 +4,7 @@ # --------------------------------------------------- # copyright : (C) 2002 by Gernot Hillier # email : gernot@hillier.de -# version : $Revision: 1.5 $ +# version : $Revision: 1.6 $ # # 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 @@ -16,6 +16,8 @@ import getopt,os,sys,re,time,pwd,errno,fcntl,string import cs_helpers dialstring="" +addressee="" +subject="" abort="" user="" quiet=0 @@ -26,20 +28,26 @@ def usage(error=""): print """capisuitefax - capisuite tool for enqueueing faxes usage: -capisuitefax [-q] [-n] [-u ] -d file1 [file2...] or -capisuitefax [-q] -a or -capisuitefax [-h] [-l] +capisuitefax [] -d file1 [file2...] or +capisuitefax [-q] -a +capisuitefax -l +capisuitefax -h -possible options are: +possible send options are: --a , --abort= abort fax job with id (id is a number) --d , --dialstring= send fax to this number --h, --help print this usage information --l, --list print jobs in the send queue +-d , --dialstring= send fax to this number (mandatory) -n, --noprefix ignore configured dial prefix for this call (for internal calls) -u , --user= send fax as (only when called as root!) +-A , --addressee= addressee (for informational purposes) +-S , --subject= some subject (for informational purposes) + +other options: + -q, --quiet be quiet, don't output informational messages +-a , --abort= 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""" if (error!=""): @@ -54,7 +62,7 @@ def showlist(config,user): sys.exit(1) 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=filter (lambda s: re.match("fax-.*\.txt",s),files) @@ -65,13 +73,15 @@ def showlist(config,user): control=cs_helpers.readConfig(sendq+job) sys.stdout.write(re.match("fax-([0-9]+)\.txt",job).group(1)) sys.stdout.write("\t") - sys.stdout.write(control.get("GLOBAL","dialstring")) - if (len(control.get("GLOBAL","dialstring"))<8): + dest=cs_helpers.getOption(control,"GLOBAL","addressee","") + 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(control.get("GLOBAL","tries")) - sys.stdout.write("\t\t") - sys.stdout.write(control.get("GLOBAL","starttime")+"\n") + sys.stdout.write(control.get("GLOBAL","tries")+"\t") + sys.stdout.write(control.get("GLOBAL","starttime")+"\t") + sys.stdout.write(cs_helpers.getOption(control,"GLOBAL","subject","")+"\n") sys.exit(0) @@ -99,10 +109,10 @@ def abortjob(config,user,job): if (err.errno in (errno.EACCES,errno.EAGAIN)): print "Job is currently in transmission. Can't abort." - try: - optlist,args = getopt.getopt(sys.argv[1:], "d:a:u:lhqn" - ,['dialstring=','noprefix','help',"abort=","list","quiet","user="]) + optlist,args = getopt.getopt(sys.argv[1:], "d:a:u:lhqnA:S:" + ,['dialstring=','noprefix','help',"abort=","list","quiet","user=", + 'addressee=','subject=']) except getopt.GetoptError, e: usage(e.msg) @@ -110,6 +120,8 @@ except getopt.GetoptError, e: # read options for option,param in optlist: 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 ('-h','--help'): usage() if option in ('-l','--list'): listqueue=1 @@ -190,7 +202,8 @@ for i in args: cs_helpers.writeDescription(newname,"dialstring=\""+dialstring+"\"\n" +"starttime=\""+time.ctime()+"\"\ntries=\"0\"\n" - +"user=\""+user+"\"\n") + +"user=\""+user+"\"\naddressee=\""+addressee+"\"\nsubject=\"" + +subject+"\"\n") os.chmod(newname,0600) os.chmod(newname[:-3]+"txt",0600) if (os.getuid()==0): diff --git a/scripts/idle.py b/scripts/idle.py index 676ff65..95433dd 100644 --- a/scripts/idle.py +++ b/scripts/idle.py @@ -2,7 +2,7 @@ # --------------------------------------------- # copyright : (C) 2002 by Gernot Hillier # email : gernot@hillier.de -# version : $Revision: 1.7 $ +# version : $Revision: 1.8 $ # # 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 @@ -87,6 +87,8 @@ def idle(capi): tries=control.getint("GLOBAL","tries") 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","") if (mailaddress==""): mailaddress=user @@ -99,11 +101,14 @@ def idle(capi): if (result in (0,0x3400,0x3480,0x3490) and resultB3==0): movejob(job_fax,sendq,done,user) capisuite.log("job "+job_fax+": finished successfully",1) - cs_helpers.sendSimpleMail(user,mailaddress,"Fax to "+dialstring+" sent successfully.", - "Your fax job to "+dialstring+" was sent successfully.\n\n" - +"Filename: "+job_fax+"\nNeeded tries: "+str(tries) - +("\nLast result: 0x%x/0x%x" % (result,resultB3)) - +"\n\nIt was moved to file://"+done+user+"-"+job_fax) + mailtext="Your fax job to "+addressee+" ("+dialstring+") was sent successfully.\n\n" \ + +"Subject: "+subject+"\nFilename: "+job_fax \ + +"\nNeeded tries: "+str(tries) \ + +("\nLast result: 0x%x/0x%x" % (result,resultB3)) \ + +"\n\nIt was moved to file://"+done+user+"-"+job_fax + cs_helpers.sendSimpleMail(user,mailaddress, + "Fax to "+addressee+" ("+dialstring+") sent successfully.", + mailtext) else: 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(",") @@ -115,16 +120,19 @@ def idle(capi): starttime=time.time()+next_delay capisuite.log("job "+job_fax+": delayed for "+str(next_delay)+" seconds",2) cs_helpers.writeDescription(sendq+job_fax,"dialstring=\""+dialstring+"\"\n" - +"starttime=\""+time.ctime(starttime)+"\"\ntries=\""+str(tries)+"\"\n" - +"user=\""+user+"\"") + +"starttime=\""+time.ctime(starttime)+"\"\ntries=\""+str(tries)+"\"\n" + +"user=\""+user+"\"\naddressee=\""+addressee+"\"\nsubject=\""+subject+"\"\n") if (tries>=max_tries): movejob(job_fax,sendq,failed,user) capisuite.log("job "+job_fax+": failed finally",1) - cs_helpers.sendSimpleMail(user,mailaddress,"Fax to "+dialstring+" FAILED.", - "I'm sorry, but your fax job to "+dialstring+" failed finally.\n\n" - +"Filename: "+job_fax+"\nTries: "+str(tries) - +"\nLast result: 0x%x/0x%x" % (result,resultB3) - +"\n\nIt was moved to file://"+failed+user+"-"+job_fax) + mailtext="I'm sorry, but your fax job to "+addressee+" ("+dialstring \ + +") failed finally.\n\nSubject: "+subject \ + +"\nFilename: "+job_fax+"\nTries: "+str(tries) \ + +"\nLast result: 0x%x/0x%x" % (result,resultB3) \ + +"\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) lockfile.close() @@ -132,11 +140,11 @@ def idle(capi): def sendfax(capi,job,outgoing_nr,dialstring,user,config): 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")) stationID=cs_helpers.getOption(config,user,"fax_stationID") if (stationID==None): - capisuite.error("Warning: fax_stationID for user "+user+" not set") + capisuite.error("Warning: fax_stationID for user "+user+" not set") stationID="" headline=cs_helpers.getOption(config,user,"fax_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: # # $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 # - fax_numbers is now really optional (bug #23) # - tries counter was wrongly reported (bug #29)