Changeset 872 for pykota/trunk/setup.py

Show
Ignore:
Timestamp:
03/29/03 14:08:28 (21 years ago)
Author:
jalet
Message:

Configuration is now expected to be found in /etc/pykota.conf instead of
in /etc/cups/pykota.conf
Installation script can move old config files to the new location if needed.
Better error handling if configuration file is absent.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/setup.py

    r870 r872  
    1717# 
    1818# $Log$ 
     19# Revision 1.5  2003/03/29 13:08:28  jalet 
     20# Configuration is now expected to be found in /etc/pykota.conf instead of 
     21# in /etc/cups/pykota.conf 
     22# Installation script can move old config files to the new location if needed. 
     23# Better error handling if configuration file is absent. 
     24# 
    1925# Revision 1.4  2003/03/29 09:47:00  jalet 
    2026# More powerful installation script. 
     
    8187     
    8288if "install" in sys.argv : 
     89    # checks if Python version is correct, we need >= 2.1 
    8390    if not (sys.version > "2.1") : 
    8491        sys.stderr.write("PyKota needs at least Python v2.1 !\nYour version seems to be older than that, please update.\nAborted !\n") 
    8592        sys.exit(-1) 
    8693         
     94    # checks if a configuration file is present in the old location 
     95    if os.path.isfile("/etc/cups/pykota.conf") : 
     96        if not os.path.isfile("/etc/pykota.conf") : 
     97            sys.stdout.write("From version 1.02 on, PyKota expects to find its configuration file in /etc instead of /etc/cups.\n") 
     98            sys.stdout.write("It seems that you've got a configuration file in the old location, so it will not be used anymore, and no configuration file in the new location.\n") 
     99            answer = raw_input("Do you want me to move your configuration file to the new location in /etc (y/N) ? ") 
     100            if answer[0:1].upper() == 'Y' : 
     101                try : 
     102                    os.rename("/etc/cups/pykota.conf", "/etc/pykota.conf") 
     103                except OSError :     
     104                    sys.stderr.write("ERROR : An error occured while moving /etc/cups/pykota.conf to /etc/pykota.conf\nAborted !\n") 
     105                    sys.exit(-1) 
     106            else : 
     107                sys.stderr.write("WARNING : Configuration file /etc/cups/pykota.conf won't be used ! Move it to /etc instead.\n") 
     108                sys.stderr.write("PyKota installation will continue anyway, but the software won't run until you put a proper configuration file in /etc\n") 
     109        else :         
     110            sys.stderr.write("WARNING : Configuration file /etc/cups/pykota.conf will not be used !\nThe file /etc/pykota.conf will be used instead.\n") 
     111     
     112    # checks if some needed Python modules are there or not. 
    87113    modulestocheck = [("PygreSQL", "pg"), ("mxDateTime", "mx.DateTime")] 
    88114    commandstocheck = [("SNMP Tools", "snmpget")] 
     
    93119            sys.exit(-1) 
    94120             
     121    # checks if some software are there or not. 
    95122    for (name, command) in commandstocheck : 
    96123        action = checkWithPrompt(name, command=command)