public inbox for [email protected]  
help / color / mirror / Atom feed
From: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch]: Error while expanding server group node.
Date: Mon, 26 Sep 2016 18:54:16 +0530
Message-ID: <CAM5-9D-Z=hDruYVzrikUBfgp9HXxUxK5=uCvmdkRe-=jROVYbw@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi

*Issue:*
Getting following error while expanding server group node.
File
"/Users/surinder/Documents/Projects/pgadmin4/web/pgadmin/browser/server_groups/servers/__init__.py",
line 86, in get_nodes
    in_recovery = result['rows'][0]['inrecovery'];
TypeError: string indices must be integers

Not a proper scenario to reproduce it.

*Solution:*
Add proper check to fix it.


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] server_expand_issue.patch (1.3K, 3-server_expand_issue.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index 35494a2..a6fe620 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -71,6 +71,8 @@ class ServerModule(sg.ServerGroupPluginModule):
             manager = driver.connection_manager(server.id)
             conn = manager.connection()
             connected = conn.connected()
+            in_recovery = None
+            wal_paused = None
             if connected:
                 status, result = conn.execute_dict("""
                     SELECT CASE WHEN usesuper
@@ -83,11 +85,9 @@ class ServerModule(sg.ServerGroupPluginModule):
                            END as isreplaypaused
                     FROM pg_user WHERE usename=current_user""")
 
-                in_recovery = result['rows'][0]['inrecovery'];
-                wal_paused = result['rows'][0]['isreplaypaused']
-            else:
-                in_recovery = None
-                wal_paused = None
+                if len(result['rows']):
+                    in_recovery = result['rows'][0]['inrecovery']
+                    wal_paused = result['rows'][0]['isreplaypaused']
 
             yield self.generate_browser_node(
                 "%d" % (server.id),


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]: Error while expanding server group node.
  In-Reply-To: <CAM5-9D-Z=hDruYVzrikUBfgp9HXxUxK5=uCvmdkRe-=jROVYbw@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