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

pull/3/head
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.
#
# A default location can be specified for each database driver ID, in
# a dictionary. A relative (to the working directory for the package)
# location may be specified, or absolute.
# a dictionary. Either an absolute or relative path can be specified.
# 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 = {
"pg": "",

View File

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