Kaydet (Commit) 5f59738f authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

ctx.ui.notify fonksiyonuna eklemeler ve düzenlemeler ve yeni renkler

* ui içerisindeki her bir işlem adımı için ekleme yapıldı. İnstalling removing gibi adımları hem ekrana hem log dosyasında hem ekrana hem de log dökümüne yazdırmak, kurulum sırasını ve bazı önemli şeyleri de sadece log dökümüne yazdırmayı denetlemem lazımdı. Notify kullanacak yerler belirlendi. BUna göre kodlar düzenlendi.
* italic yazı stili ve üzeri çizgili yazı stilleri eklendi.
üst 563a9138
......@@ -14,6 +14,9 @@ INARY 2.0 Yol Haritası ve Yapılacaklar
+ ctx.ui.debug fonksiyonu gerekli olmadıkça kullanılmamalı.
+ ctx.ui.info önemli mesajlar ve detaylar için (verbose parametresi ile kullanılmalı)
- Bilgilendirme için kullanılan mesajlar ayıklanıp logdan ayrılmalı.
/ Fix ctx.ui functions:
/ ctx.ui içindeki fonksiyonlar düzenlenmeli. Bazıları çok canavarca kullanılmış.
+ ctx.ui.notify düzenlemesi
- Paket kurulması öncesi tam bilgilendirme.
- İndirilecek boyutu yazdır.
- Eğer paket kurulacak ise toplam install.tar.xz boyutunu yazdır.
......
......@@ -181,6 +181,7 @@ class Install(AtomicOperation):
else:
event = inary.ui.installed
ctx.ui.notify(event, package=self.pkginfo, files=self.files)
util.xterm_title_reset()
def check_requirements(self):
"""check system requirements"""
......@@ -627,6 +628,7 @@ class Remove(AtomicOperation):
self.remove_inary_files()
ctx.ui.close()
ctx.ui.notify(inary.ui.removed, package=self.package, files=self.files)
util.xterm_title_reset()
def check_dependencies(self):
# FIXME: why is this not implemented? -- exa
......
......@@ -200,20 +200,56 @@ class CLI(inary.ui.UI):
self.output(util.colorize(msg + '\n', 'brightgreen'))
util.xterm_title(msg)
def notify(self, event, **keywords):
def notify(self, event, logging=True, **keywords):
if event == inary.ui.installed:
msg = _('Installed \"{}\"').format(keywords['package'].name)
color = 'brightgreen'
elif event == inary.ui.installing:
msg = _('Installing \"{0.name}\", version {0.version}, release {0.release}').format(keywords['package'])
color = 'brightblue'
elif event == inary.ui.removed:
msg = _('Removed \"{}\"').format(keywords['package'].name)
color = 'brightgreen'
elif event == inary.ui.removing:
msg = _('Removing \"{}\"').format(keywords['package'].name)
color = 'faintpurple'
elif event == inary.ui.upgraded:
msg = _('Upgraded \"{}\"').format(keywords['package'].name)
color = 'brightgreen'
elif event == inary.ui.configured:
msg = _('Configured \"{}\"').format(keywords['package'].name)
color = 'brightgreen'
elif event == inary.ui.configuring:
msg = _('Configuring \"{}\"').format(keywords['package'].name)
color = 'faintyellow'
elif event == inary.ui.extracting:
msg = _('Extracting the files of \"{}\"').format(keywords['package'].name)
color = 'faintgreen'
elif event == inary.ui.updatingrepo:
msg = _('Updating package repository: \"{}\"').format(keywords['name'])
color = 'green'
elif event == inary.ui.cached:
total_size, total_symbol = util.human_readable_size(keywords['total'])
cached_size, cached_symbol = util.human_readable_size(keywords['cached'])
msg = _('Total size of package(s): {:.2f} {} / {:.2f} {}').format(cached_size,
cached_symbol,
total_size,
total_symbol)
color = 'cyan'
elif event == inary.ui.packagestogo:
if ctx.log:
ctx.log.info(_("Following packages ordered for process: {}").format(keywords['order']))
msg = None
elif event == inary.ui.desktopfile:
if ctx.log:
ctx.log.info(_("Extracted desktop file \"{}\"").format(keywords['desktopfile']))
msg = None
else:
msg = None
if msg:
self.output(util.colorize(msg + '\n', 'cyan'))
if ctx.log:
self.output(util.colorize(msg + '\n', color))
if ctx.log and logging:
ctx.log.info(msg)
......@@ -154,7 +154,7 @@ class Constants(metaclass=Singleton):
'brightgreen': "\033[01;32m",
'brightyellow': "\033[01;33m",
'brightblue': "\033[01;34m",
'brightmagenta': "\033[01;35m",
'brightpurple': "\033[01;35m",
'brightcyan': "\033[01;36m",
'brightwhite': "\033[01;37m",
'faintblack': "\033[02;30m",
......@@ -165,6 +165,14 @@ class Constants(metaclass=Singleton):
'faintpurple': "\033[02;35m",
'faintcyan': "\033[02;36m",
'faintwhite': "\033[02;37m",
'italicblack': "\033[03;30m",
'italicred': "\033[03;31m",
'italicgreen': "\033[03;32m",
'italicyellow': "\033[03;33m",
'italicblue': "\033[03;34m",
'italicpurple': "\033[03;35m",
'italiccyan': "\033[03;36m",
'italicwhite': "\033[03;37m",
'underlineblack': "\033[04;30m",
'underlinered': "\033[04;31m",
'underlinegreen': "\033[04;32m",
......@@ -189,6 +197,14 @@ class Constants(metaclass=Singleton):
'backgroundmagenta': "\033[07;35m",
'backgroundcyan': "\033[07;36m",
'backgroundwhite': "\033[07;37m",
'strikethroughblack': "\033[09;30m",
'strikethroughred': "\033[09;31m",
'strikethroughgreen': "\033[09;32m",
'strikethroughyellow': "\033[09;33m",
'strikethroughblue': "\033[09;34m",
'strikethroughmagenta': "\033[09;35m",
'strikethroughcyan': "\033[09;36m",
'strikethroughwhite': "\033[09;37m",
'default': "\033[0m"}
def __getattr__(self, attr):
......
......@@ -119,7 +119,7 @@ def calculate_download_sizes(order):
total_size += pkg_size
ctx.ui.notify(ui.cached, total=total_size, cached=cached_size)
ctx.ui.notify(ui.cached, logging=False, total=total_size, cached=cached_size)
return total_size, cached_size
......
......@@ -97,7 +97,7 @@ def update_repo(repo, force=False):
def __update_repo(repo, force=False):
ctx.ui.action(_('Updating repository: \"{}\"').format(repo))
ctx.ui.status(_('Updating package repository: \"{}\"').format(repo), push_screen=False)
ctx.ui.notify(inary.ui.updatingrepo, name=repo)
repodb = inary.db.repodb.RepoDB()
index = inary.data.index.Index()
......
......@@ -120,7 +120,7 @@ def find_upgrades(packages, replaces):
pkg), True)
if debug and ds:
ctx.ui.status(_('The following packages have different sha1sum:'))
ctx.ui.info(_('The following packages have different sha1sum:'))
ctx.ui.info(util.format_by_columns(sorted(ds)))
return Ap
......@@ -188,7 +188,7 @@ def upgrade(A=None, repo=None):
if componentdb.has_component('system.base'):
order = operations.helper.reorder_base_packages(order)
ctx.ui.status(_('The following packages will be upgraded:'))
ctx.ui.info(_('The following packages will be upgraded:'), color="green")
ctx.ui.info(util.format_by_columns(sorted(order)))
total_size, cached_size = operations.helper.calculate_download_sizes(order)
......
......@@ -232,7 +232,7 @@ class Package:
else:
# Added for package-manager
if tarinfo.name.endswith(".desktop"):
ctx.ui.notify(inary.ui.desktopfile, desktopfile=tarinfo.name)
ctx.ui.notify(inary.ui.desktopfile, logging=False, desktopfile=tarinfo.name)
tar = self.get_install_archive()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment