View | Details | Raw Unified | Return to bug 44532 | Differences between
and this patch

Collapse All | Expand All

(-)base/univention-updater/python/univention-upgrade (-9 / +28 lines)
 Lines 33-38    Link Here 
33
# <http://www.gnu.org/licenses/>.
33
# <http://www.gnu.org/licenses/>.
34
34
35
import os
35
import os
36
import re
36
import sys
37
import sys
37
import time
38
import time
38
from optparse import OptionParser, OptionGroup
39
from optparse import OptionParser, OptionGroup
 Lines 39-44    Link Here 
39
import subprocess
40
import subprocess
40
import traceback
41
import traceback
41
import logging
42
import logging
43
import operator
42
44
43
import univention.config_registry
45
import univention.config_registry
44
46
 Lines 125-136    Link Here 
125
            return False
127
            return False
126
128
127
129
128
def _package_list(new_packages):
130
def _package_list(new_packages, terminal_width):
129
    """Return comma separated list of packages."""
131
    """
130
    l = []
132
    Return new line separated list of packages.
131
    for p in new_packages:
133
    Lines will be truncated at terminal_width.
132
        l.append(p[0])
134
    """
133
    return ','.join(l)
135
    if not new_packages:
136
        return ''
137
    if len(new_packages[0]) == 2:
138
        # install
139
        return '\n'.join(sorted(
140
            ['{}  ({})'.format(*p)[:terminal_width] for p in new_packages],
141
            key=operator.itemgetter(0)))
142
    if len(new_packages[0]) == 3:
143
        # upgrade
144
        return '\n'.join(sorted(
145
            ['{0}  ({2} old: {1})'.format(*p)[:terminal_width] for p in new_packages],
146
            key=operator.itemgetter(0)))
147
    return '\n'.join(sorted(p[0] for p in new_packages))
134
148
135
149
136
def performUpdate(options, checkForUpdates=False, silent=False):
150
def performUpdate(options, checkForUpdates=False, silent=False):
 Lines 203-214    Link Here 
203
        return True
217
        return True
204
218
205
    dprint(silent, 'found\n')
219
    dprint(silent, 'found\n')
220
    try:
221
        _length, _width = subprocess.check_output(['stty', 'size']).decode().split()
222
        terminal_width = int(_width)
223
    except (OSError, ValueError, subprocess.CalledProcessError):
224
        terminal_width = 80
206
    if len(removed_packages) > 0:
225
    if len(removed_packages) > 0:
207
        dprint(silent, 'The following packages will be REMOVED:\n %s' % _package_list(removed_packages))
226
        dprint(silent, 'The following packages will be REMOVED:\n%s' % _package_list(removed_packages, terminal_width))
208
    if len(new_packages) > 0:
227
    if len(new_packages) > 0:
209
        dprint(silent, 'The following packages will be installed:\n %s' % _package_list(new_packages))
228
        dprint(silent, 'The following packages will be installed:\n%s' % _package_list(new_packages, terminal_width))
210
    if len(upgraded_packages) > 0:
229
    if len(upgraded_packages) > 0:
211
        dprint(silent, 'The following packages will be upgraded:\n %s' % _package_list(upgraded_packages))
230
        dprint(silent, 'The following packages will be upgraded:\n%s' % _package_list(upgraded_packages, terminal_width))
212
    if interactive and not readcontinue('\nDo you want to continue [Y|n]?'):
231
    if interactive and not readcontinue('\nDo you want to continue [Y|n]?'):
213
        return False
232
        return False
214
233

Return to bug 44532