Py3 changes

migration_mirror
idziubenko 3 years ago
parent 659f1d1920
commit 10922f61c6

6
.gitignore vendored

@ -0,0 +1,6 @@
revert_changes_to_vmachine
push_to_vmachine*
.vscode
*.pyc
*.pyo
*.bak

@ -192,8 +192,8 @@ class InfoBlockInterface(object):
class EmergeInformationBlock(InfoBlockInterface): class EmergeInformationBlock(InfoBlockInterface):
_color_block = "(?:\033\[[^m]+?m)?" _color_block = r"(?:\033\[[^m]+?m)?"
_new_line = "(?:\r*\n)" _new_line = r"(?:\r*\n)"
end_token = ["\n"] end_token = ["\n"]
re_block = None re_block = None
re_match_type = type(re.match("", "")) re_match_type = type(re.match("", ""))
@ -433,7 +433,7 @@ class QuestionGroup(GroupEmergeInformationBlock):
end_token = ["]", "\n"] end_token = ["]", "\n"]
_color_block = EmergeInformationBlock._color_block _color_block = EmergeInformationBlock._color_block
re_block = re.compile( re_block = re.compile(
"(Would you.*)\[{c}Yes{c}/{c}No{c}".format(c=_color_block)) r"(Would you.*)\[{c}Yes{c}/{c}No{c}".format(c=_color_block))
def get_block(self, child): def get_block(self, child):
try: try:
@ -546,8 +546,8 @@ class EmergingPackage(NotifierInformationBlock):
_color_block = EmergeInformationBlock._color_block _color_block = EmergeInformationBlock._color_block
token = ">>> Emerging " token = ">>> Emerging "
re_block = re.compile( re_block = re.compile(
"Emerging (binary )?\({c}(\d+){c} " r"Emerging (binary )?\({c}(\d+){c} "
"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block)) r"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block))
def notify(self, observer, groups): def notify(self, observer, groups):
observer(EmergePackage(groups[3]), num=groups[1], max_num=groups[2], observer(EmergePackage(groups[3]), num=groups[1], max_num=groups[2],
@ -575,7 +575,7 @@ class FetchingTarball(NotifierInformationBlock):
Происходит скачивание архивов Происходит скачивание архивов
""" """
token = "Saving to:" token = "Saving to:"
re_block = re.compile("Saving to:\s*['](\S+)?[']") re_block = re.compile(r"Saving to:\s*['](\S+)?[']")
def notify(self, observer, groups): def notify(self, observer, groups):
observer(groups[0]) observer(groups[0])
@ -592,8 +592,8 @@ class InstallingPackage(NotifierInformationBlock):
token = ">>> Installing " token = ">>> Installing "
re_block = re.compile( re_block = re.compile(
"Installing \({c}(\d+){c} " r"Installing \({c}(\d+){c} "
"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block)) r"of {c}(\d+){c}\) {c}([^\s\033]+){c}".format(c=_color_block))
def notify(self, observer, groups): def notify(self, observer, groups):
strpkg = str(EmergePackage(groups[2])) strpkg = str(EmergePackage(groups[2]))
@ -612,8 +612,8 @@ class EmergeingErrorBlock(EmergeInformationBlock):
""" """
token = ["* ERROR: ", " * \033[39;49;00mERROR: "] token = ["* ERROR: ", " * \033[39;49;00mERROR: "]
end_token = "Working directory:" end_token = "Working directory:"
re_block = re.compile("ERROR: (\S*) failed \([^)]+\).*?" re_block = re.compile(r"ERROR: (\S*) failed \([^)]+\).*?"
"The complete build log is located at '([^']+)", r"The complete build log is located at '([^']+)",
re.DOTALL) re.DOTALL)
package = "" package = ""
@ -636,7 +636,8 @@ class RevdepPercentBlock(NotifierInformationBlock):
token = "Collecting system binaries" token = "Collecting system binaries"
end_token = [re.compile("Assigning files to packages|" end_token = [re.compile("Assigning files to packages|"
"All prepared. Starting rebuild")] "All prepared. Starting rebuild")]
re_block = re.compile("\[\s(\d+)%\s\]") # re_block = re.compile("\[\s(\d+)%\s\]")
re_block = re.compile(r"\[\s(\d+)%\s\]")
action = None action = None
def notify(self, observer, groups): def notify(self, observer, groups):

@ -158,7 +158,7 @@ class Profile(object):
@classmethod @classmethod
def from_string(cls, repository, s): def from_string(cls, repository, s):
parts = filter(None, s.split()) parts = list(filter(None, s.split()))
if len(parts) == 3 and parts[0] in cls.available_arch: if len(parts) == 3 and parts[0] in cls.available_arch:
return Profile(repository, parts[1], parts[0]) return Profile(repository, parts[1], parts[0])
return None return None
@ -261,8 +261,8 @@ class ProfileRepository(object):
Получить список профилей репозитория Получить список профилей репозитория
""" """
profiles_desc = path.join(self.directory, "profiles/profiles.desc") profiles_desc = path.join(self.directory, "profiles/profiles.desc")
return filter(None, (Profile.from_string(self, line) return list(filter(None, (Profile.from_string(self, line)
for line in readLinesFile(profiles_desc))) for line in readLinesFile(profiles_desc))))
def __repr__(self): def __repr__(self):
return "<ProfileRepository %s url=%s>" % (self.directory, self.url) return "<ProfileRepository %s url=%s>" % (self.directory, self.url)

@ -40,7 +40,7 @@ from calculate.lib.cl_log import log
import hashlib import hashlib
import re import re
import shutil import shutil
from collections import MutableSet from collections.abc import MutableSet
from contextlib import contextmanager from contextlib import contextmanager
import tempfile import tempfile
from fnmatch import fnmatch from fnmatch import fnmatch
@ -277,7 +277,7 @@ class Update(MethodsInterface):
self.printWARNING(_("Updates autocheck is not enabled")) self.printWARNING(_("Updates autocheck is not enabled"))
return False return False
last_check = SystemIni(self.clVars).getVar('system', 'last_check') or "" last_check = SystemIni(self.clVars).getVar('system', 'last_check') or ""
re_interval = re.compile("^(\d+)\s*(hours?|days?|weeks?)?", re.I) re_interval = re.compile(r"^(\d+)\s*(hours?|days?|weeks?)?", re.I)
interval_match = re_interval.search(interval) interval_match = re_interval.search(interval)
MINUTE = 60 MINUTE = 60
HOUR = MINUTE * 60 HOUR = MINUTE * 60

@ -70,7 +70,7 @@ class UpdateInfo(object):
""" """
Проверить есть ли уже запущенная копия console-gui Проверить есть ли уже запущенная копия console-gui
""" """
return any(filter(lambda x: "cl-console-gui" in x, getRunCommands())) return any(list(filter(lambda x: "cl-console-gui" in x, getRunCommands())))
def update_already_run(self): def update_already_run(self):
""" """

@ -453,8 +453,8 @@ class VariableClUpdateSyncOverlayRep(ReadonlyVariable):
type = "list" type = "list"
def get(self): def get(self):
return filter(lambda x: x not in ("portage", "gentoo"), return list(filter(lambda x: x not in ("portage", "gentoo"),
self.Get('cl_update_sync_rep')) self.Get('cl_update_sync_rep')))
class VariableClUpdateOutdateSet(ReadonlyVariable): class VariableClUpdateOutdateSet(ReadonlyVariable):
@ -782,11 +782,11 @@ class VariableClUpdateProfileDependData(ReadonlyTableVariable):
dv = self.Get(self.datavars) dv = self.Get(self.datavars)
if dv: if dv:
if hr == HumanReadable.Yes: if hr == HumanReadable.Yes:
return reversed(zip([x.capitalize() for x in dv.Get('cl_update_rep_name')], return reversed(list(zip([x.capitalize() for x in dv.Get('cl_update_rep_name')],
dv.Get('cl_update_rep_url'))) dv.Get('cl_update_rep_url'))))
else: else:
return reversed(zip(dv.Get('cl_update_rep_name'), return reversed(list(zip(dv.Get('cl_update_rep_name'),
dv.Get('cl_update_rep_url'))) dv.Get('cl_update_rep_url'))))
return "" return ""
setValue = Variable.setValue setValue = Variable.setValue
@ -828,7 +828,7 @@ class VariableClUpdateTemplatesLocate(Variable):
def choice(self): def choice(self):
descr = lambda x: self.descriptionMap.get(x, descr = lambda x: self.descriptionMap.get(x,
_("%s overlay templates" % x)) _("%s overlay templates" % x))
return map(lambda x: (x, descr(x)), self.get()) return list(map(lambda x: (x, descr(x)), self.get()))
class VariableClUpdateProfileDependName(FieldValue, ReadonlyVariable): class VariableClUpdateProfileDependName(FieldValue, ReadonlyVariable):
@ -936,7 +936,7 @@ class VariableClUpdateProfileUrl(Variable):
r"^(?:(%s)://)?((?:git@)?\w[\w\./:-]+?\w)(\.git)?$" % "|".join( r"^(?:(%s)://)?((?:git@)?\w[\w\./:-]+?\w)(\.git)?$" % "|".join(
["http", "https", "git", "ssh"])) ["http", "https", "git", "ssh"]))
re_shortname = re.compile('^(?:([\w\.-]+):)?([\w\.-]+)$') re_shortname = re.compile(r'^(?:([\w\.-]+):)?([\w\.-]+)$')
@classmethod @classmethod
def normalize_url(cls, url): def normalize_url(cls, url):
@ -1094,10 +1094,10 @@ class VariableClProfileData(ReadonlyTableVariable):
profile_arch = [x.arch for x in filtered_profiles] profile_arch = [x.arch for x in filtered_profiles]
short_name = simplify_profiles(full_name) short_name = simplify_profiles(full_name)
full_name = ["%s:%s" % (repo_name, x) for x in full_name] full_name = ["%s:%s" % (repo_name, x) for x in full_name]
return zip(full_name, return list(zip(full_name,
short_name, short_name,
profile_path, profile_path,
profile_arch) profile_arch))
setValue = Variable.setValue setValue = Variable.setValue
@ -1262,12 +1262,12 @@ class VariableClUpdateProfileSystem(Variable):
if not url: if not url:
return [] return []
arch = self.Get(self.gentoo_arch) arch = self.Get(self.gentoo_arch)
profiles = zip(*self.Select([self.profiles_shortname, profiles = list(zip(*self.Select([self.profiles_shortname,
self.profiles_fullname], self.profiles_fullname],
where=self.profiles_arch, eq=arch)) where=self.profiles_arch, eq=arch)))
if profiles: if profiles:
short_name, full_name = profiles short_name, full_name = profiles
return zip(short_name, full_name) return list(zip(short_name, full_name))
return [] return []

@ -22,15 +22,16 @@ from calculate.core.server.func import WsdlBase
from calculate.install.install import InstallError from calculate.install.install import InstallError
from .update import Update, UpdateError from .update import Update, UpdateError
from calculate.lib.utils.git import GitError from calculate.lib.utils.git import GitError
from utils.cl_update import ClUpdateAction from .utils.cl_update import ClUpdateAction
from utils.cl_update_profile import ClUpdateProfileAction from .utils.cl_update_profile import ClUpdateProfileAction
from utils.cl_setup_update import ClSetupUpdateAction from .utils.cl_setup_update import ClSetupUpdateAction
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate, _ from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate, _
setLocalTranslate('cl_update3', sys.modules[__name__]) setLocalTranslate('cl_update3', sys.modules[__name__])
__ = getLazyLocalTranslate(_) __ = getLazyLocalTranslate(_)
class Wsdl(WsdlBase): class Wsdl(WsdlBase):
methods = [ methods = [
# #

Loading…
Cancel
Save