#-*- coding: utf-8 -*- #Copyright 2008 Calculate Pack, http://www.calculate-linux.ru # # 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 os import re import cl_base class fillVars(object, cl_base.glob_attr): def get_cl_profile_path(self): """список накладываемых профилей при установке, наложении профилей""" profpath = [] profPaths = ['/usr/lib/calculate/calculate-client/profile', '/var/calculate/remote/client-profile', '/var/calculate/client-profile' ] for profPath in profPaths: if os.path.exists(profPath): paths = os.listdir(profPath) for path in paths: ph = os.path.join(profPath,path) if os.path.exists(ph) and os.listdir(ph): profpath.append(ph) return profpath def getX11Resolution(self): """возвращает текущее разрешение экрана (ширина, высота), X запущен""" lines=self._runos("%s xdpyinfo -display :0.0"%self.path_env) reRes = re.compile("dimensions:\s+(\d+)x(\d+)\s+pixels") searchRes=False for line in lines: searchRes = reRes.search(line) if searchRes: break if searchRes: return (searchRes.group(1), searchRes.group(2)) else: return False def get_hr_x11_height(self): """Получить высоту экрана в пикселах""" resolution = self.getX11Resolution() if resolution: self.Set('hr_x11_width',resolution[0]) return resolution[1] def get_hr_x11_width(self): """Получить ширину экрана в пикселах""" resolution = self.getX11Resolution() if resolution: self.Set('hr_x11_height',resolution[1]) return resolution[0]