[QGIS Commit] r11081 - in trunk/qgis/src/plugins/grass: modules-6.4 scripts

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jul 15 06:14:18 EDT 2009


Author: rugginoso
Date: 2009-07-15 06:14:17 -0400 (Wed, 15 Jul 2009)
New Revision: 11081

Added:
   trunk/qgis/src/plugins/grass/modules-6.4/db.connect-login.pg.1.png
   trunk/qgis/src/plugins/grass/modules-6.4/db.connect-login.pg.qgm
   trunk/qgis/src/plugins/grass/modules-6.4/r.external.all.1.png
   trunk/qgis/src/plugins/grass/modules-6.4/r.external.all.qgm
   trunk/qgis/src/plugins/grass/modules-6.4/v.out.ogr.pg.1.png
   trunk/qgis/src/plugins/grass/modules-6.4/v.out.ogr.pg.2.png
   trunk/qgis/src/plugins/grass/modules-6.4/v.out.ogr.pg.qgm
   trunk/qgis/src/plugins/grass/scripts/db.connect-login.pg.py
   trunk/qgis/src/plugins/grass/scripts/r.external.all.py
   trunk/qgis/src/plugins/grass/scripts/v.out.ogr.pg.py
Removed:
   trunk/qgis/src/plugins/grass/modules-6.4/qgis.db.connect-login.pg.1.png
   trunk/qgis/src/plugins/grass/modules-6.4/qgis.db.connect-login.pg.qgm
   trunk/qgis/src/plugins/grass/modules-6.4/qgis.r.external.all.1.png
   trunk/qgis/src/plugins/grass/modules-6.4/qgis.r.external.all.qgm
   trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.1.png
   trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.2.png
   trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.qgm
   trunk/qgis/src/plugins/grass/scripts/qgis.db.connect-login.pg.py
   trunk/qgis/src/plugins/grass/scripts/qgis.r.external.all.py
   trunk/qgis/src/plugins/grass/scripts/qgis.v.out.ogr.pg.py
Modified:
   trunk/qgis/src/plugins/grass/modules-6.4/default.qgc
Log:
Renamed some modules.


Copied: trunk/qgis/src/plugins/grass/modules-6.4/db.connect-login.pg.1.png (from rev 11077, trunk/qgis/src/plugins/grass/modules-6.4/qgis.db.connect-login.pg.1.png)
===================================================================
(Binary files differ)

Copied: trunk/qgis/src/plugins/grass/modules-6.4/db.connect-login.pg.qgm (from rev 11078, trunk/qgis/src/plugins/grass/modules-6.4/qgis.db.connect-login.pg.qgm)
===================================================================
--- trunk/qgis/src/plugins/grass/modules-6.4/db.connect-login.pg.qgm	                        (rev 0)
+++ trunk/qgis/src/plugins/grass/modules-6.4/db.connect-login.pg.qgm	2009-07-15 10:14:17 UTC (rev 11081)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">
+
+<qgisgrassmodule label="Set PostgreSQL DB connection" module="db.connect-login.pg.py" manual="db.connect">
+	<option key="database" />
+	<option key="schema" />
+	<option key="host" />
+	<option key="port" answer="5432"/>
+	<option key="user"/>
+	<option key="password"/>
+</qgisgrassmodule>

Modified: trunk/qgis/src/plugins/grass/modules-6.4/default.qgc
===================================================================
--- trunk/qgis/src/plugins/grass/modules-6.4/default.qgc	2009-07-15 09:50:25 UTC (rev 11080)
+++ trunk/qgis/src/plugins/grass/modules-6.4/default.qgc	2009-07-15 10:14:17 UTC (rev 11081)
@@ -25,7 +25,7 @@
 				<grass name="r.in.wms"/>
 				<grass name="r.external"/>
 				<grass name="r.external.qgis"/>
-				<grass name="r.external.qgis.all"/>
+				<grass name="r.external.all"/>
 				<grass name="r.in.wms"/>
 			</section>
 			<section label="Import vector">
@@ -66,7 +66,7 @@
 			</section>
 			<section label="Export vector">
 				<grass name="v.out.ogr"/>
-				<grass name="qgis.v.out.ogr.pg"/>
+				<grass name="v.out.ogr.pg"/>
 				<grass name="v.out.ogr.gml"/>
 				<grass name="v.out.ogr.mapinfo"/>
 				<grass name="v.out.ogr.postgis"/>
@@ -439,7 +439,7 @@
 		<section label="Database management">
 			<grass name="db.connect"/>
 			<grass name="db.connect.schema"/>
-			<grass name="qgis.db.connect-login.pg"/>
+			<grass name="db.connect-login.pg"/>
 			<grass name="v.db.reconnect.all"/>
 			<grass name="db.login"/>
 			<grass name="db.in.ogr"/>

Deleted: trunk/qgis/src/plugins/grass/modules-6.4/qgis.db.connect-login.pg.1.png
===================================================================
(Binary files differ)

Deleted: trunk/qgis/src/plugins/grass/modules-6.4/qgis.db.connect-login.pg.qgm
===================================================================
--- trunk/qgis/src/plugins/grass/modules-6.4/qgis.db.connect-login.pg.qgm	2009-07-15 09:50:25 UTC (rev 11080)
+++ trunk/qgis/src/plugins/grass/modules-6.4/qgis.db.connect-login.pg.qgm	2009-07-15 10:14:17 UTC (rev 11081)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">
-
-<qgisgrassmodule label="Set PostgreSQL DB connection" module="qgis.db.connect-login.pg.py" manual="db.connect">
-	<option key="database" />
-	<option key="schema" />
-	<option key="host" />
-	<option key="port" answer="5432"/>
-	<option key="user"/>
-	<option key="password"/>
-</qgisgrassmodule>

Deleted: trunk/qgis/src/plugins/grass/modules-6.4/qgis.r.external.all.1.png
===================================================================
(Binary files differ)

Deleted: trunk/qgis/src/plugins/grass/modules-6.4/qgis.r.external.all.qgm
===================================================================
--- trunk/qgis/src/plugins/grass/modules-6.4/qgis.r.external.all.qgm	2009-07-15 09:50:25 UTC (rev 11080)
+++ trunk/qgis/src/plugins/grass/modules-6.4/qgis.r.external.all.qgm	2009-07-15 10:14:17 UTC (rev 11081)
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassdatamodule.dtd">
-<qgisgrassmodule label="Link all GDAL supported raster files into a directory to binary raster map layers." module="qgis.r.external.all.py" manual="r.external">
-	<flag key="o"/>
-	<flag key="e"/>
-	<flag key="r"/>
-	<file key="input" type="directory" />
-	<option key="band"/>
-</qgisgrassmodule>

Deleted: trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.1.png
===================================================================
(Binary files differ)

Deleted: trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.2.png
===================================================================
(Binary files differ)

Deleted: trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.qgm
===================================================================
--- trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.qgm	2009-07-15 09:50:25 UTC (rev 11080)
+++ trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.qgm	2009-07-15 10:14:17 UTC (rev 11081)
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">
-
-<qgisgrassmodule label="Export vector to PostGIS (PostgreSQL) database table." module="qgis.v.out.ogr.pg.py" manual="v.out.ogr">
-	<option key="input" layeroption="layer" typeoption="type" />
-	<option key="olayer" />
-	<option key="database" />
-	<!--option key="schema" /-->
-	<option key="host" />
-	<option key="port" answer="5432"/>
-	<option key="user"/>
-	<option key="password"/>
-</qgisgrassmodule>

Copied: trunk/qgis/src/plugins/grass/modules-6.4/r.external.all.1.png (from rev 11077, trunk/qgis/src/plugins/grass/modules-6.4/qgis.r.external.all.1.png)
===================================================================
(Binary files differ)

Copied: trunk/qgis/src/plugins/grass/modules-6.4/r.external.all.qgm (from rev 11078, trunk/qgis/src/plugins/grass/modules-6.4/qgis.r.external.all.qgm)
===================================================================
--- trunk/qgis/src/plugins/grass/modules-6.4/r.external.all.qgm	                        (rev 0)
+++ trunk/qgis/src/plugins/grass/modules-6.4/r.external.all.qgm	2009-07-15 10:14:17 UTC (rev 11081)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassdatamodule.dtd">
+<qgisgrassmodule label="Link all GDAL supported raster files into a directory to binary raster map layers." module="r.external.all.py" manual="r.external">
+	<flag key="o"/>
+	<flag key="e"/>
+	<flag key="r"/>
+	<file key="input" type="directory" />
+	<option key="band"/>
+</qgisgrassmodule>

Copied: trunk/qgis/src/plugins/grass/modules-6.4/v.out.ogr.pg.1.png (from rev 11077, trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.1.png)
===================================================================
(Binary files differ)

Copied: trunk/qgis/src/plugins/grass/modules-6.4/v.out.ogr.pg.2.png (from rev 11077, trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.2.png)
===================================================================
(Binary files differ)

Copied: trunk/qgis/src/plugins/grass/modules-6.4/v.out.ogr.pg.qgm (from rev 11078, trunk/qgis/src/plugins/grass/modules-6.4/qgis.v.out.ogr.pg.qgm)
===================================================================
--- trunk/qgis/src/plugins/grass/modules-6.4/v.out.ogr.pg.qgm	                        (rev 0)
+++ trunk/qgis/src/plugins/grass/modules-6.4/v.out.ogr.pg.qgm	2009-07-15 10:14:17 UTC (rev 11081)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">
+
+<qgisgrassmodule label="Export vector to PostGIS (PostgreSQL) database table." module="v.out.ogr.pg.py" manual="v.out.ogr">
+	<option key="input" layeroption="layer" typeoption="type" />
+	<option key="olayer" />
+	<option key="database" />
+	<!--option key="schema" /-->
+	<option key="host" />
+	<option key="port" answer="5432"/>
+	<option key="user"/>
+	<option key="password"/>
+</qgisgrassmodule>

Copied: trunk/qgis/src/plugins/grass/scripts/db.connect-login.pg.py (from rev 11077, trunk/qgis/src/plugins/grass/scripts/qgis.db.connect-login.pg.py)
===================================================================
--- trunk/qgis/src/plugins/grass/scripts/db.connect-login.pg.py	                        (rev 0)
+++ trunk/qgis/src/plugins/grass/scripts/db.connect-login.pg.py	2009-07-15 10:14:17 UTC (rev 11081)
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+
+############################################################################
+#
+# MODULE:       qgis.db.connect-login.py
+# AUTHOR(S):    Radim Blazek
+#
+# PURPOSE:      Connect to Postgresql
+# COPYRIGHT:    (C) 2009 by Radim Blazek
+#
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
+#############################################################################
+
+#%Module
+#% description: Make connection to PostgreSQL database and login.
+#% keywords: database
+#%End
+
+#%option
+#% key: host
+#% type: string
+#% label: Host
+#% description: Host name of the machine on which the server is running. 
+#% required : no
+#%end
+
+#%option
+#% key: port
+#% type: integer
+#% label: Port
+#% description: TCP port on which the server is listening, usually 5432.
+#% required : no
+#%end
+
+#%option
+#% key: database
+#% type: string
+#% key_desc : name
+#% gisprompt: old_dbname,dbname,dbname
+#% label: Database
+#% description: Database name
+#% required : yes
+#%end
+
+#%option
+#% key: schema
+#% type: string
+#% label: Schema
+#% description: Database schema.
+#% required : no
+#%end
+
+#%option
+#% key: user
+#% type: string
+#% label: User
+#% description: Connect to the database as the user username instead of the  default. 
+#% required : no
+#%end
+
+#%option
+#% key: password
+#% type: string
+#% label: Password
+#% description: Password will be stored in file!
+#% required : no
+#%end
+
+import sys
+import os
+import string
+try:
+    from grass.script import core as grass
+except ImportError:
+    import grass
+except:
+    raise Exception ("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4" )
+
+def main():
+    host = options['host']
+    port = options['port']
+    database = options['database']
+    schema = options['schema']
+    user = options['user']
+    password = options['password']
+
+    # Test connection
+    conn = "dbname=" + database
+    if host: conn += ",host=" + host
+    if port: conn += ",port=" + port
+
+    # Unfortunately we cannot test untill user/password is set 
+    if user or password:
+        print "Setting login (db.login) ... "
+        sys.stdout.flush()
+        if grass.run_command('db.login', driver = "pg", database = conn, user = user, password = password) != 0:
+	    grass.fatal("Cannot login")
+
+    # Try to connect
+    print "Testing connection ..."
+    sys.stdout.flush()
+    if grass.run_command('db.select', quiet = True, flags='c', driver= "pg", database=conn, sql="select version()" ) != 0:
+	if user or password:
+	    print "Deleting login (db.login) ..."
+	    sys.stdout.flush()
+	    if grass.run_command('db.login', quiet = True, driver = "pg", database = conn, user = "", password = "") != 0:
+		print "Cannot delete login."
+		sys.stdout.flush()
+        grass.fatal("Cannot connect to database.")
+  
+    if grass.run_command('db.connect', driver = "pg", database = conn, schema = schema) != 0:
+        grass.fatal("Cannot connect to database.")
+	
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()

Deleted: trunk/qgis/src/plugins/grass/scripts/qgis.db.connect-login.pg.py
===================================================================
--- trunk/qgis/src/plugins/grass/scripts/qgis.db.connect-login.pg.py	2009-07-15 09:50:25 UTC (rev 11080)
+++ trunk/qgis/src/plugins/grass/scripts/qgis.db.connect-login.pg.py	2009-07-15 10:14:17 UTC (rev 11081)
@@ -1,119 +0,0 @@
-#!/usr/bin/env python
-
-############################################################################
-#
-# MODULE:       qgis.db.connect-login.py
-# AUTHOR(S):    Radim Blazek
-#
-# PURPOSE:      Connect to Postgresql
-# COPYRIGHT:    (C) 2009 by Radim Blazek
-#
-#               This program is free software under the GNU General Public
-#               License (>=v2). Read the file COPYING that comes with GRASS
-#               for details.
-#
-#############################################################################
-
-#%Module
-#% description: Make connection to PostgreSQL database and login.
-#% keywords: database
-#%End
-
-#%option
-#% key: host
-#% type: string
-#% label: Host
-#% description: Host name of the machine on which the server is running. 
-#% required : no
-#%end
-
-#%option
-#% key: port
-#% type: integer
-#% label: Port
-#% description: TCP port on which the server is listening, usually 5432.
-#% required : no
-#%end
-
-#%option
-#% key: database
-#% type: string
-#% key_desc : name
-#% gisprompt: old_dbname,dbname,dbname
-#% label: Database
-#% description: Database name
-#% required : yes
-#%end
-
-#%option
-#% key: schema
-#% type: string
-#% label: Schema
-#% description: Database schema.
-#% required : no
-#%end
-
-#%option
-#% key: user
-#% type: string
-#% label: User
-#% description: Connect to the database as the user username instead of the  default. 
-#% required : no
-#%end
-
-#%option
-#% key: password
-#% type: string
-#% label: Password
-#% description: Password will be stored in file!
-#% required : no
-#%end
-
-import sys
-import os
-import string
-try:
-    from grass.script import core as grass
-except ImportError:
-    import grass
-except:
-    raise Exception ("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4" )
-
-def main():
-    host = options['host']
-    port = options['port']
-    database = options['database']
-    schema = options['schema']
-    user = options['user']
-    password = options['password']
-
-    # Test connection
-    conn = "dbname=" + database
-    if host: conn += ",host=" + host
-    if port: conn += ",port=" + port
-
-    # Unfortunately we cannot test untill user/password is set 
-    if user or password:
-        print "Setting login (db.login) ... "
-        sys.stdout.flush()
-        if grass.run_command('db.login', driver = "pg", database = conn, user = user, password = password) != 0:
-	    grass.fatal("Cannot login")
-
-    # Try to connect
-    print "Testing connection ..."
-    sys.stdout.flush()
-    if grass.run_command('db.select', quiet = True, flags='c', driver= "pg", database=conn, sql="select version()" ) != 0:
-	if user or password:
-	    print "Deleting login (db.login) ..."
-	    sys.stdout.flush()
-	    if grass.run_command('db.login', quiet = True, driver = "pg", database = conn, user = "", password = "") != 0:
-		print "Cannot delete login."
-		sys.stdout.flush()
-        grass.fatal("Cannot connect to database.")
-  
-    if grass.run_command('db.connect', driver = "pg", database = conn, schema = schema) != 0:
-        grass.fatal("Cannot connect to database.")
-	
-if __name__ == "__main__":
-    options, flags = grass.parser()
-    main()

Deleted: trunk/qgis/src/plugins/grass/scripts/qgis.r.external.all.py
===================================================================
--- trunk/qgis/src/plugins/grass/scripts/qgis.r.external.all.py	2009-07-15 09:50:25 UTC (rev 11080)
+++ trunk/qgis/src/plugins/grass/scripts/qgis.r.external.all.py	2009-07-15 10:14:17 UTC (rev 11081)
@@ -1,84 +0,0 @@
-#!/usr/bin/env python
-
-############################################################################
-#
-# MODULE:       qgis.r.external.all.py
-# AUTHOR(S):    Lorenzo Masini
-#
-# PURPOSE:      Link all GDAL supported raster files into a directory 
-#		to binary raster map layers.
-# COPYRIGHT:    (C) 2009 by Lorenzo Masini
-#
-#               This program is free software under the GNU General Public
-#               License (>=v2). Read the file COPYING that comes with GRASS
-#               for details.
-#
-#############################################################################
-
-#%Module
-#% description: Link all GDAL supported raster files into a directory to binary raster map layers.
-#% keywords: raster, import
-#%End
-
-#%option
-#% key: input
-#% type: string
-#% gisprompt: input
-#% key_desc : name
-#% description: Directory containing raster files
-#% required : yes
-#%end
-
-#%option
-#% key: band
-#% type: integer
-#% description: Band to select
-#% answer: 1
-#% required : no
-#%end
-
-#%flag
-#% key: o
-#% description: Override projection (use location's projection)
-#%end
-
-#%flag
-#% key: e
-#% description: Extend location extents based on new dataset
-#%end
-
-#%flag
-#% key: r
-#% description: Recursively scan subdirectories
-
-import sys
-import os
-try:
-    from grass.script import core as grass
-except ImportError:
-    import grass
-except:
-    raise Exception ("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4" )
-
-
-def import_directory_of_rasters(directory, recursive):
-    for dir, dirnames, filenames in os.walk(directory):
-	for filename in filenames:
-		if grass.run_command('r.external', flags=flags_string, input=os.path.join(dir, filename), band=options['band'], output=filename[:-4], title=filename[:-4]) != 0:
-			grass.warning('Cannot import file' + filename)
-	if not recursive:
-		break
-	for dirname in dirnames:
-		import_directory_of_rasters(dirname, recursive)
-
-def main():
-    input = options['input']
-    recursive = flags['r']
-	
-    import_directory_of_rasters(input, recursive)
-	 	
-if __name__ == "__main__":
-    options, flags = grass.parser()
-    flags_string = "".join([k for k in flags.keys() if flags[k] and k != 'r'])
-    main()
-

Deleted: trunk/qgis/src/plugins/grass/scripts/qgis.v.out.ogr.pg.py
===================================================================
--- trunk/qgis/src/plugins/grass/scripts/qgis.v.out.ogr.pg.py	2009-07-15 09:50:25 UTC (rev 11080)
+++ trunk/qgis/src/plugins/grass/scripts/qgis.v.out.ogr.pg.py	2009-07-15 10:14:17 UTC (rev 11081)
@@ -1,140 +0,0 @@
-#!/usr/bin/env python
-
-############################################################################
-#
-# MODULE:       qgis.v.out.ogr.pg.py
-# AUTHOR(S):    Radim Blazek
-#
-# PURPOSE:      Export a vectore to PostGIS (PostgreSQL) database table
-# COPYRIGHT:    (C) 2009 by Radim Blazek
-#
-#               This program is free software under the GNU General Public
-#               License (>=v2). Read the file COPYING that comes with GRASS
-#               for details.
-#
-#############################################################################
-
-#%Module
-#% description: Export vector to PostGIS (PostgreSQL) database table.
-#% keywords: vector, export, database
-#%End
-
-#%option
-#% key: input
-#% type: string
-#% gisprompt: old,vector,vector
-#% key_desc : name
-#% description: Name of input vector map
-#% required : yes
-#%end
-
-#%option
-#% key: layer
-#% type: integer
-#% description: Number of input layer
-#% answer: 1
-#% required : yes
-#%end
-
-#%option
-#% key: type
-#% type: string
-#% description: Feature type(s)
-#% options: point,kernel,centroid,line,boundary,area,face
-#% multiple: yes
-#% required : yes
-#%end
-
-#%option
-#% key: olayer
-#% type: string
-#% description: Name of output database table
-#% required : yes
-#%end
-
-#%option
-#% key: host
-#% type: string
-#% label: Host
-#% description: Host name of the machine on which the server is running. 
-#% required : no
-#%end
-
-#%option
-#% key: port
-#% type: integer
-#% label: Port
-#% description: TCP port on which the server is listening, usually 5432.
-#% required : no
-#%end
-
-#%option
-#% key: database
-#% type: string
-#% key_desc : name
-#% gisprompt: old_dbname,dbname,dbname
-#% label: Database
-#% description: Database name
-#% required : yes
-#%end
-
-# AFAIK scheme is not supported well by OGR
-##%option
-##% key: schema
-##% type: string
-##% label: Schema
-##% description: Database schema.
-##% required : no
-##%end
-
-#%option
-#% key: user
-#% type: string
-#% label: User
-#% description: Connect to the database as the user username instead of the  default. 
-#% required : no
-#%end
-
-#%option
-#% key: password
-#% type: string
-#% label: Password
-#% description: Password will be stored in file!
-#% required : no
-#%end
-
-import sys
-import os
-import string
-try:
-    from grass.script import core as grass
-except ImportError:
-    import grass
-except:
-    raise Exception ("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4" )
-
-def main():
-    input = options['input']
-    layer = options['layer']
-    type = options['type']
-    olayer = options['olayer']
-    host = options['host']
-    port = options['port']
-    database = options['database']
-    #schema = options['schema']
-    user = options['user']
-    password = options['password']
-
-    # Construct dsn string
-    dsn = "PG:dbname=" + database
-    if host: dsn += " host=" + host
-    if port: dsn += " port=" + port
-    if user: dsn += " user=" + user
-    if password: dsn += " password=" + password
-
-    if grass.run_command('v.out.ogr', input=input, layer=layer, type=type, format="PostgreSQL", dsn=dsn, olayer=olayer ) != 0:
-        grass.fatal("Cannot export vector to database.")
-	
-if __name__ == "__main__":
-    options, flags = grass.parser()
-    main()

Copied: trunk/qgis/src/plugins/grass/scripts/r.external.all.py (from rev 11077, trunk/qgis/src/plugins/grass/scripts/qgis.r.external.all.py)
===================================================================
--- trunk/qgis/src/plugins/grass/scripts/r.external.all.py	                        (rev 0)
+++ trunk/qgis/src/plugins/grass/scripts/r.external.all.py	2009-07-15 10:14:17 UTC (rev 11081)
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+
+############################################################################
+#
+# MODULE:       qgis.r.external.all.py
+# AUTHOR(S):    Lorenzo Masini
+#
+# PURPOSE:      Link all GDAL supported raster files into a directory 
+#		to binary raster map layers.
+# COPYRIGHT:    (C) 2009 by Lorenzo Masini
+#
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
+#############################################################################
+
+#%Module
+#% description: Link all GDAL supported raster files into a directory to binary raster map layers.
+#% keywords: raster, import
+#%End
+
+#%option
+#% key: input
+#% type: string
+#% gisprompt: input
+#% key_desc : name
+#% description: Directory containing raster files
+#% required : yes
+#%end
+
+#%option
+#% key: band
+#% type: integer
+#% description: Band to select
+#% answer: 1
+#% required : no
+#%end
+
+#%flag
+#% key: o
+#% description: Override projection (use location's projection)
+#%end
+
+#%flag
+#% key: e
+#% description: Extend location extents based on new dataset
+#%end
+
+#%flag
+#% key: r
+#% description: Recursively scan subdirectories
+
+import sys
+import os
+try:
+    from grass.script import core as grass
+except ImportError:
+    import grass
+except:
+    raise Exception ("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4" )
+
+
+def import_directory_of_rasters(directory, recursive):
+    for dir, dirnames, filenames in os.walk(directory):
+	for filename in filenames:
+		if grass.run_command('r.external', flags=flags_string, input=os.path.join(dir, filename), band=options['band'], output=filename[:-4], title=filename[:-4]) != 0:
+			grass.warning('Cannot import file' + filename)
+	if not recursive:
+		break
+	for dirname in dirnames:
+		import_directory_of_rasters(dirname, recursive)
+
+def main():
+    input = options['input']
+    recursive = flags['r']
+	
+    import_directory_of_rasters(input, recursive)
+	 	
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    flags_string = "".join([k for k in flags.keys() if flags[k] and k != 'r'])
+    main()
+

Copied: trunk/qgis/src/plugins/grass/scripts/v.out.ogr.pg.py (from rev 11077, trunk/qgis/src/plugins/grass/scripts/qgis.v.out.ogr.pg.py)
===================================================================
--- trunk/qgis/src/plugins/grass/scripts/v.out.ogr.pg.py	                        (rev 0)
+++ trunk/qgis/src/plugins/grass/scripts/v.out.ogr.pg.py	2009-07-15 10:14:17 UTC (rev 11081)
@@ -0,0 +1,140 @@
+#!/usr/bin/env python
+
+############################################################################
+#
+# MODULE:       qgis.v.out.ogr.pg.py
+# AUTHOR(S):    Radim Blazek
+#
+# PURPOSE:      Export a vectore to PostGIS (PostgreSQL) database table
+# COPYRIGHT:    (C) 2009 by Radim Blazek
+#
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
+#############################################################################
+
+#%Module
+#% description: Export vector to PostGIS (PostgreSQL) database table.
+#% keywords: vector, export, database
+#%End
+
+#%option
+#% key: input
+#% type: string
+#% gisprompt: old,vector,vector
+#% key_desc : name
+#% description: Name of input vector map
+#% required : yes
+#%end
+
+#%option
+#% key: layer
+#% type: integer
+#% description: Number of input layer
+#% answer: 1
+#% required : yes
+#%end
+
+#%option
+#% key: type
+#% type: string
+#% description: Feature type(s)
+#% options: point,kernel,centroid,line,boundary,area,face
+#% multiple: yes
+#% required : yes
+#%end
+
+#%option
+#% key: olayer
+#% type: string
+#% description: Name of output database table
+#% required : yes
+#%end
+
+#%option
+#% key: host
+#% type: string
+#% label: Host
+#% description: Host name of the machine on which the server is running. 
+#% required : no
+#%end
+
+#%option
+#% key: port
+#% type: integer
+#% label: Port
+#% description: TCP port on which the server is listening, usually 5432.
+#% required : no
+#%end
+
+#%option
+#% key: database
+#% type: string
+#% key_desc : name
+#% gisprompt: old_dbname,dbname,dbname
+#% label: Database
+#% description: Database name
+#% required : yes
+#%end
+
+# AFAIK scheme is not supported well by OGR
+##%option
+##% key: schema
+##% type: string
+##% label: Schema
+##% description: Database schema.
+##% required : no
+##%end
+
+#%option
+#% key: user
+#% type: string
+#% label: User
+#% description: Connect to the database as the user username instead of the  default. 
+#% required : no
+#%end
+
+#%option
+#% key: password
+#% type: string
+#% label: Password
+#% description: Password will be stored in file!
+#% required : no
+#%end
+
+import sys
+import os
+import string
+try:
+    from grass.script import core as grass
+except ImportError:
+    import grass
+except:
+    raise Exception ("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4" )
+
+def main():
+    input = options['input']
+    layer = options['layer']
+    type = options['type']
+    olayer = options['olayer']
+    host = options['host']
+    port = options['port']
+    database = options['database']
+    #schema = options['schema']
+    user = options['user']
+    password = options['password']
+
+    # Construct dsn string
+    dsn = "PG:dbname=" + database
+    if host: dsn += " host=" + host
+    if port: dsn += " port=" + port
+    if user: dsn += " user=" + user
+    if password: dsn += " password=" + password
+
+    if grass.run_command('v.out.ogr', input=input, layer=layer, type=type, format="PostgreSQL", dsn=dsn, olayer=olayer ) != 0:
+        grass.fatal("Cannot export vector to database.")
+	
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()



More information about the QGIS-commit mailing list