!543 修复osid.in文件找不到的问题
Merge pull request !543 from zhangao/master_dev5
This commit is contained in:
@ -318,38 +318,12 @@ def linux_distribution(distname='', version='', idNum='',
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
is_flag_osid = False
|
is_flag_osid = False
|
||||||
|
is_flag_oscorrect = True
|
||||||
try:
|
try:
|
||||||
etc = os.listdir('/etc')
|
etc = os.listdir('/etc')
|
||||||
except os.error:
|
except os.error:
|
||||||
# Probably not a Unix system
|
# Probably not a Unix system
|
||||||
return distname, version, idNum
|
return distname, version, idNum
|
||||||
|
|
||||||
# Read system information from configuration file
|
|
||||||
# Call the function and pass in the filename
|
|
||||||
osid_path = os.path.realpath(
|
|
||||||
os.path.join(os.path.realpath(__file__), "../../../osid.in"))
|
|
||||||
|
|
||||||
if os.path.exists(osid_path):
|
|
||||||
file_data = parse_linux_distributions(osid_path)
|
|
||||||
|
|
||||||
# Output the parsed content
|
|
||||||
selected_data = select_linux_distribution(file_data)
|
|
||||||
|
|
||||||
if selected_data:
|
|
||||||
is_flag_osid = True
|
|
||||||
|
|
||||||
else:
|
|
||||||
print(f"The file '{osid_path}' does not exist.")
|
|
||||||
|
|
||||||
if is_flag_osid:
|
|
||||||
if selected_data['os']:
|
|
||||||
distname = selected_data['os']
|
|
||||||
if selected_data['version']:
|
|
||||||
version = selected_data['version']
|
|
||||||
if selected_data['bit']:
|
|
||||||
idNum = selected_data['bit']
|
|
||||||
return distname, version, idNum
|
|
||||||
|
|
||||||
sortEtc = sorted(etc)
|
sortEtc = sorted(etc)
|
||||||
gFile = None
|
gFile = None
|
||||||
for file in sortEtc:
|
for file in sortEtc:
|
||||||
@ -372,12 +346,41 @@ def linux_distribution(distname='', version='', idNum='',
|
|||||||
|
|
||||||
if _distname and full_distribution_name:
|
if _distname and full_distribution_name:
|
||||||
distname = _distname
|
distname = _distname
|
||||||
|
for dist in SUPPORT_WHOLE_PLATFORM_LIST:
|
||||||
|
if dist.lower == _distname.lower:
|
||||||
|
is_flag_oscorrect = True
|
||||||
if _version:
|
if _version:
|
||||||
version = _version
|
version = _version
|
||||||
if _id:
|
if _id:
|
||||||
idNum = _id
|
idNum = _id
|
||||||
return distname, version, idNum
|
if is_flag_oscorrect == True:
|
||||||
|
return distname, version, idNum
|
||||||
|
elif is_flag_oscorrect == False:
|
||||||
|
# Read system information from configuration file
|
||||||
|
# Call the function and pass in the filename
|
||||||
|
osid_path = os.path.realpath(
|
||||||
|
os.path.join(os.path.realpath(__file__), "../../../osid.conf"))
|
||||||
|
|
||||||
|
if os.path.exists(osid_path):
|
||||||
|
file_data = parse_linux_distributions(osid_path)
|
||||||
|
|
||||||
|
# Output the parsed content
|
||||||
|
selected_data = select_linux_distribution(file_data)
|
||||||
|
|
||||||
|
if selected_data:
|
||||||
|
is_flag_osid = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f"The file '{osid_path}' does not exist.")
|
||||||
|
|
||||||
|
if is_flag_osid:
|
||||||
|
if selected_data['os']:
|
||||||
|
distname = selected_data['os']
|
||||||
|
if selected_data['version']:
|
||||||
|
version = selected_data['version']
|
||||||
|
if selected_data['bit']:
|
||||||
|
idNum = selected_data['bit']
|
||||||
|
return distname, version, idNum
|
||||||
|
|
||||||
def dist(supported_dists=_supported_dists):
|
def dist(supported_dists=_supported_dists):
|
||||||
""" Tries to determine the name of the Linux OS distribution name.
|
""" Tries to determine the name of the Linux OS distribution name.
|
||||||
|
@ -24,7 +24,7 @@ import re
|
|||||||
import select
|
import select
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from os_platform.common import _supported_dists
|
from os_platform.common import _supported_dists,SUPPORT_WHOLE_PLATFORM_LIST
|
||||||
|
|
||||||
ISCONFIGURETRUE = "# isConfigure = TRUE"
|
ISCONFIGURETRUE = "# isConfigure = TRUE"
|
||||||
ISCONFIGUREFALSE = "# isConfigure = FALSE"
|
ISCONFIGUREFALSE = "# isConfigure = FALSE"
|
||||||
@ -237,40 +237,12 @@ class LinuxDistro(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
is_flag_osid = False
|
is_flag_osid = False
|
||||||
|
is_flag_oscorrect = True
|
||||||
try:
|
try:
|
||||||
etc_dir = os.listdir('/etc')
|
etc_dir = os.listdir('/etc')
|
||||||
except os.error:
|
except os.error:
|
||||||
# Probably not a Unix system
|
# Probably not a Unix system
|
||||||
return distname, version, idNum
|
return distname, version, idNum
|
||||||
|
|
||||||
# Read system information from configuration file
|
|
||||||
# Call the function and pass in the filename
|
|
||||||
osid_path = os.path.realpath(
|
|
||||||
os.path.join(os.path.realpath(__file__), "../../osid.in"))
|
|
||||||
|
|
||||||
if os.path.exists(osid_path):
|
|
||||||
file_data = LinuxDistro.parse_linux_distributions(osid_path)
|
|
||||||
|
|
||||||
# Output the parsed content
|
|
||||||
selected_data = LinuxDistro.select_linux_distribution(file_data)
|
|
||||||
|
|
||||||
if selected_data:
|
|
||||||
is_flag_osid = True
|
|
||||||
|
|
||||||
else:
|
|
||||||
print(f"The file '{osid_path}' does not exist.")
|
|
||||||
|
|
||||||
if is_flag_osid:
|
|
||||||
if selected_data['os']:
|
|
||||||
distname = selected_data['os']
|
|
||||||
if selected_data['version']:
|
|
||||||
version = selected_data['version']
|
|
||||||
if selected_data['bit']:
|
|
||||||
idNum = selected_data['bit']
|
|
||||||
return distname, version, idNum
|
|
||||||
# else:
|
|
||||||
# g_logger.debug("Start to distributing the check context dump file")
|
|
||||||
|
|
||||||
etc_dir.sort()
|
etc_dir.sort()
|
||||||
gFile = None
|
gFile = None
|
||||||
_release_filename = re.compile(r'(\w+)[-_](release|version)')
|
_release_filename = re.compile(r'(\w+)[-_](release|version)')
|
||||||
@ -294,8 +266,38 @@ class LinuxDistro(object):
|
|||||||
|
|
||||||
if _distname and full_distribution_name:
|
if _distname and full_distribution_name:
|
||||||
distname = _distname
|
distname = _distname
|
||||||
|
for dist in SUPPORT_WHOLE_PLATFORM_LIST:
|
||||||
|
if dist.lower == _distname.lower:
|
||||||
|
is_flag_oscorrect = True
|
||||||
if _version:
|
if _version:
|
||||||
version = _version
|
version = _version
|
||||||
if _id:
|
if _id:
|
||||||
idNum = _id
|
idNum = _id
|
||||||
return distname, version, idNum
|
if is_flag_oscorrect == True:
|
||||||
|
return distname, version, idNum
|
||||||
|
elif is_flag_oscorrect == False:
|
||||||
|
# Read system information from configuration file
|
||||||
|
# Call the function and pass in the filename
|
||||||
|
osid_path = os.path.realpath(
|
||||||
|
os.path.join(os.path.realpath(__file__), "../../osid.conf"))
|
||||||
|
|
||||||
|
if os.path.exists(osid_path):
|
||||||
|
file_data = LinuxDistro.parse_linux_distributions(osid_path)
|
||||||
|
|
||||||
|
# Output the parsed content
|
||||||
|
selected_data = LinuxDistro.select_linux_distribution(file_data)
|
||||||
|
|
||||||
|
if selected_data:
|
||||||
|
is_flag_osid = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f"The file '{osid_path}' does not exist.")
|
||||||
|
|
||||||
|
if is_flag_osid:
|
||||||
|
if selected_data['os']:
|
||||||
|
distname = selected_data['os']
|
||||||
|
if selected_data['version']:
|
||||||
|
version = selected_data['version']
|
||||||
|
if selected_data['bit']:
|
||||||
|
idNum = selected_data['bit']
|
||||||
|
return distname, version, idNum
|
||||||
|
Reference in New Issue
Block a user