diff --git a/pym/cl_distr.py b/pym/cl_distr.py index 30d7370..faaa575 100644 --- a/pym/cl_distr.py +++ b/pym/cl_distr.py @@ -127,38 +127,43 @@ class DistributiveRepository: else: return {} + def _getfromcontent(self,filename): + """Get info from content""" + varsShare = self.varsShare + distr = None + # may be directory is isodir (directory which contains iso image) + extname = "isodir" + try: + distr = IsoDistributive(filename) + filename = distr.convertToDirectory().directory + except Exception,e: + extname = "dir" + d = self.ini_to_dict(path.join(filename, + 'etc/calculate/calculate.ini')) + if not d or not "march" in d: + if path.exists(path.join(filename,'lib64')): + d['march'] = 'x86_64' + else: + d['march']= 'i686' + if d: + d['ext'] = extname + d["name"] = varsShare.getShortnameByMakeprofile(filename) or \ + varsShare.getShortnameByIni(filename) or \ + varsShare.detectOtherShortname(filename) or \ + "Linux" + d['ver'] = \ + varsShare.getVersionFromMetapackage(filename,d["name"]) or \ + varsShare.getVersionFromCalculateIni(filename) or "0" + if distr: + distr.close() + return d + def _getdistrinfo(self,filename): """Get information by distributive""" varsShare = self.varsShare # if filename is directory if path.isdir(filename): - distr = None - # may be directory is isodir (directory which contains iso image) - extname = "isodir" - try: - distr = IsoDistributive(filename) - filename = distr.convertToDirectory().directory - except Exception,e: - extname = "dir" - d = self.ini_to_dict(path.join(filename, - 'etc/calculate/calculate.ini')) - if not d or not "march" in d: - if path.exists(path.join(filename,'lib64')): - d['march'] = 'x86_64' - else: - d['march']= 'i686' - if d: - d['ext'] = extname - d["name"] = varsShare.getShortnameByMakeprofile(filename) or \ - varsShare.getShortnameByIni(filename) or \ - varsShare.detectOtherShortname(filename) or \ - "Linux" - d['ver'] = \ - varsShare.getVersionFromMetapackage(filename,d["name"]) or \ - varsShare.getVersionFromCalculateIni(filename) or "0" - if distr: - distr.close() - return d + return self._getfromcontent(filename) else: match = self.reDistName.match(filename) if not match: diff --git a/pym/cl_fill_install.py b/pym/cl_fill_install.py index 9667597..fc01400 100644 --- a/pym/cl_fill_install.py +++ b/pym/cl_fill_install.py @@ -587,7 +587,8 @@ class fillVars(object, glob_attr): self.Get('cl_image_path'), self.Get('os_install_arch_machine'), self.Get('os_install_linux_shortname'), - self.Get('os_install_linux_ver')) + None) + #self.Get('os_install_linux_ver')) def get_os_install_linux_shortname(self): """Shortname of installation os""" @@ -607,19 +608,20 @@ class fillVars(object, glob_attr): self.Get('cl_image_path'), self.Get('os_install_arch_machine'), self.Get('os_install_linux_shortname')) - res = DistributiveRepository.reDistName.search(imagename) - if res: - return res.groupdict()['ver'] - elif path.isdir(imagename): - d = DistributiveRepository()._getdistrinfo(imagename) - if "linuxver" in d: - return d['linuxver'] - if "ver" in d: - return d['ver'] + if not imagename: + return "" + d = DistributiveRepository()._getfromcontent(imagename) + if "linuxver" in d: + return d['linuxver'] + elif "ver" in d: + return d['ver'] else: if self.Get('os_install_linux_shortname') == \ self.Get('os_linux_shortname'): return self.Get('os_linux_ver') + res = DistributiveRepository.reDistName.search(imagename) + if res: + return res.groupdict()['ver'] return "" def get_cl_pkgdir_path(self): diff --git a/pym/cl_share_cmd.py b/pym/cl_share_cmd.py index 10b06fb..9f6d395 100644 --- a/pym/cl_share_cmd.py +++ b/pym/cl_share_cmd.py @@ -19,6 +19,7 @@ import os from cl_print import color_print from cl_utils import _error +import cl_install # Перевод сообщений для программы from cl_lang import lang @@ -57,6 +58,8 @@ class share_cmd(color_print, _error): v = int(optObj.v) except: v = 1 + cl_overriding.exit = cl_install.defaultExit + cl_overriding.printERROR = cl_install.defaultPrintERROR self.logicObj.clVars.printVars(varsFilter, varsNames, outFormat=format, verbose=v) diff --git a/pym/cl_vars_install.py b/pym/cl_vars_install.py index fd82a62..61d5e03 100644 --- a/pym/cl_vars_install.py +++ b/pym/cl_vars_install.py @@ -155,7 +155,7 @@ class Data: os_install_linguas = {'mode':'w'} # linux version of installation os - os_install_linux_ver = {'mode':'w'} + os_install_linux_ver = {'mode':'r'} # subname of installation os os_install_linux_subname = {'mode':'w'}