Detect if pgAdmin is running in Flatpak.

This commit is contained in:
Kolja 2024-06-18 14:52:13 +02:00 committed by GitHub
parent 0452828cc7
commit d4b72e2d89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -26,6 +26,10 @@ const createDir = (dirName) => {
} }
}; };
const insideFlatpak = () => {
return platform() === 'linux' && fs.existsSync('/.flatpak-info');
}
// This function is used to get the python executable path // This function is used to get the python executable path
// based on the platform. Use this for deployment. // based on the platform. Use this for deployment.
const getPythonPath = () => { const getPythonPath = () => {
@ -37,8 +41,11 @@ const getPythonPath = () => {
case 'darwin': case 'darwin':
pythonPath = '../../Frameworks/Python.framework/Versions/Current/bin/python3'; pythonPath = '../../Frameworks/Python.framework/Versions/Current/bin/python3';
break; break;
case 'linux': case 'linux':
pythonPath = '../venv/bin/python3'; pythonPath = '../venv/bin/python3';
if (insideFlatpak()) {
pythonPath = '/usr/bin/python';
}
break; break;
default: default:
if (platform().startsWith('win')) { if (platform().startsWith('win')) {
@ -451,4 +458,5 @@ module.exports = {
setZoomLevelForAllWindows: setZoomLevelForAllWindows, setZoomLevelForAllWindows: setZoomLevelForAllWindows,
ConfigureStore: ConfigureStore, ConfigureStore: ConfigureStore,
parseConsoleArgs: parseConsoleArgs, parseConsoleArgs: parseConsoleArgs,
insideFlatpak: insideFlatpak,
}; };

View File

@ -29,6 +29,10 @@ let pythonPath = misc.getPythonPath();
let pgadminFile = '../web/pgAdmin4.py'; let pgadminFile = '../web/pgAdmin4.py';
let configFile = '../web/config.py'; let configFile = '../web/config.py';
if (misc.insideFlatpak()) {
pgadminFile = '/app/pgAdmin4/web/pgAdmin4.py';
}
// Override the paths above, if a developer needs to // Override the paths above, if a developer needs to
if (fs.existsSync('dev_config.json')) { if (fs.existsSync('dev_config.json')) {
try { try {