Browse Source

Добавлена обработка revdep-rebuild

tags/3.2.0_alpha5
Mike khiretskiy 7 years ago
parent
commit
0693200b8f
3 changed files with 56 additions and 7 deletions
  1. +25
    -2
      update/emerge_parser.py
  2. +26
    -0
      update/update.py
  3. +5
    -5
      update/utils/cl_update.py

+ 25
- 2
update/emerge_parser.py View File

@@ -160,9 +160,9 @@ class EmergeInformationBlock(object):

def __contains__(self, item):
if self.result is None:
return 0
return False
else:
return item in self.result
return item in str(self)

def _get_text(self, result):
"""
@@ -449,6 +449,29 @@ class EmergeingErrorBlock(EmergeInformationBlock):
raise EmergeError(_("Emerge %s is failed") % self.package)


class RevdepPercentBlock(NotifierInformationBlock):
"""
Блок определния статуса revdep-rebuild
"""
token = "Collecting system binaries"
end_token = [re.compile("Assigning files to packages|"
"All prepared. Starting rebuild"), pexpect.EOF]
re_block = re.compile("\[\s(\d+)%\s\]")

def notify(self, observer, groups):
percent = int(groups[0])
observer(percent)

def get_block(self, child):
while True:
index = child.expect([self.re_block]+self.end_token)
if index == 0:
for observer in self.observers:
self.notify(observer, child.match.groups())
else:
self.result = child.match
break

class EmergeParser(object):
"""
Парсер вывода emerge


+ 26
- 0
update/update.py View File

@@ -20,6 +20,7 @@ from os import path
from calculate.lib.utils.tools import AddonError
from calculate.lib.utils.colortext.palette import TextState
from calculate.lib.utils.colortext import get_color_print
from calculate.update.emerge_parser import RevdepPercentBlock
import pexpect

from package_tools import Git, Layman,\
@@ -298,6 +299,31 @@ class Update:
raise
return True

def revdep_rebuild(self, cmd, *params):
cmd_path = getProgPath(cmd)
if not cmd_path:
raise UpdateError(_("Failed to find %s command") % cmd)
with EmergeParser(
emerge_parser.CommandExecutor(cmd_path, params)) as emerge:
revdep = RevdepPercentBlock(emerge)
self.addProgress()
revdep.add_observer(self.setProgress)
revdep.action = lambda x: (self.endTask(), self.startTask(
_("Calculating dependencies")) if "Assign" in revdep else None)
emerge.emerging.add_observer(self._printEmergePackage)
emerge.installing.add_observer(self._printInstallPackage)
emerge.uninstalling.add_observer(self._printUninstallPackage)
try:
emerge.run()
except EmergeError:
if emerge.emerging_error:
self.printPre(
self._emerge_translate(emerge.emerging_error.log))
else:
self.printPre(self._emerge_translate(emerge.prepare_error))
raise
return True

def _display_pretty_package_list(self, pkglist, remove_list=False):
"""
Отобразить список пакетов в "удобночитаемом" виде


+ 5
- 5
update/utils/cl_update.py View File

@@ -180,16 +180,16 @@ class ClUpdateAction(Action):
'preserved_libs']
},
{'name': 'update:revdev_rebuild',
'message': __('Executing {0}').format("revdep-rebuild"),
'method': 'Update.emergelike("revdep-rebuild")',
'message': __('Checking reverse dependencies'),
'method': 'Update.revdep_rebuild("revdep-rebuild")',
'condition': was_installed('.*', log_names['revdep']),
'decoration': 'Update.update_task("%s")' % log_names['revdep']
},
{'name': 'update:set_upto_date_cache',
'method': 'Update.setUpToDateCache()'
}
]
},
{'name': 'update:set_upto_date_cache',
'method': 'Update.setUpToDateCache()'
}
]

# список задач для дейсвия


Loading…
Cancel
Save