Univention Bugzilla – Attachment 8820 Details for
Bug 44532
beautify updater package list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
list packages sorted with new lines and versions
beautify_upgrade_output.patch (text/plain), 2.66 KB, created by
Daniel Tröder
on 2017-05-04 10:52 CEST
(
hide
)
Description:
list packages sorted with new lines and versions
Filename:
MIME Type:
Creator:
Daniel Tröder
Created:
2017-05-04 10:52 CEST
Size:
2.66 KB
patch
obsolete
>Index: base/univention-updater/python/univention-upgrade >=================================================================== >--- base/univention-updater/python/univention-upgrade (Revision 79032) >+++ base/univention-updater/python/univention-upgrade (Arbeitskopie) >@@ -33,6 +33,7 @@ > # <http://www.gnu.org/licenses/>. > > import os >+import re > import sys > import time > from optparse import OptionParser, OptionGroup >@@ -39,6 +40,7 @@ > import subprocess > import traceback > import logging >+import operator > > import univention.config_registry > >@@ -125,12 +127,24 @@ > return False > > >-def _package_list(new_packages): >- """Return comma separated list of packages.""" >- l = [] >- for p in new_packages: >- l.append(p[0]) >- return ','.join(l) >+def _package_list(new_packages, terminal_width): >+ """ >+ Return new line separated list of packages. >+ Lines will be truncated at terminal_width. >+ """ >+ if not new_packages: >+ return '' >+ if len(new_packages[0]) == 2: >+ # install >+ return '\n'.join(sorted( >+ ['{} ({})'.format(*p)[:terminal_width] for p in new_packages], >+ key=operator.itemgetter(0))) >+ if len(new_packages[0]) == 3: >+ # upgrade >+ return '\n'.join(sorted( >+ ['{0} ({2} old: {1})'.format(*p)[:terminal_width] for p in new_packages], >+ key=operator.itemgetter(0))) >+ return '\n'.join(sorted(p[0] for p in new_packages)) > > > def performUpdate(options, checkForUpdates=False, silent=False): >@@ -203,12 +217,17 @@ > return True > > dprint(silent, 'found\n') >+ try: >+ _length, _width = subprocess.check_output(['stty', 'size']).decode().split() >+ terminal_width = int(_width) >+ except (OSError, ValueError, subprocess.CalledProcessError): >+ terminal_width = 80 > if len(removed_packages) > 0: >- dprint(silent, 'The following packages will be REMOVED:\n %s' % _package_list(removed_packages)) >+ dprint(silent, 'The following packages will be REMOVED:\n%s' % _package_list(removed_packages, terminal_width)) > if len(new_packages) > 0: >- dprint(silent, 'The following packages will be installed:\n %s' % _package_list(new_packages)) >+ dprint(silent, 'The following packages will be installed:\n%s' % _package_list(new_packages, terminal_width)) > if len(upgraded_packages) > 0: >- dprint(silent, 'The following packages will be upgraded:\n %s' % _package_list(upgraded_packages)) >+ dprint(silent, 'The following packages will be upgraded:\n%s' % _package_list(upgraded_packages, terminal_width)) > if interactive and not readcontinue('\nDo you want to continue [Y|n]?'): > return False >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 44532
: 8820 |
8821