improved output formatting
This commit is contained in:
parent
5e8c57937f
commit
0caa892f25
@ -112,9 +112,12 @@ class UpdateWindow(Gtk.ApplicationWindow):
|
||||
self.buffer.insert(iter, text + "\n")
|
||||
|
||||
def execute(self, args, ignore_stderr=False, output_msg=None,
|
||||
empty_msg=None, env={}):
|
||||
empty_msg=None, env={}, clear=True):
|
||||
self.lock()
|
||||
self.clear()
|
||||
|
||||
if clear:
|
||||
self.clear()
|
||||
|
||||
self.output_msg = output_msg
|
||||
self.empty_msg = empty_msg
|
||||
self.ignore_stderr = ignore_stderr
|
||||
@ -176,19 +179,20 @@ class UpdateWindow(Gtk.ApplicationWindow):
|
||||
def on_upgrade(self, *args):
|
||||
self.upgrade()
|
||||
|
||||
def update(self):
|
||||
def update(self, clear=True):
|
||||
args = ['/usr/bin/apt-get', '-y', 'update']
|
||||
env = {'DEBIAN_FRONTEND': 'noninteractive'}
|
||||
self.execute(args, env=env)
|
||||
self.execute(args, env=env, clear=clear)
|
||||
|
||||
def on_update(self, *args):
|
||||
self.update()
|
||||
|
||||
def list(self):
|
||||
def list(self, clear=True):
|
||||
args = ['/usr/bin/apt', '-qq', 'list', '--upgradable']
|
||||
self.execute(
|
||||
args,
|
||||
ignore_stderr=True,
|
||||
clear=clear,
|
||||
output_msg="Found the following package upgrades:",
|
||||
empty_msg="Currently there are no available package upgrades.")
|
||||
|
||||
@ -201,13 +205,12 @@ class UpdateWindow(Gtk.ApplicationWindow):
|
||||
def update_buffer(self):
|
||||
try:
|
||||
text = self.stdout_queue.get(block=False)
|
||||
|
||||
self.stdout += text
|
||||
self.append_mesg("STDOUT", text)
|
||||
|
||||
match = re.fullmatch(r'EXIT (\d+)', text)
|
||||
|
||||
if match is not None:
|
||||
if match is None:
|
||||
self.stdout += text
|
||||
self.append_mesg("STDOUT", text)
|
||||
else:
|
||||
exit_code = int(match.group(1))
|
||||
|
||||
if exit_code != 0:
|
||||
@ -337,6 +340,8 @@ class SimpleAptUpdate(Gtk.Application):
|
||||
|
||||
self.window.present()
|
||||
self.window.show_all()
|
||||
self.window.update()
|
||||
self.window.list(clear=False)
|
||||
|
||||
|
||||
##
|
||||
|
Loading…
Reference in New Issue
Block a user