Show
Ignore:
Timestamp:
11/27/04 23:52:07 (19 years ago)
Author:
jalet
Message:

Now PyKota searches its configuration files first in system user pykota's
home directory

Files:
1 modified

Legend:

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

    r1944 r1960  
    2222# 
    2323# $Log$ 
     24# Revision 1.145  2004/11/27 22:52:07  jalet 
     25# Now PyKota searches its configuration files first in system user pykota's 
     26# home directory 
     27# 
    2428# Revision 1.144  2004/11/18 06:01:53  jalet 
    2529# Fix for the fix 
     
    522526import sys 
    523527import os 
     528import pwd 
    524529import fnmatch 
    525530import getopt 
     
    600605        # pykota specific stuff 
    601606        self.documentation = doc 
     607         
     608        # try to find the configuration files in user's 'pykota' home directory. 
    602609        try : 
    603             self.config = config.PyKotaConfig("/etc/pykota") 
     610            pykotauser = pwd.getpwnam("pykota") 
     611        except KeyError :     
     612            confdir = "/etc/pykota" 
     613            missingUser = 1 
     614        else :     
     615            confdir = pykotauser[5] 
     616            missingUser = 0 
     617             
     618        try : 
     619            self.config = config.PyKotaConfig(confdir) 
    604620        except ConfigParser.ParsingError, msg :     
    605621            sys.stderr.write("ERROR: Problem encountered while parsing configuration file : %s\n" % msg) 
     
    615631            self.crashed(msg) 
    616632            raise 
     633             
     634        # We NEED this here, even when not in an accounting filter/backend     
    617635        self.softwareJobSize = 0 
    618636        self.softwareJobPrice = 0.0 
     637         
    619638        if defaultToCLocale : 
    620639            self.printInfo("Incorrect locale settings. PyKota falls back to the 'C' locale.", "warn") 
     640        if missingUser :      
     641            self.printInfo("The 'pykota' system account is missing. Configuration files were searched in /etc/pykota instead.", "warn") 
     642         
    621643        self.logdebug("Charset in use : %s" % self.charset) 
    622644        arguments = " ".join(['"%s"' % arg for arg in sys.argv])