public inbox for [email protected]  
help / color / mirror / Atom feed
From: Akshay Joshi <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgadmin4][Patch]: Fixed minor issue in auto discover server when entry is blank in the config file
Date: Thu, 21 Jun 2018 13:02:58 +0530
Message-ID: <CANxoLDcyq+oLtrU_yoFjHrtsU0YQBqDZ5fB0bO7V8FCrCrKO9w@mail.gmail.com> (raw)

Hi Hackers,

I have found one minor issue in auto discovery logic. *getint* function of
ConfigParser throws exception if the value of the parameter is blank in the
config file. Example: *Port=*

Because of that exception pgAdmin4 unable to discover all the valid
servers. Attached is the patch to fix that. Please review it.

-- 
*Akshay Joshi*

*Sr. Software Architect *



*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*


Attachments:

  [application/octet-stream] Auto_discover_exception.patch (1.0K, 3-Auto_discover_exception.patch)
  download | inline diff:
diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py
index 5caf604..e4c9c48 100644
--- a/web/pgadmin/__init__.py
+++ b/web/pgadmin/__init__.py
@@ -509,7 +509,16 @@ def create_app(app_name=None):
                 ):
                     svr_name = registry.get(section, 'Description')
                     svr_superuser = registry.get(section, 'Superuser')
-                    svr_port = registry.getint(section, 'Port')
+
+                    # getint function throws exception if value is blank.
+                    # Ex: Port=
+                    # In such case we should handle the exception and continue
+                    # to read the next section of the config file.
+                    try:
+                        svr_port = registry.getint(section, 'Port')
+                    except ValueError:
+                        continue
+
                     svr_discovery_id = section
                     description = registry.get(section, 'Description')
                     data_directory = registry.get(section, 'DataDirectory')


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgadmin4][Patch]: Fixed minor issue in auto discover server when entry is blank in the config file
  In-Reply-To: <CANxoLDcyq+oLtrU_yoFjHrtsU0YQBqDZ5fB0bO7V8FCrCrKO9w@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox