@ -604,6 +604,10 @@ class Distribution(object):
This is unit tested . Please extend the tests to cover all distributions if you have them available .
This is unit tested . Please extend the tests to cover all distributions if you have them available .
"""
"""
# every distribution name mentioned here, must have one of
# - allowempty == True
# - be listed in SEARCH_STRING
# - have a function get_distribution_DISTNAME implemented
OSDIST_LIST = (
OSDIST_LIST = (
{ ' path ' : ' /etc/oracle-release ' , ' name ' : ' OracleLinux ' } ,
{ ' path ' : ' /etc/oracle-release ' , ' name ' : ' OracleLinux ' } ,
{ ' path ' : ' /etc/slackware-version ' , ' name ' : ' Slackware ' } ,
{ ' path ' : ' /etc/slackware-version ' , ' name ' : ' Slackware ' } ,
@ -687,11 +691,11 @@ class Distribution(object):
if not os . path . exists ( path ) :
if not os . path . exists ( path ) :
continue
continue
if os . path . getsize ( path ) == 0 :
# if allowempty is set, we only check for file existance but not content
if ' allowempty ' in ddict and ddict [ ' allowempty ' ] :
if ' allowempty ' in ddict and ddict [ ' allowempty ' ] :
self . facts [ ' distribution ' ] = name
self . facts [ ' distribution ' ] = name
break
break
else :
if os . path . getsize ( path ) == 0 :
continue
continue
data = get_file_content ( path )
data = get_file_content ( path )
@ -707,6 +711,7 @@ class Distribution(object):
break
break
else :
else :
# call a dedicated function for parsing the file content
# call a dedicated function for parsing the file content
try :
distfunc = getattr ( self , ' get_distribution_ ' + name )
distfunc = getattr ( self , ' get_distribution_ ' + name )
parsed = distfunc ( name , data , path )
parsed = distfunc ( name , data , path )
if parsed is None or parsed :
if parsed is None or parsed :
@ -714,6 +719,11 @@ class Distribution(object):
# break only if parsing was succesful
# break only if parsing was succesful
# otherwise continue with other distributions
# otherwise continue with other distributions
break
break
except AttributeError :
# this should never happen, but if it does fail quitely and not with a traceback
pass
# to debug multiple matching release files, one can use:
# to debug multiple matching release files, one can use:
# self.facts['distribution_debug'].append({path + ' ' + name:
# self.facts['distribution_debug'].append({path + ' ' + name:
@ -780,10 +790,6 @@ class Distribution(object):
if release :
if release :
self . facts [ ' distribution_release ' ] = release . groups ( ) [ 0 ]
self . facts [ ' distribution_release ' ] = release . groups ( ) [ 0 ]
def get_distribution_Archlinux ( self , name , data , path ) :
self . facts [ ' distribution ' ] = ' Archlinux '
self . facts [ ' distribution_version ' ] = data
def get_distribution_Alpine ( self , name , data , path ) :
def get_distribution_Alpine ( self , name , data , path ) :
self . facts [ ' distribution ' ] = ' Alpine '
self . facts [ ' distribution ' ] = ' Alpine '
self . facts [ ' distribution_version ' ] = data
self . facts [ ' distribution_version ' ] = data