MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / upgrade_check

Function upgrade_check

web/pgadmin/misc/__init__.py:360–484  ·  view source on GitHub ↗

Check for application updates and return update metadata to the client. - Compares current version with remote version data. - Supports auto-update in desktop mode.

()

Source from the content-addressed store, hash-verified

358 methods=['GET'])
359@pga_login_required
360def upgrade_check():
361 """
362 Check for application updates and return update metadata to the client.
363 - Compares current version with remote version data.
364 - Supports auto-update in desktop mode.
365 """
366 # Determine if this check was manually triggered by the user
367 trigger_update_check = (request.args.get('trigger_update_check', 'false')
368 .lower() == 'true')
369
370 platform = None
371 ret = {"outdated": False}
372
373 if config.UPGRADE_CHECK_ENABLED:
374 last_check = get_setting('LastUpdateCheck', default='0')
375 today = time.strftime('%Y%m%d')
376
377 data = None
378 url = '%s?version=%s' % (
379 config.UPGRADE_CHECK_URL, config.APP_VERSION)
380 current_app.logger.debug('Checking version data at: %s' % url)
381
382 # Attempt to fetch upgrade data from remote URL
383 try:
384 # Do not wait for more than 5 seconds.
385 # It stuck on rendering the browser.html, while working in the
386 # broken network.
387 if sys.version_info >= (
388 3, 13):
389 # Use SSL context for Python 3.13+
390 if os.path.exists(config.CA_FILE):
391 context = ssl.create_default_context(cafile=config.CA_FILE)
392 else:
393 context = ssl.create_default_context(
394 cafile=certifi.where()
395 )
396
397 response = urlopen(url, data=data, timeout=5,
398 context=context)
399 elif os.path.exists(config.CA_FILE):
400 # Use cafile parameter for older versions
401 response = urlopen(url, data=data, timeout=5,
402 cafile=config.CA_FILE)
403 else:
404 response = urlopen(url, data, 5, cafile=certifi.where())
405 current_app.logger.debug(
406 'Version check HTTP response code: %d' % response.getcode()
407 )
408
409 if response.getcode() == 200:
410 data = json.loads(response.read().decode('utf-8'))
411 current_app.logger.debug('Response data: %s' % data)
412 except Exception as e:
413 current_app.logger.exception(e)
414 # Escaping the error message to prevent HTML execution in UI
415 escaped_error = html.escape(str(e))
416 return internal_server_error(errormsg=escaped_error)
417

Callers

nothing calls this directly

Calls 8

get_settingFunction · 0.90
internal_server_errorFunction · 0.90
store_settingFunction · 0.90
make_json_responseFunction · 0.90
decodeMethod · 0.80
escapeMethod · 0.80
getMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected