Исправлена смена профиля

master3.4 3.4.7.3
parent be07c37b14
commit d81fc4b781

@ -23,7 +23,7 @@ from calculate.lib.cl_log import log
from calculate.lib.datavars import (Variable, VariableError, from calculate.lib.datavars import (Variable, VariableError,
ReadonlyVariable, ReadonlyTableVariable, ReadonlyVariable, ReadonlyTableVariable,
TableVariable, FieldValue, TableVariable, FieldValue,
HumanReadable, HumanReadable, CriticalError,
SimpleDataVars, DataVarsError) SimpleDataVars, DataVarsError)
from calculate.lib.utils.binhosts import Binhosts from calculate.lib.utils.binhosts import Binhosts
from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin
@ -930,6 +930,7 @@ class VariableClUpdateProfileUrl(Variable):
""" """
untrusted = True untrusted = True
check_after = ["cl_update_profile_branch"] check_after = ["cl_update_profile_branch"]
check_action = "update_profile"
opt = ["--url"] opt = ["--url"]
metavalue = "URL" metavalue = "URL"
@ -944,6 +945,10 @@ class VariableClUpdateProfileUrl(Variable):
def current_root(self): def current_root(self):
return '/' return '/'
@property
def rep_names(self):
return self.Get("update.cl_update_rep_name")
def init(self): def init(self):
self.label = _("Profile repository") self.label = _("Profile repository")
self.help = _("set the profile repository") self.help = _("set the profile repository")
@ -1004,13 +1009,24 @@ class VariableClUpdateProfileUrl(Variable):
profile = self.Get(self.profile) profile = self.Get(self.profile)
if profile: if profile:
while (profile != self.current_root and while (profile != self.current_root and
".git" not in listDirectory(profile)): ".git" not in listDirectory(profile) and
"repo_name" not in listDirectory(
path.join(profile,"profiles"))):
profile = path.dirname(profile) profile = path.dirname(profile)
if profile == self.current_root: if profile == self.current_root:
return "" return self.default_url
if ".git" not in listDirectory(profile):
repo_name = readFile(path.join(
profile,"profiles/repo_name")).strip()
if (repo_name in self.rep_names and
self.Get('cl_action') == self.check_action):
raise CriticalError(
_("You need update repositories before change profile"))
git = Git() git = Git()
return git.get_url(profile, "origin") or "" return git.get_url(profile, "origin") or self.default_url
except Exception: except CriticalError as e:
raise VariableError(str(e))
except Exception as e:
pass pass
return self.default_url return self.default_url

Loading…
Cancel
Save