- shortened long lines
- escape filenames correctly git-svn-id: https://svn.ibp.de/svn/capisuite/trunk/capisuite@97 4ebea2bb-67d4-0310-8558-a5799e421b66
This commit is contained in:
parent
1a5fa8e9d2
commit
a4694ca0ab
|
@ -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.1 $
|
# version : $Revision: 1.2 $
|
||||||
#
|
#
|
||||||
# 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
|
||||||
|
@ -15,35 +15,36 @@ import getopt,os,sys,re,time,pwd,errno,fcntl
|
||||||
# capisuite stuff
|
# capisuite stuff
|
||||||
import cs_helpers
|
import cs_helpers
|
||||||
|
|
||||||
dialstring=""
|
dialstring=""
|
||||||
abort=""
|
abort=""
|
||||||
quiet=0
|
quiet=0
|
||||||
listqueue=0
|
listqueue=0
|
||||||
useprefix=1
|
useprefix=1
|
||||||
|
|
||||||
def usage(error=""):
|
def usage(error=""):
|
||||||
print "capisuitefax - capisuite tool for enqueueing faxes"
|
print """capisuitefax - capisuite tool for enqueueing faxes
|
||||||
print
|
|
||||||
print "usage:"
|
usage:
|
||||||
print "capisuitefax [-q] [-n] -d <dial> file1 [file2...] or"
|
capisuitefax [-q] [-n] -d <dial> file1 [file2...] or
|
||||||
print "capisuitefax [-q] -a <id> or"
|
capisuitefax [-q] -a <id> or
|
||||||
print "capisuitefax [-h] [-l]"
|
capisuitefax [-h] [-l]
|
||||||
print
|
|
||||||
print "possible options are:"
|
possible options are:
|
||||||
print
|
|
||||||
print "-a <id>, --abort=<id> abort fax job with id (id is a number)"
|
-a <id>, --abort=<id> abort fax job with id (id is a number)
|
||||||
print "-d <dial>, --dialstring=<dial> send fax to this number (required)"
|
-d <dial>, --dialstring=<dial> send fax to this number
|
||||||
print "-h, --help print this usage information"
|
-h, --help print this usage information
|
||||||
print "-l, --list print the jobs in the send queue"
|
-l, --list print jobs in the send queue
|
||||||
print "-n, --noprefix ignore configured dial prefix for this call (for internal calls)"
|
-n, --noprefix ignore configured dial prefix for this call
|
||||||
print "-q, --quiet be quiet, don't output informational messages"
|
(for internal calls)
|
||||||
print
|
-q, --quiet be quiet, don't output informational messages
|
||||||
print "The given files must be in Adobe PostScript format"
|
|
||||||
|
The given files must be in Adobe PostScript format"""
|
||||||
if (error!=""):
|
if (error!=""):
|
||||||
print
|
print
|
||||||
print "ERROR:",error
|
print "ERROR:",error
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def showlist(config,user):
|
def showlist(config,user):
|
||||||
sendq=cs_helpers.getOption(config,"","fax_user_dir")
|
sendq=cs_helpers.getOption(config,"","fax_user_dir")
|
||||||
if (sendq==None):
|
if (sendq==None):
|
||||||
|
@ -86,18 +87,20 @@ def abortjob(config,user,job):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lockfile=open(sendq+job[:-3]+"lock","w")
|
lockfile=open(sendq+job[:-3]+"lock","w")
|
||||||
fcntl.lockf(lockfile,fcntl.LOCK_EX | fcntl.LOCK_NB) # lock so that it isn't deleted while sending
|
# lock so that it isn't deleted while sending
|
||||||
|
fcntl.lockf(lockfile,fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
os.unlink(sendq+job)
|
os.unlink(sendq+job)
|
||||||
os.unlink(sendq+job[:-3]+"sff")
|
os.unlink(sendq+job[:-3]+"sff")
|
||||||
fcntl.lockf(lockfile,fcntl.LOCK_UN)
|
fcntl.lockf(lockfile,fcntl.LOCK_UN)
|
||||||
os.unlink(sendq+job[:-3]+"lock")
|
os.unlink(sendq+job[:-3]+"lock")
|
||||||
except IOError,err:
|
except IOError,err:
|
||||||
if (err.errno in (errno.EACCES,errno.EAGAIN)):
|
if (err.errno in (errno.EACCES,errno.EAGAIN)):
|
||||||
print "Sorry, this 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:lhqn", ['dialstring=','noprefix','help',"abort=","list","quiet"])
|
optlist,args = getopt.getopt(sys.argv[1:], "d:a:lhqn"
|
||||||
|
,['dialstring=','noprefix','help',"abort=","list","quiet"])
|
||||||
|
|
||||||
except getopt.GetoptError, e:
|
except getopt.GetoptError, e:
|
||||||
usage(e.msg)
|
usage(e.msg)
|
||||||
|
@ -138,13 +141,13 @@ sendq=os.path.join(sendq,user,"sendq")+"/"
|
||||||
if (not os.access(sendq,os.W_OK)):
|
if (not os.access(sendq,os.W_OK)):
|
||||||
print "can't write to queue dir"
|
print "can't write to queue dir"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if (listqueue):
|
if (listqueue):
|
||||||
showlist(config,user)
|
showlist(config,user)
|
||||||
|
|
||||||
if (abort):
|
if (abort):
|
||||||
abortjob(config,user,abort)
|
abortjob(config,user,abort)
|
||||||
|
|
||||||
prefix=cs_helpers.getOption(config,user,"dial_prefix","")
|
prefix=cs_helpers.getOption(config,user,"dial_prefix","")
|
||||||
if (useprefix):
|
if (useprefix):
|
||||||
dialstring=prefix+dialstring
|
dialstring=prefix+dialstring
|
||||||
|
@ -154,7 +157,7 @@ for i in args:
|
||||||
if (not os.access(i,os.R_OK)):
|
if (not os.access(i,os.R_OK)):
|
||||||
sys.stderr.write("can't open "+i+'\n')
|
sys.stderr.write("can't open "+i+'\n')
|
||||||
continue
|
continue
|
||||||
t=os.popen("file -b -i "+i+" 2>/dev/null")
|
t=os.popen("file -b -i "+cs_helpers.escape(i)+" 2>/dev/null")
|
||||||
filetype=t.read()
|
filetype=t.read()
|
||||||
if (t.close()):
|
if (t.close()):
|
||||||
usage("can't execute \"file\"")
|
usage("can't execute \"file\"")
|
||||||
|
@ -164,9 +167,12 @@ for i in args:
|
||||||
|
|
||||||
newname=cs_helpers.uniqueName(sendq,"fax","sff")
|
newname=cs_helpers.uniqueName(sendq,"fax","sff")
|
||||||
|
|
||||||
ret=(os.system("gs -dNOPAUSE -dQUIET -dBATCH -sDEVICE=cfax -sOutputFile="+newname+" "+i))>>8
|
command="gs -dNOPAUSE -dQUIET -dBATCH -sDEVICE=cfax -sOutputFile=" \
|
||||||
|
+ newname+" "+cs_helpers.escape(i)
|
||||||
|
ret=(os.system(command))>>8
|
||||||
if (ret):
|
if (ret):
|
||||||
sys.stderr.write("error during SFF-conversion at file "+i+'. Ghostscript not installed?\n')
|
sys.stderr.write("error during SFF-conversion at file "+i+'. \
|
||||||
|
Ghostscript not installed?\n')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
cs_helpers.writeDescription(newname,"dialstring=\""+dialstring+"\"\n"
|
cs_helpers.writeDescription(newname,"dialstring=\""+dialstring+"\"\n"
|
||||||
|
@ -176,15 +182,3 @@ for i in args:
|
||||||
os.chmod(newname[:-3]+"txt",0600)
|
os.chmod(newname[:-3]+"txt",0600)
|
||||||
|
|
||||||
print i,"successful enqueued as",newname,"for",dialstring
|
print i,"successful enqueued as",newname,"for",dialstring
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue