Changeset 699 for pykota/trunk

Show
Ignore:
Timestamp:
02/05/03 23:16:20 (22 years ago)
Author:
jalet
Message:

DEVICE_URI is undefined outside of CUPS, i.e. for normal command line tools

Location:
pykota/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pykota

    r695 r699  
    1717# 
    1818# $Log$ 
     19# Revision 1.2  2003/02/05 22:16:20  jalet 
     20# DEVICE_URI is undefined outside of CUPS, i.e. for normal command line tools 
     21# 
    1922# Revision 1.1  2003/02/05 21:28:17  jalet 
    2023# Initial import into CVS 
     
    3437        self.username = username 
    3538        self.requester = requester.openRequester(self.config, self.printername) 
     39        self.printerhostname = self.getPrinterHostname() 
    3640     
     41    def getPrinterHostname(self) : 
     42        """Returns the printer hostname.""" 
     43        device_uri = os.environ.get("DEVICE_URI", "") 
     44        # TODO : check this for more complex urls than ipp://myprinter.dot.com:631/printers/lp 
     45        try : 
     46            (backend, destination) = device_uri.split(":", 1)  
     47        except ValueError :     
     48            raise PyKotaToolError, "Invalid DEVICE_URI : %s\n" % device_uri 
     49        while destination.startswith("/") : 
     50            destination = destination[1:] 
     51        return destination.split("/")[0].split(":")[0] 
     52         
    3753    def filterInput(self, inputfile) : 
    3854        """Transparent filter.""" 
  • pykota/trunk/pykota/tool.py

    r698 r699  
    1515# 
    1616# $Log$ 
     17# Revision 1.3  2003/02/05 22:16:20  jalet 
     18# DEVICE_URI is undefined outside of CUPS, i.e. for normal command line tools 
     19# 
    1720# Revision 1.2  2003/02/05 22:10:29  jalet 
    1821# Typos 
     
    4952        self.storage = storage.openConnection(self.config, asadmin=(not isfilter)) 
    5053        self.printername = os.environ.get("PRINTER", None) 
    51         self.printerhostname = self.getPrinterHostname() 
    5254        self.smtpserver = self.config.getSMTPServer() 
    5355        self.admin = self.config.getAdmin() 
     
    7173        self.sendMessage(self.adminmail, "Subject: %s\n\n%s" % (subject, message)) 
    7274         
    73     def getPrinterHostname(self) : 
    74         """Returns the printer hostname.""" 
    75         device_uri = os.environ.get("DEVICE_URI", "") 
    76         # TODO : check this for more complex urls than ipp://myprinter.dot.com:631/printers/lp 
    77         try : 
    78             (backend, destination) = device_uri.split(":", 1)  
    79         except ValueError :     
    80             raise PyKotaToolError, "Invalid DEVICE_URI : %s\n" % device_uri 
    81         while destination.startswith("/") : 
    82             destination = destination[1:] 
    83         return destination.split("/")[0].split(":")[0] 
    84          
    8575    def warnQuotaPrinter(self, username) : 
    8676        """Checks a user quota and send him a message if quota is exceeded on current printer."""