[GRASS-SVN] r61806 - grass/trunk/lib/python/temporal
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Sep 5 12:39:51 PDT 2014
Author: huhabla
Date: 2014-09-05 12:39:50 -0700 (Fri, 05 Sep 2014)
New Revision: 61806
Modified:
grass/trunk/lib/python/temporal/abstract_map_dataset.py
grass/trunk/lib/python/temporal/aggregation.py
grass/trunk/lib/python/temporal/c_libraries_interface.py
grass/trunk/lib/python/temporal/core.py
grass/trunk/lib/python/temporal/extract.py
grass/trunk/lib/python/temporal/gui_support.py
grass/trunk/lib/python/temporal/mapcalc.py
grass/trunk/lib/python/temporal/register.py
grass/trunk/lib/python/temporal/stds_export.py
grass/trunk/lib/python/temporal/stds_import.py
grass/trunk/lib/python/temporal/temporal_algebra.py
grass/trunk/lib/python/temporal/univar_statistics.py
Log:
temporal framework: Trying to fix import issues that lead to malfunction temporal framework
Modified: grass/trunk/lib/python/temporal/abstract_map_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_map_dataset.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/abstract_map_dataset.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -342,9 +342,9 @@
'l': self.get_layer()})
return False
else:
- core.error(_("Start time must be of type datetime for "
- "%(type)s map <%(id)s>") % {
- 'type': self.get_type(), 'id': self.get_map_id()})
+ self.msgr.error(_("Start time must be of type datetime for "
+ "%(type)s map <%(id)s>") % {
+ 'type': self.get_type(), 'id': self.get_map_id()})
return False
if end_time and not isinstance(end_time, datetime):
Modified: grass/trunk/lib/python/temporal/aggregation.py
===================================================================
--- grass/trunk/lib/python/temporal/aggregation.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/aggregation.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -24,6 +24,7 @@
"""
from space_time_datasets import *
+import grass.script as gscript
###############################################################################
@@ -131,7 +132,7 @@
# Check if new map is in the temporal database
if new_map.is_in_db(dbif):
- if core.overwrite() == True:
+ if gscript.overwrite() == True:
# Remove the existing temporal database entry
new_map.delete(dbif)
new_map = RasterDataset(map_id)
@@ -144,7 +145,7 @@
'st': str(start), 'end': str(end)}))
# Create the r.series input file
- filename = core.tempfile(True)
+ filename = gscript.tempfile(True)
file = open(filename, 'w')
for name in inputs:
@@ -155,12 +156,12 @@
# Run r.series
if len(inputs) > 1000 :
- ret = core.run_command("r.series", flags="z", file=filename,
- output=output, overwrite=core.overwrite(),
+ ret = gscript.run_command("r.series", flags="z", file=filename,
+ output=output, overwrite=gscript.overwrite(),
method=method)
else:
- ret = core.run_command("r.series", file=filename,
- output=output, overwrite=core.overwrite(),
+ ret = gscript.run_command("r.series", file=filename,
+ output=output, overwrite=gscript.overwrite(),
method=method)
if ret != 0:
@@ -173,7 +174,7 @@
# In case of a null map continue, do not register null maps
if new_map.metadata.get_min() is None and new_map.metadata.get_max() is None:
if not register_null:
- core.run_command("g.remove", rast=output)
+ gscript.run_command("g.remove", rast=output)
return None
return new_map
@@ -207,7 +208,6 @@
@return A list of RasterDataset objects that contain the new map names and
the temporal extent for map registration
"""
- import grass.script as gcore
import grass.pygrass.modules as pymod
import copy
@@ -290,7 +290,7 @@
if len(aggregation_list) > 1:
# Create the r.series input file
- filename = gcore.tempfile(True)
+ filename = gscript.tempfile(True)
file = open(filename, 'w')
for name in aggregation_list:
string = "%s\n" % (name)
@@ -312,4 +312,4 @@
msgr.percent(1, 1, 1)
- return output_list
\ No newline at end of file
+ return output_list
Modified: grass/trunk/lib/python/temporal/c_libraries_interface.py
===================================================================
--- grass/trunk/lib/python/temporal/c_libraries_interface.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/c_libraries_interface.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -59,6 +59,7 @@
:returns: Name of the driver or None if no temporal database present
"""
+
drstring = libtgis.tgis_get_mapset_driver_name(data[1])
conn.send(drstring)
Modified: grass/trunk/lib/python/temporal/core.py
===================================================================
--- grass/trunk/lib/python/temporal/core.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/core.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -39,7 +39,7 @@
import gettext
gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'))
-import grass.script.core as gcore
+import grass.script as gscript
from datetime import datetime
from c_libraries_interface import *
# Import all supported database backends
@@ -400,6 +400,28 @@
# We register this function to be called at exit
atexit.register(stop_subprocesses)
+def get_available_temporal_mapsets():
+ """Return a list of of mapset names with temporal database driver and names
+ that are accessable from the current mapset.
+
+ :returns: A dictionary, mapset names are keys, the tuple (driver, database) are the values
+ """
+ global c_library_interface
+
+ mapsets = c_library_interface.available_mapsets()
+
+ tgis_mapsets = {}
+
+ for mapset in mapsets:
+ driver = c_library_interface.get_driver_name(mapset)
+ database = c_library_interface.get_database_name(mapset)
+
+ if driver and database:
+ tgis_mapsets[mapset] = (driver, database)
+
+ return tgis_mapsets
+
+
###############################################################################
def init(raise_fatal_error=False):
@@ -453,8 +475,8 @@
# We must run t.connect at first to create the temporal database and to
# get the environmental variables
- gcore.run_command("t.connect", flags="c")
- grassenv = gcore.gisenv()
+ gscript.run_command("t.connect", flags="c")
+ grassenv = gscript.gisenv()
# Set the global variable for faster access
current_mapset = grassenv["MAPSET"]
@@ -467,7 +489,7 @@
# Check if the script library raises on error,
# if so we do the same
- if gcore.get_raise_on_error() is True:
+ if gscript.get_raise_on_error() is True:
raise_on_error = True
# Start the GRASS message interface server
@@ -515,7 +537,7 @@
dbmi = sqlite3
else:
# Set the default sqlite3 connection in case nothing was defined
- gcore.run_command("t.connect", flags="d")
+ gscript.run_command("t.connect", flags="d")
driver_string = ciface.get_driver_name()
database_string = ciface.get_database_name()
tgis_backend = driver_string
Modified: grass/trunk/lib/python/temporal/extract.py
===================================================================
--- grass/trunk/lib/python/temporal/extract.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/extract.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -16,6 +16,7 @@
from space_time_datasets import *
from open_stds import *
from multiprocessing import Process
+import grass.script as gscript
############################################################################
@@ -62,7 +63,7 @@
sp = open_old_stds(input, type, dbif)
# Check the new stds
new_sp = check_new_stds(output, type, dbif,
- core.overwrite())
+ gscript.overwrite())
if type == "vector":
rows = sp.get_registered_maps(
"id,name,mapset,layer", where, "start_time", dbif)
@@ -105,7 +106,7 @@
# Check if new map is in the temporal database
if new_map.is_in_db(dbif):
- if core.overwrite():
+ if gscript.overwrite():
# Remove the existing temporal database entry
new_map.delete(dbif)
new_map = sp.get_new_map_instance(map_id)
@@ -170,7 +171,7 @@
sp.get_temporal_type(),
title, description,
semantic_type, dbif,
- core.overwrite())
+ gscript.overwrite())
# collect empty maps to remove them
empty_maps = []
@@ -235,11 +236,11 @@
names += ",%s" % (map.get_name())
count += 1
if type == "raster":
- core.run_command("g.remove", rast=names, quiet=True)
+ gscript.run_command("g.remove", rast=names, quiet=True)
elif type == "raster3d":
- core.run_command("g.remove", rast3d=names, quiet=True)
+ gscript.run_command("g.remove", rast3d=names, quiet=True)
elif type == "vector":
- core.run_command("g.remove", vect=names, quiet=True)
+ gscript.run_command("g.remove", vect=names, quiet=True)
dbif.close()
@@ -248,18 +249,18 @@
def run_mapcalc2d(expr):
"""Helper function to run r.mapcalc in parallel"""
- exit(core.run_command("r.mapcalc", expression=expr,
- overwrite=core.overwrite(), quiet=True))
+ exit(gscript.run_command("r.mapcalc", expression=expr,
+ overwrite=gscript.overwrite(), quiet=True))
def run_mapcalc3d(expr):
"""Helper function to run r3.mapcalc in parallel"""
- exit(core.run_command("r3.mapcalc", expression=expr,
- overwrite=core.overwrite(), quiet=True))
+ exit(gscript.run_command("r3.mapcalc", expression=expr,
+ overwrite=gscript.overwrite(), quiet=True))
def run_vector_extraction(input, output, layer, type, where):
"""Helper function to run r.mapcalc in parallel"""
- exit(core.run_command("v.extract", input=input, output=output,
+ exit(gscript.run_command("v.extract", input=input, output=output,
layer=layer, type=type, where=where,
- overwrite=core.overwrite(), quiet=True))
+ overwrite=gscript.overwrite(), quiet=True))
Modified: grass/trunk/lib/python/temporal/gui_support.py
===================================================================
--- grass/trunk/lib/python/temporal/gui_support.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/gui_support.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -15,6 +15,7 @@
from space_time_datasets import *
from factory import *
+import grass.script as gscript
###############################################################################
@@ -46,7 +47,7 @@
for type in types:
try:
tlist_result = tlist(type=type, dbif=dbif)
- except core.ScriptError as e:
+ except gscript.ScriptError as e:
warning(e)
continue
Modified: grass/trunk/lib/python/temporal/mapcalc.py
===================================================================
--- grass/trunk/lib/python/temporal/mapcalc.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/mapcalc.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -15,6 +15,7 @@
from space_time_datasets import *
from open_stds import *
from multiprocessing import Process
+import grass.script as gscript
############################################################################
@@ -98,7 +99,7 @@
input_list.append(copy.copy(sp))
new_sp = check_new_stds(output, type, dbif,
- core.overwrite())
+ gscript.overwrite())
# Sample all inputs by the first input and create a sample matrix
if spatial:
@@ -227,7 +228,7 @@
# Check if new map is in the temporal database
if new_map.is_in_db(dbif):
- if core.overwrite():
+ if gscript.overwrite():
# Remove the existing temporal database entry
new_map.delete(dbif)
new_map = first_input.get_new_map_instance(map_id)
@@ -284,7 +285,7 @@
new_sp = open_new_stds(output, type,
temporal_type, title, description,
semantic_type, dbif,
- core.overwrite())
+ gscript.overwrite())
count = 0
# collect empty maps to remove them
@@ -329,9 +330,9 @@
names += ",%s" % (map.get_name())
count += 1
if type == "raster":
- core.run_command("g.remove", rast=names, quiet=True)
+ gscript.run_command("g.remove", rast=names, quiet=True)
elif type == "raster3d":
- core.run_command("g.remove", rast3d=names, quiet=True)
+ gscript.run_command("g.remove", rast3d=names, quiet=True)
dbif.close()
@@ -340,16 +341,16 @@
def _run_mapcalc2d(expr):
"""Helper function to run r.mapcalc in parallel"""
- exit(core.run_command("r.mapcalc", expression=expr,
- overwrite=core.overwrite(), quiet=True))
+ exit(gscript.run_command("r.mapcalc", expression=expr,
+ overwrite=gscript.overwrite(), quiet=True))
###############################################################################
def _run_mapcalc3d(expr):
"""Helper function to run r3.mapcalc in parallel"""
- exit(core.run_command("r3.mapcalc", expression=expr,
- overwrite=core.overwrite(), quiet=True))
+ exit(gscript.run_command("r3.mapcalc", expression=expr,
+ overwrite=gscript.overwrite(), quiet=True))
###############################################################################
Modified: grass/trunk/lib/python/temporal/register.py
===================================================================
--- grass/trunk/lib/python/temporal/register.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/register.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -23,6 +23,7 @@
"""
from open_stds import *
+import grass.script as gscript
###############################################################################
@@ -217,7 +218,7 @@
else:
is_in_db = True
# Check the overwrite flag
- if not core.overwrite():
+ if not gscript.overwrite():
if map.get_layer():
msgr.warning(_("Map is already registered in temporal "
"database. Unable to update %(t)s map "
@@ -444,13 +445,12 @@
@param dbif The database interface to be used
"""
- import grass.script as gcore
import grass.pygrass.modules as pymod
import copy
dbif, connected = init_dbif(dbif)
- filename = gcore.tempfile(True)
+ filename = gscript.tempfile(True)
file = open(filename, 'w')
empty_maps = []
Modified: grass/trunk/lib/python/temporal/stds_export.py
===================================================================
--- grass/trunk/lib/python/temporal/stds_export.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/stds_export.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -36,6 +36,7 @@
from space_time_datasets import *
from factory import *
from open_stds import *
+import grass.script as gscript
proj_file_name = "proj.txt"
init_file_name = "init.txt"
@@ -79,31 +80,31 @@
gdal_type = "UInt32"
else:
gdal_type = "Int32"
- ret = core.run_command("r.out.gdal", flags="c", input=name,
+ ret = gscript.run_command("r.out.gdal", flags="c", input=name,
output=out_name, nodata=nodata,
type=gdal_type, format="GTiff")
else:
- ret = core.run_command("r.out.gdal", flags="c",
+ ret = gscript.run_command("r.out.gdal", flags="c",
input=name, output=out_name, format="GTiff")
elif format_ == "AAIGrid":
# Export the raster map with r.out.gdal as Arc/Info ASCII Grid
out_name = name + ".asc"
- ret = core.run_command("r.out.gdal", flags="c", input=name, output=out_name, format="AAIGrid")
+ ret = gscript.run_command("r.out.gdal", flags="c", input=name, output=out_name, format="AAIGrid")
if ret != 0:
shutil.rmtree(new_cwd)
tar.close()
- core.fatal(_("Unable to export raster map <%s>" % name))
+ gscript.fatal(_("Unable to export raster map <%s>" % name))
tar.add(out_name)
# Export the color rules
out_name = name + ".color"
- ret = core.run_command("r.colors.out", map=name, rules=out_name)
+ ret = gscript.run_command("r.colors.out", map=name, rules=out_name)
if ret != 0:
shutil.rmtree(new_cwd)
tar.close()
- core.fatal(_("Unable to export color rules for raster "
+ gscript.fatal(_("Unable to export color rules for raster "
"map <%s> r.out.gdal" % name))
tar.add(out_name)
@@ -121,11 +122,11 @@
# Write the filename, the start_time and the end_time
list_file.write(string)
# Export the raster map with r.pack
- ret = core.run_command("r.pack", input=name, flags="c")
+ ret = gscript.run_command("r.pack", input=name, flags="c")
if ret != 0:
shutil.rmtree(new_cwd)
tar.close()
- core.fatal(_("Unable to export raster map <%s> with r.pack" %
+ gscript.fatal(_("Unable to export raster map <%s> with r.pack" %
name))
tar.add(name + ".pack")
@@ -146,12 +147,12 @@
# Write the filename, the start_time and the end_time
list_file.write(string)
# Export the vector map with v.out.ogr
- ret = core.run_command("v.out.ogr", input=name, dsn=(name + ".xml"),
+ ret = gscript.run_command("v.out.ogr", input=name, dsn=(name + ".xml"),
layer=layer, format="GML")
if ret != 0:
shutil.rmtree(new_cwd)
tar.close()
- core.fatal(_("Unable to export vector map <%s> as "
+ gscript.fatal(_("Unable to export vector map <%s> as "
"GML with v.out.ogr" % name))
tar.add(name + ".xml")
@@ -178,11 +179,11 @@
# Write the filename, the start_time and the end_time
list_file.write(string)
# Export the vector map with v.pack
- ret = core.run_command("v.pack", input=name, flags="c")
+ ret = gscript.run_command("v.pack", input=name, flags="c")
if ret != 0:
shutil.rmtree(new_cwd)
tar.close()
- core.fatal(_("Unable to export vector map <%s> with v.pack" %
+ gscript.fatal(_("Unable to export vector map <%s> with v.pack" %
name))
tar.add(name + ".pack")
@@ -203,11 +204,11 @@
# Write the filename, the start_time and the end_time
list_file.write(string)
# Export the raster 3d map with r3.pack
- ret = core.run_command("r3.pack", input=name, flags="c")
+ ret = gscript.run_command("r3.pack", input=name, flags="c")
if ret != 0:
shutil.rmtree(new_cwd)
tar.close()
- core.fatal(_("Unable to export raster map <%s> with r3.pack" %
+ gscript.fatal(_("Unable to export raster map <%s> with r3.pack" %
name))
tar.add(name + ".pack")
@@ -295,7 +296,7 @@
list_file.close()
# Write projection and metadata
- proj = core.read_command("g.proj", flags="j")
+ proj = gscript.read_command("g.proj", flags="j")
proj_file = open(proj_file_name, "w")
proj_file.write(proj)
@@ -324,7 +325,7 @@
init_file.write(string)
init_file.close()
- metadata = core.read_command("t.info", type=type_, input=sp.get_id())
+ metadata = gscript.read_command("t.info", type=type_, input=sp.get_id())
metadata_file = open(metadata_file_name, "w")
metadata_file.write(metadata)
metadata_file.close()
Modified: grass/trunk/lib/python/temporal/stds_import.py
===================================================================
--- grass/trunk/lib/python/temporal/stds_import.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/stds_import.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -40,6 +40,7 @@
from register import *
import factory
from factory import *
+import grass.script as gscript
proj_file_name = "proj.txt"
init_file_name = "init.txt"
@@ -70,33 +71,33 @@
impflags += "o"
if link:
- ret = core.run_command("r.external", input=filename,
+ ret = gscript.run_command("r.external", input=filename,
output=name,
flags=impflags,
- overwrite=core.overwrite())
+ overwrite=gscript.overwrite())
else:
- ret = core.run_command("r.in.gdal", input=filename,
+ ret = gscript.run_command("r.in.gdal", input=filename,
output=name,
flags=impflags,
- overwrite=core.overwrite())
+ overwrite=gscript.overwrite())
if ret != 0:
- core.fatal(_("Unable to import/link raster map <%s> from file %s.") %(name,
+ gscript.fatal(_("Unable to import/link raster map <%s> from file %s.") %(name,
filename))
# Set the color rules if present
filename = row["filename"] + ".color"
if os.path.isfile(filename):
- ret = core.run_command("r.colors", map=name,
+ ret = gscript.run_command("r.colors", map=name,
rules=filename,
- overwrite=core.overwrite())
+ overwrite=gscript.overwrite())
if ret != 0:
- core.fatal(_("Unable to set the color rules for "
+ gscript.fatal(_("Unable to set the color rules for "
"raster map <%s>.") % name)
# Set the computational region from the last map imported
if set_current_region is True:
- core.run_command("g.region", rast=name)
+ gscript.run_command("g.region", rast=name)
############################################################################
@@ -108,19 +109,19 @@
for row in maplist:
name = row["name"]
filename = row["filename"] + ".pack"
- ret = core.run_command("r.unpack", input=filename,
+ ret = gscript.run_command("r.unpack", input=filename,
output=name,
flags=impflags,
- overwrite=core.overwrite(),
+ overwrite=gscript.overwrite(),
verbose=True)
if ret != 0:
- core.fatal(_("Unable to unpack raster map <%s> from file %s.") % (name,
+ gscript.fatal(_("Unable to unpack raster map <%s> from file %s.") % (name,
filename))
# Set the computational region from the last map imported
if set_current_region is True:
- core.run_command("g.region", rast=name)
+ gscript.run_command("g.region", rast=name)
############################################################################
@@ -133,13 +134,13 @@
name = row["name"]
filename = row["filename"] + ".xml"
- ret = core.run_command("v.in.ogr", dsn=filename,
+ ret = gscript.run_command("v.in.ogr", dsn=filename,
output=name,
flags=impflags,
- overwrite=core.overwrite())
+ overwrite=gscript.overwrite())
if ret != 0:
- core.fatal(_("Unable to import vector map <%s> from file %s.") % (name,
+ gscript.fatal(_("Unable to import vector map <%s> from file %s.") % (name,
filename))
############################################################################
@@ -156,14 +157,14 @@
if name in imported_maps:
continue
filename = row["filename"] + ".pack"
- ret = core.run_command("v.unpack", input=filename,
+ ret = gscript.run_command("v.unpack", input=filename,
output=name,
flags=impflags,
- overwrite=core.overwrite(),
+ overwrite=gscript.overwrite(),
verbose=True)
if ret != 0:
- core.fatal(_("Unable to unpack vector map <%s> from file %s.") % (name,
+ gscript.fatal(_("Unable to unpack vector map <%s> from file %s.") % (name,
filename))
imported_maps[name] = name
@@ -196,15 +197,15 @@
"""
global raise_on_error
- old_state = core.raise_on_error
- core.set_raise_on_error(True)
+ old_state = gscript.raise_on_error
+ gscript.set_raise_on_error(True)
# Check if input file and extraction directory exits
if not os.path.exists(input):
- core.fatal(_("Space time raster dataset archive <%s> not found")
+ gscript.fatal(_("Space time raster dataset archive <%s> not found")
% input)
if not create and not os.path.exists(extrdir):
- core.fatal(_("Extraction directory <%s> not found") % extrdir)
+ gscript.fatal(_("Extraction directory <%s> not found") % extrdir)
tar = tarfile.open(name=input, mode='r')
@@ -212,11 +213,11 @@
members = tar.getnames()
if init_file_name not in members:
- core.fatal(_("Unable to find init file <%s>") % init_file_name)
+ gscript.fatal(_("Unable to find init file <%s>") % init_file_name)
if list_file_name not in members:
- core.fatal(_("Unable to find list file <%s>") % list_file_name)
+ gscript.fatal(_("Unable to find list file <%s>") % list_file_name)
if proj_file_name not in members:
- core.fatal(_("Unable to find projection file <%s>") % proj_file_name)
+ gscript.fatal(_("Unable to find projection file <%s>") % proj_file_name)
tar.extractall(path=extrdir)
tar.close()
@@ -231,31 +232,31 @@
# Check projection information
if not location:
- temp_name = core.tempfile()
+ temp_name = gscript.tempfile()
temp_file = open(temp_name, "w")
proj_name = os.path.abspath(proj_file_name)
- p = core.start_command("g.proj", flags="j", stdout=temp_file)
+ p = gscript.start_command("g.proj", flags="j", stdout=temp_file)
p.communicate()
temp_file.close()
- if not core.compare_key_value_text_files(temp_name, proj_name, sep="="):
+ if not gscript.compare_key_value_text_files(temp_name, proj_name, sep="="):
if overr:
- core.warning(_("Projection information does not match. "
+ gscript.warning(_("Projection information does not match. "
"Proceeding..."))
else:
- diff = ''.join(core.diff_files(temp_name, proj_name))
- core.warning(_("Difference between PROJ_INFO file of imported map "
+ diff = ''.join(gscript.diff_files(temp_name, proj_name))
+ gscript.warning(_("Difference between PROJ_INFO file of imported map "
"and of current location:\n{diff}").format(diff=diff))
- core.fatal(_("Projection information does not match. Aborting."))
+ gscript.fatal(_("Projection information does not match. Aborting."))
# Create a new location based on the projection information and switch
# into it
- old_env = core.gisenv()
+ old_env = gscript.gisenv()
if location:
try:
proj4_string = open(proj_file_name, 'r').read()
- core.create_location(dbase=old_env["GISDBASE"],
+ gscript.create_location(dbase=old_env["GISDBASE"],
location=location,
proj4=proj4_string)
# Just create a new location and return
@@ -263,18 +264,18 @@
os.chdir(old_cwd)
return
except Exception as e:
- core.fatal(_("Unable to create location %(l)s. Reason: %(e)s")
+ gscript.fatal(_("Unable to create location %(l)s. Reason: %(e)s")
% {'l': location, 'e': str(e)})
# Switch to the new created location
- ret = core.run_command("g.mapset", mapset="PERMANENT",
+ ret = gscript.run_command("g.mapset", mapset="PERMANENT",
location=location,
gisdbase=old_env["GISDBASE"])
if ret != 0:
- core.fatal(_("Unable to switch to location %s") % location)
+ gscript.fatal(_("Unable to switch to location %s") % location)
# create default database connection
- ret = core.run_command("t.connect", flags="d")
+ ret = gscript.run_command("t.connect", flags="d")
if ret != 0:
- core.fatal(_("Unable to create default temporal database "
+ gscript.fatal(_("Unable to create default temporal database "
"in new location %s") % location)
try:
@@ -339,13 +340,13 @@
if "temporal_type" not in init or \
"semantic_type" not in init or \
"number_of_maps" not in init:
- core.fatal(_("Key words %(t)s, %(s)s or %(n)s not found in init"
+ gscript.fatal(_("Key words %(t)s, %(s)s or %(n)s not found in init"
" file.") % {'t': "temporal_type",
's': "semantic_type",
'n': "number_of_maps"})
if line_count != int(init["number_of_maps"]):
- core.fatal(_("Number of maps mismatch in init and list file."))
+ gscript.fatal(_("Number of maps mismatch in init and list file."))
format_ = "GTiff"
type_ = "strds"
@@ -356,26 +357,26 @@
format_ = init["format"]
if stds_type != type_:
- core.fatal(_("The archive file is of wrong space time dataset type"))
+ gscript.fatal(_("The archive file is of wrong space time dataset type"))
# Check the existence of the files
if format_ == "GTiff":
for row in maplist:
filename = row["filename"] + ".tif"
if not os.path.exists(filename):
- core.fatal(_("Unable to find GeoTIFF raster file "
+ gscript.fatal(_("Unable to find GeoTIFF raster file "
"<%s> in archive.") % filename)
elif format_ == "AAIGrid":
for row in maplist:
filename = row["filename"] + ".asc"
if not os.path.exists(filename):
- core.fatal(_("Unable to find AAIGrid raster file "
+ gscript.fatal(_("Unable to find AAIGrid raster file "
"<%s> in archive.") % filename)
elif format_ == "GML":
for row in maplist:
filename = row["filename"] + ".xml"
if not os.path.exists(filename):
- core.fatal(_("Unable to find GML vector file "
+ gscript.fatal(_("Unable to find GML vector file "
"<%s> in archive.") % filename)
elif format_ == "pack":
for row in maplist:
@@ -384,16 +385,16 @@
else:
filename = row["filename"] + ".pack"
if not os.path.exists(filename):
- core.fatal(_("Unable to find GRASS package file "
+ gscript.fatal(_("Unable to find GRASS package file "
"<%s> in archive.") % filename)
else:
- core.fatal(_("Unsupported input format"))
+ gscript.fatal(_("Unsupported input format"))
# Check the space time dataset
id = output + "@" + mapset
sp = dataset_factory(type_, id)
- if sp.is_in_db() and core.overwrite() == False:
- core.fatal(_("Space time %(t)s dataset <%(sp)s> is already in the "
+ if sp.is_in_db() and gscript.overwrite() == False:
+ gscript.fatal(_("Space time %(t)s dataset <%(sp)s> is already in the "
"database. Use the overwrite flag.") % {'t': type_,
'sp': sp.get_id()})
@@ -412,8 +413,8 @@
_import_vector_maps(maplist)
# Create the space time dataset
- if sp.is_in_db() and core.overwrite() == True:
- core.info(_("Overwrite space time %(sp)s dataset "
+ if sp.is_in_db() and gscript.overwrite() == True:
+ gscript.info(_("Overwrite space time %(sp)s dataset "
"<%(id)s> and unregister all maps.") % {
'sp': sp.get_new_map_instance(None).get_type(),
'id': sp.get_id()})
@@ -425,11 +426,11 @@
relative_time_unit = None
if temporal_type == "relative":
if "relative_time_unit" not in init:
- core.fatal(_("Key word %s not found in init file.") % ("relative_time_unit"))
+ gscript.fatal(_("Key word %s not found in init file.") % ("relative_time_unit"))
relative_time_unit = init["relative_time_unit"]
sp.set_relative_time_unit(relative_time_unit)
- core.verbose(_("Create space time %s dataset.") %
+ gscript.verbose(_("Create space time %s dataset.") %
sp.get_new_map_instance(None).get_type())
sp.set_initial_values(temporal_type=temporal_type,
@@ -453,8 +454,8 @@
finally:
if location:
# Switch to the old location
- ret = core.run_command("g.mapset", mapset=old_env["MAPSET"],
+ ret = gscript.run_command("g.mapset", mapset=old_env["MAPSET"],
location=old_env["LOCATION_NAME"],
gisdbase=old_env["GISDBASE"])
- core.set_raise_on_error(old_state)
+ gscript.set_raise_on_error(old_state)
Modified: grass/trunk/lib/python/temporal/temporal_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_algebra.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/temporal_algebra.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -1434,8 +1434,7 @@
tvardict["END_DATE"] = end.date()
tvardict["END_DATETIME"] = end
tvardict["END_TIME"] = end.time()
- #core.fatal(_("The temporal functions for map <%s> only supported for absolute"\
- # "time." % (str(map.get_id()))))
+
return(tvardict)
def eval_datetime_str(self, tfuncval, comp, value):
Modified: grass/trunk/lib/python/temporal/univar_statistics.py
===================================================================
--- grass/trunk/lib/python/temporal/univar_statistics.py 2014-09-05 11:58:24 UTC (rev 61805)
+++ grass/trunk/lib/python/temporal/univar_statistics.py 2014-09-05 19:39:50 UTC (rev 61806)
@@ -24,6 +24,7 @@
"""
from open_stds import *
+import grass.script as gscript
###############################################################################
@@ -51,7 +52,7 @@
if not rows:
dbif.close()
- core.fatal(_("Space time %(sp)s dataset <%(i)s> is empty") % {
+ gscript.fatal(_("Space time %(sp)s dataset <%(i)s> is empty") % {
'sp': sp.get_new_map_instance(None).get_type(), 'i': sp.get_id()})
if no_header is False:
@@ -78,15 +79,15 @@
flag += "e"
if type == "strds":
- stats = core.parse_command("r.univar", map=id, flags=flag)
+ stats = gscript.parse_command("r.univar", map=id, flags=flag)
elif type == "str3ds":
- stats = core.parse_command("r3.univar", map=id, flags=flag)
+ stats = gscript.parse_command("r3.univar", map=id, flags=flag)
if not stats:
if type == "strds":
- core.warning(_("Unable to get statistics for raster map <%s>") % id)
+ gscript.warning(_("Unable to get statistics for raster map <%s>") % id)
elif type == "str3ds":
- core.warning(_("Unable to get statistics for 3d raster map <%s>") % id)
+ gscript.warning(_("Unable to get statistics for 3d raster map <%s>") % id)
continue
string += str(id) + fs + str(start) + fs + str(end)
@@ -136,7 +137,7 @@
if sp.is_in_db(dbif) == False:
dbif.close()
- core.fatal(_("Space time %(sp)s dataset <%(i)s> not found") % {
+ gscript.fatal(_("Space time %(sp)s dataset <%(i)s> not found") % {
'sp': sp.get_new_map_instance(None).get_type(), 'i': id})
sp.select(dbif)
@@ -146,7 +147,7 @@
if not rows:
dbif.close()
- core.fatal(_("Space time %(sp)s dataset <%(i)s> is empty") % {
+ gscript.fatal(_("Space time %(sp)s dataset <%(i)s> is empty") % {
'sp': sp.get_new_map_instance(None).get_type(), 'i': id})
string = ""
@@ -180,14 +181,14 @@
if not mylayer:
mylayer = layer
- stats = core.parse_command("v.univar", map=id, where=where,
+ stats = gscript.parse_command("v.univar", map=id, where=where,
column=column, layer=mylayer,
type=type, flags=flags)
string = ""
if not stats:
- core.warning(_("Unable to get statistics for vector map <%s>") % id)
+ gscript.warning(_("Unable to get statistics for vector map <%s>") % id)
continue
string += str(id) + fs + str(start) + fs + str(end)
More information about the grass-commit
mailing list