X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FConfig.py;h=690f9e364b25c9c4ab143e597871ee17da4309f9;hb=afaa86e866019b80eb3524706fc19837047c2e49;hp=97233f0c6611c83df4ebd31bb7bc66295035f8f4;hpb=6b6d5d2a4a89bd99fb91fa83c1e081d53824e27c;p=plcapi.git diff --git a/PLC/Config.py b/PLC/Config.py index 97233f0..690f9e3 100644 --- a/PLC/Config.py +++ b/PLC/Config.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # # PLCAPI configuration store. Supports XML-based configuration file # format exported by MyPLC. @@ -6,8 +5,6 @@ # Mark Huang # Copyright (C) 2004-2006 The Trustees of Princeton University # -# $Id: Config.py,v 1.2 2006/09/06 19:15:59 mlhuang Exp $ -# import os import sys @@ -31,11 +28,11 @@ class Config: def __init__(self, file = "/etc/planetlab/plc_config"): # Load plc_config try: - execfile(file, self.__dict__) + exec(compile(open(file).read(), file, 'exec'), self.__dict__) except: # Try myplc directory try: - execfile(myplc + os.sep + "plc_config", self.__dict__) + exec(compile(open(myplc + os.sep + "plc_config").read(), myplc + os.sep + "plc_config", 'exec'), self.__dict__) except: raise PLCAPIError("Could not find plc_config in " + \ file + ", " + \ @@ -66,8 +63,8 @@ class XMLConfig: file + ", " + \ myplc + os.sep + "plc_config.xml") - for (category, variablelist) in cfg.variables().values(): - for variable in variablelist.values(): + for (category, variablelist) in list(cfg.variables().values()): + for variable in list(variablelist.values()): # Try to cast each variable to an appropriate Python # type. if variable['type'] == "int": @@ -93,4 +90,4 @@ class XMLConfig: if __name__ == '__main__': import pprint pprint = pprint.PrettyPrinter() - pprint.pprint(Config().__dict__.items()) + pprint.pprint(list(Config().__dict__.items()))