Browse Source

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

tags/3.4.7.3
parent
commit
d81fc4b781
1 changed files with 21 additions and 5 deletions
  1. +21
    -5
      pym/update/variables/update.py

+ 21
- 5
pym/update/variables/update.py View File

@@ -23,7 +23,7 @@ from calculate.lib.cl_log import log
from calculate.lib.datavars import (Variable, VariableError,
ReadonlyVariable, ReadonlyTableVariable,
TableVariable, FieldValue,
HumanReadable,
HumanReadable, CriticalError,
SimpleDataVars, DataVarsError)
from calculate.lib.utils.binhosts import Binhosts
from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin
@@ -930,6 +930,7 @@ class VariableClUpdateProfileUrl(Variable):
"""
untrusted = True
check_after = ["cl_update_profile_branch"]
check_action = "update_profile"

opt = ["--url"]
metavalue = "URL"
@@ -944,6 +945,10 @@ class VariableClUpdateProfileUrl(Variable):
def current_root(self):
return '/'

@property
def rep_names(self):
return self.Get("update.cl_update_rep_name")

def init(self):
self.label = _("Profile repository")
self.help = _("set the profile repository")
@@ -1004,13 +1009,24 @@ class VariableClUpdateProfileUrl(Variable):
profile = self.Get(self.profile)
if profile:
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)
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()
return git.get_url(profile, "origin") or ""
except Exception:
return git.get_url(profile, "origin") or self.default_url
except CriticalError as e:
raise VariableError(str(e))
except Exception as e:
pass
return self.default_url



Loading…
Cancel
Save