You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-utils-3-install/pym/install/variables/linux.py

95 lines
2.8 KiB

9 years ago
# -*- coding: utf-8 -*-
# Copyright 2008-2016 Mir Calculate. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
9 years ago
from calculate.lib.datavars import ReadonlyVariable, VariableInterface
from calculate.lib.variables.linux import Linux
from calculate.lib.cl_lang import setLocalTranslate
9 years ago
setLocalTranslate('cl_install3', sys.modules[__name__])
class InstallLinux(Linux, VariableInterface):
def __getFromImageOrCurrent(self, currentVar):
"""Get value from install image or current system"""
if self.Get('cl_action') == 'system':
image = self.Get('cl_image')
if image:
d = image.getInfo()
# support lazy values
9 years ago
res = d.get(currentVar, "")
return str(res()) if callable(res) else res
else:
return ""
else:
return self.Get(currentVar)
# variable for get current system info (example: os_linux_shortname)
current_variable = ""
# field of distroinfo (name,ver,build,march and etc)
distroinfo_field = ""
def get(self):
"""Get by distroinfo or current info"""
12 years ago
return self.__getFromImageOrCurrent(self.current_variable)
9 years ago
class VariableOsInstallLinuxShortname(InstallLinux, ReadonlyVariable):
"""Shortname of system"""
current_variable = "os_linux_shortname"
9 years ago
class VariableOsInstallLinuxVer(InstallLinux, ReadonlyVariable):
"""Version of system"""
current_variable = "os_linux_ver"
9 years ago
class VariableOsInstallLinuxBuild(InstallLinux, ReadonlyVariable):
"""Build of system"""
current_variable = "os_linux_build"
9 years ago
class VariableOsInstallArchMachine(InstallLinux, ReadonlyVariable):
"""Arch of system"""
current_variable = "os_arch_machine"
9 years ago
class VariableOsInstallLinuxFiles(InstallLinux, ReadonlyVariable):
"""Files num in system"""
current_variable = "os_linux_files"
13 years ago
9 years ago
class VariableOsInstallLinuxName(InstallLinux, ReadonlyVariable):
"""
Install distro name
"""
12 years ago
current_variable = "os_linux_name"
9 years ago
class VariableOsInstallLinuxSystem(InstallLinux, ReadonlyVariable):
"""
Install system name
"""
12 years ago
current_variable = "os_linux_system"
9 years ago
class VariableOsInstallLinuxSubname(InstallLinux, ReadonlyVariable):
"""
Install subname
"""
12 years ago
current_variable = "os_linux_subname"