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.
202 lines
8.2 KiB
202 lines
8.2 KiB
11 years ago
|
diff --git calculate/lib/cl_progressbar.py calculate/lib/cl_progressbar.py
|
||
|
index 36bb6c4..5734d28 100644
|
||
|
--- calculate/lib/cl_progressbar.py
|
||
|
+++ calculate/lib/cl_progressbar.py
|
||
|
@@ -110,6 +110,7 @@ try:
|
||
|
|
||
|
def __init__(self):
|
||
|
self.outQueue = Queue()
|
||
|
+ self.finished = False
|
||
|
self.inQueue = Queue()
|
||
|
Process(target=self.runProgress,
|
||
|
args=(self.outQueue,self.inQueue)).start()
|
||
|
@@ -127,6 +128,7 @@ try:
|
||
|
|
||
|
def quit(self):
|
||
|
self.outQueue.put(("quit",(),False))
|
||
|
+ self.finished = True
|
||
|
self.outQueue.close()
|
||
|
self.inQueue.close()
|
||
|
except:
|
||
|
diff --git calculate/lib/datavars.py calculate/lib/datavars.py
|
||
|
index 1881294..b5f2d33 100644
|
||
|
--- calculate/lib/datavars.py
|
||
|
+++ calculate/lib/datavars.py
|
||
|
@@ -48,6 +48,9 @@ def itemgetter(*args,**kwargs):
|
||
|
return lambda x:(x[args[0]],)
|
||
|
return operator.itemgetter(*args)
|
||
|
|
||
|
+class CriticalError(Exception):
|
||
|
+ """Critical error"""
|
||
|
+
|
||
|
class DataVarsError(Exception):
|
||
|
"""Exception of getting variable values"""
|
||
|
|
||
|
@@ -1017,9 +1020,13 @@ class DataVars(SimpleDataVars):
|
||
|
"""
|
||
|
if not self.iniCache:
|
||
|
# get initialized section names
|
||
|
- if os.path.exists('/etc/make.profile'):
|
||
|
+ try:
|
||
|
+ make_profile = self.Get('main.cl_make_profile')
|
||
|
+ except VariableError as e:
|
||
|
+ raise CriticalError(str(e))
|
||
|
+ if os.path.exists(make_profile):
|
||
|
profiles = [('profile',
|
||
|
- path.join('/etc',os.readlink('/etc/make.profile')))]
|
||
|
+ path.join('/etc',os.readlink(make_profile)))]
|
||
|
else:
|
||
|
profiles = []
|
||
|
for iniName,iniFile in profiles+\
|
||
|
diff --git calculate/lib/utils/colortext/printing.py calculate/lib/utils/colortext/printing.py
|
||
|
index 147d1d7..75227ee 100644
|
||
|
--- calculate/lib/utils/colortext/printing.py
|
||
|
+++ calculate/lib/utils/colortext/printing.py
|
||
|
@@ -32,6 +32,11 @@ class Print(object):
|
||
|
self.buffer.append(self.output.setBold())
|
||
|
return self
|
||
|
|
||
|
+ @property
|
||
|
+ def underline(self):
|
||
|
+ self.buffer.append(self.output.setUnderline())
|
||
|
+ return self
|
||
|
+
|
||
|
def foreground(self, color):
|
||
|
self.buffer.append(self.output.setForeground(color))
|
||
|
return self
|
||
|
diff --git calculate/lib/variables/env.py calculate/lib/variables/env.py
|
||
|
index ab295ca..87d43cc 100644
|
||
|
--- calculate/lib/variables/env.py
|
||
|
+++ calculate/lib/variables/env.py
|
||
|
@@ -414,6 +414,17 @@ class VariableClMakeProfile(Variable):
|
||
|
"""
|
||
|
Путь до актуального make.profile
|
||
|
"""
|
||
|
+ systemRoot = "/"
|
||
|
+
|
||
|
+ def get_work_link(self, *links):
|
||
|
+ for link in links:
|
||
|
+ if path.exists(link):
|
||
|
+ return link
|
||
|
+
|
||
|
def get(self):
|
||
|
- # TODO: заглушка, нужно учитывать /etc/portage/make.profile
|
||
|
- return "/etc/make.profile"
|
||
|
+ files = ["etc/portage/make.profile", "etc/make.profile"]
|
||
|
+ val = self.get_work_link(
|
||
|
+ *[path.join(self.systemRoot, x) for x in files])
|
||
|
+ if not val:
|
||
|
+ raise VariableError(_("Failed to detect system profile"))
|
||
|
+ return val
|
||
|
diff --git calculate/lib/variables/linux.py calculate/lib/variables/linux.py
|
||
|
index 5d907f6..d49c773 100644
|
||
|
--- calculate/lib/variables/linux.py
|
||
|
+++ calculate/lib/variables/linux.py
|
||
|
@@ -18,10 +18,10 @@ import os
|
||
|
from os import path
|
||
|
import re
|
||
|
import platform
|
||
|
-from calculate.lib.datavars import Variable,ReadonlyVariable,SimpleDataVars
|
||
|
+from calculate.lib.datavars import Variable, SimpleDataVars
|
||
|
from calculate.lib.utils.portage import isPkgInstalled
|
||
|
-from calculate.lib.utils.files import countFiles,readFile
|
||
|
-import calculate.lib.cl_template as cl_template
|
||
|
+from calculate.lib.utils.files import readFile
|
||
|
+from env import VariableClMakeProfile
|
||
|
|
||
|
class Linux:
|
||
|
dictLinuxName = {"CLD":"Calculate Linux Desktop",
|
||
|
@@ -51,7 +51,7 @@ class Linux:
|
||
|
|
||
|
def getShortnameByMakeprofile(self,systemroot):
|
||
|
"""Get shortname by symlink of make.profile"""
|
||
|
- makeprofile = path.join(systemroot,'etc/make.profile')
|
||
|
+ makeprofile = self.Get('cl_make_profile')
|
||
|
if path.exists(makeprofile):
|
||
|
link = os.readlink(makeprofile)
|
||
|
reMakeProfileLink = re.compile('/calculate/(desktop|server)/(%s)/'%
|
||
|
@@ -78,11 +78,11 @@ class Linux:
|
||
|
|
||
|
def detectOtherShortname(self,systemroot):
|
||
|
"""Detect other system. Now only Gentoo."""
|
||
|
- gentooFile = path.join(systemroot,"etc/gentoo-release")
|
||
|
+ gentooFile = path.join(systemroot, "etc/gentoo-release")
|
||
|
if path.exists(gentooFile):
|
||
|
return "Gentoo"
|
||
|
- if all(map(lambda x:path.lexists(path.join(systemroot,x)),
|
||
|
- ['bin','var','lib','etc'])):
|
||
|
+ if all(map(lambda x: path.lexists(path.join(systemroot, x)),
|
||
|
+ ['bin', 'var', 'lib', 'etc'])):
|
||
|
return "Linux"
|
||
|
return None
|
||
|
|
||
|
@@ -92,17 +92,17 @@ class Linux:
|
||
|
"""
|
||
|
overlayPath = 'var/lib/layman/calculate'
|
||
|
releaseFile = 'profiles/calculate-release'
|
||
|
- return readFile(path.join(systemroot,overlayPath,releaseFile))
|
||
|
+ return readFile(path.join(systemroot, overlayPath, releaseFile))
|
||
|
|
||
|
def getVersionFromMetapackage(self,systemroot,shortname):
|
||
|
"""Get version from meta package"""
|
||
|
- for pkg in ("app-misc/calculate-meta","app-misc/%s-meta"%shortname):
|
||
|
- calcMeta = isPkgInstalled(pkg,systemroot)
|
||
|
+ for pkg in ("app-misc/calculate-meta", "app-misc/%s-meta" % shortname):
|
||
|
+ calcMeta = isPkgInstalled(pkg, systemroot)
|
||
|
if calcMeta:
|
||
|
return calcMeta[0]['PV']
|
||
|
return None
|
||
|
|
||
|
- def getVersionFromCalculateIni(self,systemroot):
|
||
|
+ def getVersionFromCalculateIni(self, systemroot):
|
||
|
"""Get version from calculate ini"""
|
||
|
pathname = path.join(systemroot,
|
||
|
'etc/calculate/calculate.ini')
|
||
|
@@ -124,11 +124,9 @@ class Linux:
|
||
|
def getVersionFromGentooFiles(self,systemroot):
|
||
|
"""Get version from gentoo files"""
|
||
|
gentooFile = path.join(systemroot,"etc/gentoo-release")
|
||
|
- systemVersion = ""
|
||
|
- flagGentoo = False
|
||
|
reVer=re.compile("^(\d+\.)*\d+$",re.S)
|
||
|
if path.exists(gentooFile):
|
||
|
- gentooLink = path.join(systemroot,"etc/make.profile")
|
||
|
+ gentooLink = self.Get('cl_make_profile')
|
||
|
if path.islink(gentooLink):
|
||
|
vers = filter(reVer.search,
|
||
|
os.readlink(gentooLink).split('/'))
|
||
|
@@ -227,9 +225,10 @@ class VariableOsLinuxFiles(Variable,Linux):
|
||
|
|
||
|
|
||
|
class LinuxDataVars(SimpleDataVars):
|
||
|
- def __init__(self,systemRoot="/"):
|
||
|
+ def __init__(self, systemRoot="/"):
|
||
|
self.systemRoot = systemRoot
|
||
|
SimpleDataVars.__init__(self,
|
||
|
+ VariableClMakeProfile(systemRoot=systemRoot),
|
||
|
VariableOsLinuxShortname(systemRoot=systemRoot),
|
||
|
VariableOsLinuxName(systemRoot=systemRoot),
|
||
|
VariableOsLinuxSubname(systemRoot=systemRoot),
|
||
|
@@ -238,14 +237,12 @@ class LinuxDataVars(SimpleDataVars):
|
||
|
VariableOsLinuxSystem(systemRoot=systemRoot),
|
||
|
VariableOsLinuxVer(systemRoot=systemRoot),
|
||
|
VariableOsLinuxBuild(systemRoot=systemRoot))
|
||
|
- makeprofile = path.join(systemRoot,'etc/make.profile')
|
||
|
+ makeprofile = self.Get('cl_make_profile')
|
||
|
if os.path.exists(makeprofile):
|
||
|
- inifile = path.join(systemRoot,'etc',
|
||
|
- os.readlink(path.join(systemRoot,'etc/make.profile')))
|
||
|
+ inifile = path.join(systemRoot, 'etc',
|
||
|
+ os.readlink(makeprofile))
|
||
|
self.flIniFileFrom(inifile)
|
||
|
- inifile = "etc/calculate/calculate.env"
|
||
|
- self.flIniFileFrom(path.join(systemRoot,inifile))
|
||
|
- iniFile = "etc/calculate/calculate3.env"
|
||
|
- self.flIniFileFrom(path.join(systemRoot,iniFile))
|
||
|
- iniFile = "etc/calculate/calculate2.env"
|
||
|
- self.flIniFileFrom(path.join(systemRoot,iniFile))
|
||
|
+ for inifile in ("etc/calculate/calculate.env",
|
||
|
+ "etc/calculate/calculate3.env",
|
||
|
+ "etc/calculate/calculate2.env"):
|
||
|
+ self.flIniFileFrom(path.join(systemRoot, inifile))
|