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

Function set_binary_path

web/pgadmin/utils/__init__.py:403–440  ·  view source on GitHub ↗

This function is used to iterate through the utilities and set the default binary path.

(binary_path, bin_paths, server_type,
                    version_number=None, set_as_default=False,
                    is_fixed_path=False)

Source from the content-addressed store, hash-verified

401
402
403def set_binary_path(binary_path, bin_paths, server_type,
404 version_number=None, set_as_default=False,
405 is_fixed_path=False):
406 """
407 This function is used to iterate through the utilities and set the
408 default binary path.
409 """
410 path_with_dir = binary_path if "$DIR" in binary_path else None
411 binary_versions = get_binary_path_versions(binary_path)
412
413 for utility, version in binary_versions.items():
414 version_number = version if version_number is None else version_number
415 # version will be None if binary not present
416 version_number = version_number or ''
417 if version_number.find('.'):
418 version_number = version_number.split('.', 1)[0]
419 try:
420 # Get the paths array based on server type
421 if 'pg_bin_paths' in bin_paths or 'as_bin_paths' in bin_paths:
422 paths_array = bin_paths['pg_bin_paths']
423 if server_type == 'ppas':
424 paths_array = bin_paths['as_bin_paths']
425 else:
426 paths_array = bin_paths
427
428 for path in paths_array:
429 if path['version'].find(version_number) == 0 and \
430 path['binaryPath'] is None:
431 path['binaryPath'] = path_with_dir \
432 if path_with_dir is not None else binary_path
433 if set_as_default:
434 path['isDefault'] = True
435 # Whether the fixed path in the config file exists or not
436 path['isFixed'] = is_fixed_path
437 break
438 break
439 except Exception:
440 continue
441
442
443def replace_binary_path(binary_path):

Callers 3

path_converterMethod · 0.90
configure_preferencesFunction · 0.90

Calls 2

get_binary_path_versionsFunction · 0.85
findMethod · 0.80

Tested by 1

configure_preferencesFunction · 0.72