瀏覽代碼

wxGUI: list PG databases, try `db.databases` first

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53601 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 12 年之前
父節點
當前提交
9019a9f4be
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      gui/wxpython/gui_core/gselect.py

+ 6 - 1
gui/wxpython/gui_core/gselect.py

@@ -1763,7 +1763,12 @@ class GdalSelect(wx.Panel):
             if format == 'SQLite' or format == 'Rasterlite':
             if format == 'SQLite' or format == 'Rasterlite':
                 win = self.input['db-win']['file']
                 win = self.input['db-win']['file']
             elif format == 'PostgreSQL' or format == 'PostGIS WKT Raster driver':
             elif format == 'PostgreSQL' or format == 'PostGIS WKT Raster driver':
-                if grass.find_program('psql', ['--help']):
+                # try to get list of PG databases
+                db = RunCommand('db.databases', quiet = True, read = True,
+                                driver = 'pg').splitlines()
+                if db is not None:
+                    win.SetItems(sorted(db))
+                elif grass.find_program('psql', ['--help']):
                     win = self.input['db-win']['choice']
                     win = self.input['db-win']['choice']
                     if not win.GetItems():
                     if not win.GetItems():
                         p = grass.Popen(['psql', '-ltA'], stdout = grass.PIPE)
                         p = grass.Popen(['psql', '-ltA'], stdout = grass.PIPE)