MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / validate_binary_path

Function validate_binary_path

web/pgadmin/misc/__init__.py:326–354  ·  view source on GitHub ↗

This function is used to validate the specified utilities path by running the utilities with their versions.

()

Source from the content-addressed store, hash-verified

324 methods=["POST"])
325@pga_login_required
326def validate_binary_path():
327 """
328 This function is used to validate the specified utilities path by
329 running the utilities with their versions.
330 """
331 data = None
332 if hasattr(request.data, 'decode'):
333 data = request.data.decode('utf-8')
334
335 if data != '':
336 data = json.loads(data)
337
338 version_str = ''
339
340 # Do not allow storage dir as utility path
341 if 'utility_path' in data and data['utility_path'] is not None and \
342 Path(config.STORAGE_DIR) != Path(data['utility_path']) and \
343 Path(config.STORAGE_DIR) not in Path(data['utility_path']).parents:
344 binary_versions = get_binary_path_versions(data['utility_path'])
345 for utility, version in binary_versions.items():
346 if version is None:
347 version_str += "<b>" + utility + ":</b> " + \
348 "not found on the specified binary path.<br/>"
349 else:
350 version_str += "<b>" + utility + ":</b> " + version + "<br/>"
351 else:
352 return precondition_required(gettext('Invalid binary path.'))
353
354 return make_json_response(data=gettext(version_str), status=200)
355
356
357@blueprint.route("/upgrade_check", endpoint="upgrade_check",

Callers

nothing calls this directly

Calls 5

get_binary_path_versionsFunction · 0.90
precondition_requiredFunction · 0.90
make_json_responseFunction · 0.90
gettextFunction · 0.85
decodeMethod · 0.80

Tested by

no test coverage detected