Changeset 1178 for pykota/trunk

Show
Ignore:
Timestamp:
11/12/03 10:33:35 (21 years ago)
Author:
jalet
Message:

New CUPS backend supports device enumeration

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r1177 r1178  
    2424# 
    2525# $Log$ 
     26# Revision 1.2  2003/11/12 09:33:34  jalet 
     27# New CUPS backend supports device enumeration 
     28# 
    2629# Revision 1.1  2003/11/08 16:05:31  jalet 
    2730# CUPS backend added for people to experiment. 
     
    3336import os 
    3437import time 
     38import cStringIO 
     39import shlex 
    3540 
    3641from pykota.tool import PyKotaTool, PyKotaToolError 
     
    225230    # This is a CUPS backend, we should act and die like a CUPS backend 
    226231    if len(sys.argv) == 1 : 
    227         print 'direct cupspykota "PyKota" "Print Quota and Accounting Backend"'  
     232        # we will execute each existing backend in device enumeration mode 
     233        # and generate their PyKota accounting counterpart 
     234        (directory, myname) = os.path.split(sys.argv[0]) 
     235        for backend in [os.path.join(directory, b) for b in os.listdir(directory) if os.path.isfile(os.path.join(directory, b)) and (b != myname)] : 
     236            answer = os.popen(backend, "r") 
     237            try : 
     238                devices = [line.strip() for line in answer.readlines()] 
     239            except :     
     240                devices = [] 
     241            status = answer.close() 
     242            if status is None : 
     243                for d in devices : 
     244                    fdevice = cStringIO.StringIO("%s" % d) 
     245                    tokenizer = shlex.shlex(fdevice) 
     246                    tokenizer.wordchars = tokenizer.wordchars + r".:,?!~/\_$*-+={}[]()#" 
     247                    arguments = [] 
     248                    while 1 : 
     249                        token = tokenizer.get_token() 
     250                        if token : 
     251                            arguments.append(token) 
     252                        else : 
     253                            break 
     254                    fdevice.close() 
     255                    (devicetype, device, name, fullname) = arguments 
     256                    if name.startswith('"') and name.endswith('"') : 
     257                        name = name[1:-1] 
     258                    if fullname.startswith('"') and fullname.endswith('"') : 
     259                        fullname = fullname[1:-1] 
     260                    print '%s cupspykota:%s "PyKota+%s" "PyKota managed %s"' % (devicetype, device, name, fullname)     
    228261        retcode = 0 
    229262    elif len(sys.argv) not in (6, 7) :     
  • pykota/trunk/NEWS

    r1177 r1178  
    2222PyKota NEWS : 
    2323 
     24    - 1.16alpha5 : 
     25     
     26        - New CUPS backend supports device enumeration ! 
     27          This means that NO manual CUPS configuration has to 
     28          be done. All can now be done from CUPS web interface. 
     29         
    2430    - 1.16alpha4 : 
    2531     
  • pykota/trunk/pykota/version.py

    r1177 r1178  
    2222# 
    2323 
    24 __version__ = "1.16alpha4_unofficial" 
     24__version__ = "1.16alpha5_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""