Show
Ignore:
Timestamp:
03/16/03 09:00:50 (21 years ago)
Author:
jalet
Message:

Default hard coded options are now used if they are not set in the
configuration file.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/config.py

    r852 r853  
    1515# 
    1616# $Log$ 
     17# Revision 1.18  2003/03/16 08:00:50  jalet 
     18# Default hard coded options are now used if they are not set in the 
     19# configuration file. 
     20# 
    1721# Revision 1.17  2003/03/15 23:01:28  jalet 
    1822# New mailto option in configuration file added. 
     
    152156        """Returns the logging backend information.""" 
    153157        validloggers = [ "stderr", "system" ]  
    154         logger = self.getGlobalOption("logger").lower() 
     158        try : 
     159            logger = self.getGlobalOption("logger").lower() 
     160        except PyKotaConfigError :     
     161            logger = "system" 
    155162        if logger not in validloggers :              
    156163            raise PyKotaConfigError, _("Option logger only supports values in %s") % str(validloggers) 
     
    176183        """Returns the default policy for the current printer.""" 
    177184        validpolicies = [ "ALLOW", "DENY" ]      
    178         policy = self.getPrinterOption(printer, "policy").upper() 
     185        try : 
     186            policy = self.getPrinterOption(printer, "policy").upper() 
     187        except PyKotaConfigError :     
     188            policy = "ALLOW" 
    179189        if policy not in validpolicies : 
    180190            raise PyKotaConfigError, _("Option policy in section %s only supports values in %s") % (printer, str(validpolicies)) 
     
    183193    def getSMTPServer(self) :     
    184194        """Returns the SMTP server to use to send messages to users.""" 
    185         return self.getGlobalOption("smtpserver") 
     195        try : 
     196            return self.getGlobalOption("smtpserver") 
     197        except PyKotaConfigError :     
     198            return "localhost" 
    186199         
    187200    def getAdminMail(self, printer) :     
    188201        """Returns the Email address of the Print Quota Administrator.""" 
    189         return self.getPrinterOption(printer, "adminmail") 
     202        try : 
     203            return self.getPrinterOption(printer, "adminmail") 
     204        except PyKotaConfigError :     
     205            return "root@localhost" 
    190206         
    191207    def getAdmin(self, printer) :     
    192208        """Returns the full name of the Print Quota Administrator.""" 
    193         return self.getPrinterOption(printer, "admin") 
     209        try : 
     210            return self.getPrinterOption(printer, "admin") 
     211        except PyKotaConfigError :     
     212            return "root" 
    194213         
    195214    def getMailTo(self, printer) :     
    196215        """Returns the recipient of email messages.""" 
    197216        validmailtos = [ "DEVNULL", "BOTH", "USER", "ADMIN" ] 
    198         mailto = self.getPrinterOption(printer, "mailto").upper() 
     217        try : 
     218            mailto = self.getPrinterOption(printer, "mailto").upper() 
     219        except PyKotaConfigError :     
     220            mailto = "BOTH" 
    199221        if mailto not in validmailtos : 
    200222            raise PyKotaConfigError, _("Option mailto in section %s only supports values in %s") % (printer, str(validmailtos)) 
     
    203225    def getGraceDelay(self, printer) :     
    204226        """Returns the grace delay in days.""" 
    205         gd = self.getPrinterOption(printer, "gracedelay") 
     227        try : 
     228            gd = self.getPrinterOption(printer, "gracedelay") 
     229        except PyKotaConfigError :     
     230            gd = 7 
    206231        try : 
    207232            return int(gd)