Add EDID variables and DPI

3.6.8.1
parent 377f714b9d
commit b9164a7792

@ -33,6 +33,7 @@ from calculate.lib.utils.common import (getVideoFromXorgLog,
getVideoFromModules,
getVideoFromVendor, getInstalledVideo,
CmdlineParams)
from calculate.lib.utils.video import get_edid_data, EdidInfoError, EdidInfo
from calculate.install.distr import DistributiveError
import fcntl
import struct
@ -480,3 +481,55 @@ class VariableClSplashImageUpdateSet(VariableClSplashImageHash):
newmd5 = self.get_hash_data(self.hash_files)
return "on" if newmd5 != self.Get('cl_splash_image_hash') else "off"
return "off"
class VariableClInstallEdidData(ReadonlyVariable):
type = Variable.Types.Object
def get(self):
edid_data = get_edid_data()
if not edid_data:
return {}
try:
ei = EdidInfo()
ei.set_data(edid_data)
return {
"resolution": ei.resolution,
"ratio": ei.ratio,
"screensize": ei.screensize
}
except EdidInfoError as e:
raise VariableError(str(e))
class VariableClInstallEdidResolution(ReadonlyVariable):
def get(self):
return self.Get('cl_install_edid_data').get('resolution','')
class VariableClInstallEdidScreensize(ReadonlyVariable):
def get(self):
return self.Get('cl_install_edid_data').get('screensize','')
class VariableClInstallCalculateDpi(Variable):
def get(self):
inch = 25.4
screensize = self.Get('cl_install_edid_screensize')
resolution = self.Get('os_install_x11_resolution')
if screensize and resolution:
cx = screensize.partition("x")[0]
cxres = resolution.partition("x")[0]
if cx.isdigit() and cxres.isdigit():
cx = float(cx)
cxres = float(cxres)
return str(int(inch * cxres / cx))
return ""
class VariableClInstallDpi(Variable):
def get(self):
calculate_dpi = self.Get('cl_install_calculate_dpi')
try:
if calculate_dpi:
calculate_dpi = int(calculate_dpi)
if calculate_dpi > 100:
return "108"
except ValueError:
pass
return "96"

Loading…
Cancel
Save