From d462c833d2f3e664a7480363bae13e33a352cd0c Mon Sep 17 00:00:00 2001 From: Alessandro De Maria Date: Mon, 1 Mar 2021 11:09:39 +0000 Subject: [PATCH 2/2] Address comments on pep8 and documentation --- docs/en_US/import_export_servers.rst | 3 +++ web/setup.py | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/en_US/import_export_servers.rst b/docs/en_US/import_export_servers.rst index 1e05f9617b..175a544cf4 100644 --- a/docs/en_US/import_export_servers.rst +++ b/docs/en_US/import_export_servers.rst @@ -57,6 +57,9 @@ path) of the JSON file containing the server definitions. Servers will be owned by the desktop mode user (pgadmin4@pgadmin.org by default - see the DESKTOP_USER setting in ``config.py``). This can be overridden with the ``--user`` command line option. There can be multiple configuations of pgAdmin on the same system. +The default behaviour is for the imported servers to be added to the existent list, +which might lead to duplicates. This can be overridden with the ``--replace`` command +line option, which will replace the list of servers with the newly imported one. To load the servers into a specific pgAdmin config DB file, ``--sqlite-path`` option can be used. It is also recommended to use this option when running pgAdmin in desktop mode. By default SQLITE_PATH setting in ``config.py`` is taken. For example: diff --git a/web/setup.py b/web/setup.py index 86e61fc77b..37d8345f4f 100644 --- a/web/setup.py +++ b/web/setup.py @@ -10,6 +10,9 @@ """Perform the initial setup of the application, by creating the auth and settings database.""" +from pgadmin.model import db, User, Version, ServerGroup, Server, \ + SCHEMA_VERSION as CURRENT_SCHEMA_VERSION +from pgadmin import create_app import argparse import json import os @@ -28,10 +31,6 @@ root = os.path.dirname(os.path.realpath(__file__)) if sys.path[0] != root: sys.path.insert(0, root) -from pgadmin import create_app -from pgadmin.model import db, User, Version, ServerGroup, Server, \ - SCHEMA_VERSION as CURRENT_SCHEMA_VERSION - def add_value(attr_dict, key, value): """Add a value to the attribute dict if non-empty. @@ -397,6 +396,7 @@ def setup_db(): if os.name != 'nt': os.chmod(config.SQLITE_PATH, 0o600) + def clear_servers(): """Clear groups and servers configurations. @@ -432,7 +432,7 @@ def clear_servers(): for group in groups: db.session.delete(group) servers = Server.query.filter_by(user_id=user_id) - + for server in servers: db.session.delete(server) @@ -442,7 +442,6 @@ def clear_servers(): print("Error clearing server configuration") - if __name__ == '__main__': # Configuration settings import config -- 2.24.3 (Apple Git-128)