|
|
|
@ -275,8 +275,24 @@ class fillVars(glob_attr):
|
|
|
|
|
else:
|
|
|
|
|
return domain
|
|
|
|
|
|
|
|
|
|
dictLinuxName = {"CLD":"Calculate Linux Desktop",
|
|
|
|
|
"CLDX":"Calculate Linux Desktop",
|
|
|
|
|
"CLDG":"Calculate Linux Desktop",
|
|
|
|
|
"CDS":"Calculate Directory Server",
|
|
|
|
|
"CLS":"Calculate Linx Scratch",
|
|
|
|
|
"CSS":"Calculate Scratch Server",
|
|
|
|
|
"Gentoo":"Gentoo"}
|
|
|
|
|
|
|
|
|
|
def get_os_linux_shortname(self):
|
|
|
|
|
'''Получить переменную короткого названия системы'''
|
|
|
|
|
makeprofile = '/etc/make.profile'
|
|
|
|
|
if os.path.exists(makeprofile):
|
|
|
|
|
link = os.readlink(makeprofile)
|
|
|
|
|
reMakeProfileLink = re.compile('calculate/(desktop|server)/(%s)'%
|
|
|
|
|
"|".join(self.dictLinuxName.keys()),re.S)
|
|
|
|
|
shortnameSearch = reMakeProfileLink.search(link)
|
|
|
|
|
if shortnameSearch:
|
|
|
|
|
return shortnameSearch.groups()[1]
|
|
|
|
|
path = '/etc/calculate/calculate.ini'
|
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
FD = open(path)
|
|
|
|
@ -299,15 +315,8 @@ class fillVars(glob_attr):
|
|
|
|
|
"""полное название системы"""
|
|
|
|
|
linuxShortName = self.Get("os_linux_shortname")
|
|
|
|
|
if linuxShortName:
|
|
|
|
|
dictLinuxName = {"CLD":"Calculate Linux Desktop",
|
|
|
|
|
"CLDX":"Calculate Linux Desktop",
|
|
|
|
|
"CLDG":"Calculate Linux Desktop",
|
|
|
|
|
"CDS":"Calculate Directory Server",
|
|
|
|
|
"CLS":"Calculate Linx Scratch",
|
|
|
|
|
"CSS":"Calculate Scratch Server",
|
|
|
|
|
"Gentoo":"Gentoo"}
|
|
|
|
|
if linuxShortName in dictLinuxName.keys():
|
|
|
|
|
return dictLinuxName[linuxShortName]
|
|
|
|
|
if linuxShortName in self.dictLinuxName.keys():
|
|
|
|
|
return self.dictLinuxName[linuxShortName]
|
|
|
|
|
else:
|
|
|
|
|
return "Linux"
|
|
|
|
|
else:
|
|
|
|
@ -326,32 +335,51 @@ class fillVars(glob_attr):
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def get_os_linux_ver(self):
|
|
|
|
|
'''Получить версию системы'''
|
|
|
|
|
path = '/etc/calculate/calculate.ini'
|
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
FD = open(path)
|
|
|
|
|
data = FD.readlines()
|
|
|
|
|
FD.close()
|
|
|
|
|
shortNameList = filter(lambda y:y,
|
|
|
|
|
map(lambda x:\
|
|
|
|
|
len(x.split("="))==2 and\
|
|
|
|
|
x.split("=")[0]=="linuxver" and\
|
|
|
|
|
x.split("=")[1].strip(), data))
|
|
|
|
|
if shortNameList:
|
|
|
|
|
return shortNameList[0]
|
|
|
|
|
gentooFile = "/etc/gentoo-release"
|
|
|
|
|
systemVersion = ""
|
|
|
|
|
flagGentoo = False
|
|
|
|
|
if os.path.exists(gentooFile):
|
|
|
|
|
gentooLink = "/etc/make.profile"
|
|
|
|
|
if os.path.islink(gentooLink):
|
|
|
|
|
systemVersion = os.readlink(gentooLink).rpartition("/")[2]
|
|
|
|
|
flagGentoo = True
|
|
|
|
|
if not flagGentoo:
|
|
|
|
|
'''Get system version'''
|
|
|
|
|
def get_from_metapackage():
|
|
|
|
|
"""Get version from meta package"""
|
|
|
|
|
shortname = self.Get('os_linux_shortname')
|
|
|
|
|
metaPkgs = filter(lambda x:"%s-meta"%shortname.lower() in x,
|
|
|
|
|
os.listdir('/var/db/pkg/app-misc/'))
|
|
|
|
|
if metaPkgs:
|
|
|
|
|
reFindVer = re.compile("(?<=\-)\d+\.?\d*\.?\d*")
|
|
|
|
|
findVer = reFindVer.search(metaPkgs[0])
|
|
|
|
|
if findVer:
|
|
|
|
|
return findVer.group()
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def get_from_calculate_ini():
|
|
|
|
|
"""Get version from calculate ini"""
|
|
|
|
|
path = '/etc/calculate/calculate.ini'
|
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
FD = open(path)
|
|
|
|
|
data = FD.readlines()
|
|
|
|
|
FD.close()
|
|
|
|
|
shortNameList = filter(lambda y:y,
|
|
|
|
|
map(lambda x:\
|
|
|
|
|
len(x.split("="))==2 and\
|
|
|
|
|
x.split("=")[0]=="linuxver" and\
|
|
|
|
|
x.split("=")[1].strip(), data))
|
|
|
|
|
if shortNameList:
|
|
|
|
|
return shortNameList[0]
|
|
|
|
|
|
|
|
|
|
def get_from_gentoo_files():
|
|
|
|
|
"""Get version from gentoo files"""
|
|
|
|
|
gentooFile = "/etc/gentoo-release"
|
|
|
|
|
systemVersion = ""
|
|
|
|
|
flagGentoo = False
|
|
|
|
|
if os.path.exists(gentooFile):
|
|
|
|
|
gentooLink = "/etc/make.profile"
|
|
|
|
|
if os.path.islink(gentooLink):
|
|
|
|
|
return os.readlink(gentooLink).rpartition("/")[2]
|
|
|
|
|
|
|
|
|
|
def get_from_uname():
|
|
|
|
|
"""Get version from uname"""
|
|
|
|
|
kernelVersion=self._runos("uname -r")
|
|
|
|
|
if kernelVersion:
|
|
|
|
|
systemVersion = kernelVersion.partition("-")[0]
|
|
|
|
|
return systemVersion
|
|
|
|
|
return kernelVersion.partition("-")[0]
|
|
|
|
|
return get_from_metapackage() or get_from_calculate_ini() or \
|
|
|
|
|
get_from_gentoo_files() or get_from_uname() or "0"
|
|
|
|
|
|
|
|
|
|
def get_os_net_hostname(self):
|
|
|
|
|
'''Считать имя компьютера net_host'''
|
|
|
|
|