def unit_test():
    print "Testing the eros configuration file parser."
    config = ErosConfig()
    print "  Platforms Dir : %s" %config.user_platforms_dir() 
    print "  Toolchains Dir: %s" %config.user_toolchains_dir()
    config.new_user_platforms_dir("/opt/ros/ycs/platforms") 
    config.new_user_toolchains_dir("/opt/ros/ycs/toolchains") 
    config.new_user_platforms_dir(os.path.join(core.eros_home(),"toolchains")) 
    config.new_user_toolchains_dir(os.path.join(core.eros_home(),"platforms"))
 def check_for_eros_configuration(self):
     '''
     Creates a default configuration if it doesn't already exist.
     '''
     if(not os.path.exists(core.eros_home())):
         os.mkdir(core.eros_home())
     if(not os.path.exists(os.path.join(core.eros_home(),"toolchains"))):
         os.mkdir(os.path.join(core.eros_home(),"toolchains"))
     if(not os.path.exists(os.path.join(core.eros_home(),"platforms"))):
         os.mkdir(os.path.join(core.eros_home(),"platforms"))
     if (not os.path.exists(core.eros_config())):
         config = ConfigParser.RawConfigParser()
         config.add_section('Platforms')
         config.add_section('Toolchains')
         config.set('Platforms', 'user_platforms_dir', os.path.join(core.eros_home(),"platforms"))
         config.set('Toolchains', 'user_toolchains_dir', os.path.join(core.eros_home(),"toolchains"))
         # Writing the configuration file
         with open(core.eros_config(), 'wb') as configfile:
             config.write(configfile)
###############################################################################
# Supporting Methods
###############################################################################

def eros_rosconfig_tail():
    return os.path.join(roslib.packages.get_pkg_dir('eros_python_tools'),"templates","rosconfig.tail.cmake")

def eros_platform_template():
    return os.path.join(roslib.packages.get_pkg_dir('eros_python_tools'),"templates","rosconfig.template.cmake")

def eros_platform_dir():
    return os.path.join(roslib.packages.get_pkg_dir('eros_platforms'),"library")

# global variable for the user platforms dir, access via user_platform_dir()
_user_platforms_dir = os.path.join(core.eros_home(),"platforms")

def user_platform_dir(dir=None):
    global _user_platforms_dir
    if ( dir != None ):
        if ( not os.path.exists(dir) ):
            raise Exception('Specified directory does not exist.')
        _user_platforms_dir = dir
    return _user_platforms_dir

# global variable for the platform list, access via platform_list()
platforms = []

def platform_list():
    """
    Both provides access to and populates the platform list for both eros and user-defined
 def __init__(self):
     self.check_for_eros_configuration()
     self.config = ConfigParser.RawConfigParser()
     self.config.read(os.path.join(core.eros_home(),"eros.cfg"))
        print "  Compilers validated: "
        print "    gcc : " + toolchain_gcc_pathname
        print "    gpp : " + toolchain_gpp_pathname
        
###############################################################################
# Methods
###############################################################################
    
def eros_toolchain_template():
    return os.path.join(roslib.packages.get_pkg_dir('eros_python_tools'),"templates","rostoolchain.template.cmake")
    
def eros_toolchain_dir():
    return os.path.join(roslib.packages.get_pkg_dir('eros_toolchains'),"library")

# global variable for the user toolchains dir, access via user_toolchain_dir()
_user_toolchains_dir = os.path.join(core.eros_home(),"toolchains")

def user_toolchain_dir(dir=None):
    global _user_toolchains_dir
    if ( dir != None ):
        if ( not os.path.exists(dir) ):
            raise Exception('Specified directory does not exist.')
        _user_toolchains_dir = dir
    return _user_toolchains_dir

# global variable for the toolchain list, access via toolchain_list()
toolchains = []

def toolchain_list():
    """
    Both provides access to and populates the toolchain list from both eros and user-defined