|
Lines 271-276
Link Here
|
| 271 |
else: |
271 |
else: |
| 272 |
dprint(silent, 'none') |
272 |
dprint(silent, 'none') |
| 273 |
|
273 |
|
|
|
274 |
####################################################################### |
| 275 |
# APP UPDATE |
| 276 |
####################################################################### |
| 277 |
try: |
| 278 |
from univention.appcenter.actions import get_action |
| 279 |
import univention.appcenter.log as appcenter_log |
| 280 |
from argparse import Namespace |
| 281 |
app_upgrade = get_action('upgrade') |
| 282 |
if app_upgrade is None: |
| 283 |
raise ImportError() |
| 284 |
except ImportError: |
| 285 |
# the new univention.appcenter package is not installed. nevermind |
| 286 |
# cannot be a dependency as the app center depends on updater... |
| 287 |
pass |
| 288 |
else: |
| 289 |
# check if component updates are available |
| 290 |
dprint(silent, 'Checking for app updates: ', newline=False) |
| 291 |
app_upgrade = app_upgrade() |
| 292 |
app_upgrade._username = None |
| 293 |
appcenter_log.log_to(log_file=LOGFN) |
| 294 |
appcenter_log.log_to(stdout=True, log_format='%(message)s', logger='%s.readme' % app_upgrade.logger.name) |
| 295 |
appcenter_log._reverse_umc_module_logger() |
| 296 |
args = Namespace() |
| 297 |
args.all = True |
| 298 |
new_apps = list(app_upgrade.iter_apps(args)) |
| 299 |
update_available = bool(new_apps) |
| 300 |
|
| 301 |
if update_available: |
| 302 |
run = True |
| 303 |
# updates available ==> stop here in "check-mode" |
| 304 |
if checkForUpdates: |
| 305 |
dprint(silent, 'found') |
| 306 |
return True |
| 307 |
|
| 308 |
dprint(silent, 'found\n') |
| 309 |
dprint(silent, 'The following apps can be updated:\n') |
| 310 |
for app in new_apps: |
| 311 |
dprint(silent, '%(name)s: Version %(old)s can be updated to %(new)s' % {'name': app.name, 'old': app.version, 'new': app.candidate.version}) |
| 312 |
dprint(silent, 'Starting univention-app update at %s...' % (time.ctime()), debug=True) |
| 313 |
dprint(silent, '\nStarting app update', newline=False) |
| 314 |
success = True |
| 315 |
for app in new_apps: |
| 316 |
if interactive: |
| 317 |
run = readcontinue('\nDo you want to update %s [Y|n]?' % app.name) |
| 318 |
if run: |
| 319 |
time.sleep(1) |
| 320 |
|
| 321 |
success = app_upgrade.call(app=[app], noninteractive=not interactive) and success |
| 322 |
|
| 323 |
if not success: |
| 324 |
dprint(silent, 'ERROR: app upgrade failed. Please check /var/log/univention/updater.log\n') |
| 325 |
sys.exit(1) |
| 326 |
dprint(silent, 'univention-app upgrade finished at %s...' % (time.ctime()), debug=True) |
| 327 |
dprint(silent, 'done') |
| 328 |
time.sleep(1) |
| 329 |
else: |
| 330 |
dprint(silent, 'none') |
| 331 |
|
| 274 |
# updates available ==> stop here in "check-mode" |
332 |
# updates available ==> stop here in "check-mode" |
| 275 |
if checkForUpdates: |
333 |
if checkForUpdates: |
| 276 |
return False |
334 |
return False |