Changeset 853 for pykota/trunk

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

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

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/conf/pykota.conf.sample

    r852 r853  
    3232# Where to log ? 
    3333# supported values : stderr, system (system means syslog, but don't use 'syslog' here) 
     34# if the value is not set then the default SYSTEM applies. 
    3435logger: system 
    3536 
    3637# Mail server to use to warn users 
     38# If the value is not set then localhost is used. 
    3739smtpserver: localhost 
    3840 
     
    4446# These values can be set either globally or per printer or both. 
    4547# If both are defined, the printer option has priority. 
     48# If these values are not set, the default admin root  
     49# and the default adminmail root@localhost are used. 
    4650admin: Jerome Alet 
    4751adminmail: alet@librelogiciel.com 
     
    5559# This value can be set either globally or per printer or both. 
    5660# If both are defined, the printer option has priority. 
     61# If the value is not set, then the default BOTH applies. 
    5762mailto: both 
    5863 
     
    6166# This value can be set either globally or per printer or both. 
    6267# If both are defined, the printer option has priority. 
     68# If the value is not set then the default seven (7) days applies. 
    6369gracedelay: 7 
    6470 
    65 # one section per printer, or no other section at all if all options are defined globally 
     71# one section per printer, or no other section at all if all options  
     72# are defined globally 
    6673[lp] 
    6774 
     
    8592# This value can be set either globally or per printer or both. 
    8693# If both are defined, the printer option has priority. 
     94# If the value is not set then the default policy ALLOW applies. 
    8795policy: allow 
    8896 
  • pykota/trunk/NEWS

    r852 r853  
    2626            - Both means the User and the Admin will receive them. 
    2727             
     28        - The configuration file now uses hard-coded default values 
     29          when an option is not set. See sample configuration file 
     30          for details. 
     31           
    2832        - Manual pages are included since 1.00, but I forgot to     
    2933          add this information to this file. 
  • 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)