Allow a placeholder ($DIR) to be used in utility paths to make it easier to use relative paths.

This commit is contained in:
Dave Page 2016-11-23 13:35:27 +00:00
parent 08396ce861
commit 1a18e07329
2 changed files with 14 additions and 7 deletions

View File

@ -270,8 +270,13 @@ STORAGE_DIR = os.path.join(
# expected to be overridden by packagers in config_distro.py. # expected to be overridden by packagers in config_distro.py.
# #
# A default location can be specified for each database driver ID, in # A default location can be specified for each database driver ID, in
# a dictionary. A relative (to the working directory for the package) # a dictionary. Either an absolute or relative path can be specified.
# location may be specified, or absolute. # In cases where it may be difficult to know what the working directory
# is, "$DIR" can be specified. This will be replaced with the path to the
# top-level pgAdmin4.py file. For example, on macOS we might use:
#
# $DIR/../../SharedSupport
#
########################################################################## ##########################################################################
DEFAULT_BINARY_PATHS = { DEFAULT_BINARY_PATHS = {
"pg": "", "pg": "",

View File

@ -7,7 +7,7 @@
# #
########################################################################## ##########################################################################
import os import os, sys
from flask import render_template from flask import render_template
from flask_babel import gettext as _ from flask_babel import gettext as _
@ -94,7 +94,7 @@ class ServerType(object):
reverse=True reverse=True
) )
def utility(self, operation, sverion): def utility(self, operation, sversion):
res = None res = None
if operation == 'backup': if operation == 'backup':
@ -112,10 +112,12 @@ class ServerType(object):
)) ))
) )
return os.path.join( bin_path = self.utility_path.get().replace("$DIR", os.path.dirname(sys.modules['__main__'].__file__))
self.utility_path.get(),
return os.path.abspath(os.path.join(
bin_path,
(res if os.name != 'nt' else (res + '.exe')) (res if os.name != 'nt' else (res + '.exe'))
) ))
# Default Server Type # Default Server Type