瀏覽代碼

Better increment format check

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51893 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 13 年之前
父節點
當前提交
88b87c9400
共有 2 個文件被更改,包括 8 次插入0 次删除
  1. 4 0
      lib/python/temporal/datetime_math.py
  2. 4 0
      lib/python/temporal/space_time_datasets_tools.py

+ 4 - 0
lib/python/temporal/datetime_math.py

@@ -79,8 +79,12 @@ def increment_datetime_by_string(mydate, increment, mult = 1):
         incparts = increment.split(",")
         for incpart in incparts:
             inclist.append(incpart.strip().split(" "))
+            
 
         for inc in inclist:
+	    if len(inc) < 2:
+		core.error(_("Wrong increment format: %s") % (increment))
+		return None
             if inc[1].find("seconds") >= 0:
                 seconds = mult * int(inc[0])
             elif inc[1].find("minutes") >= 0:

+ 4 - 0
lib/python/temporal/space_time_datasets_tools.py

@@ -295,8 +295,12 @@ def assign_valid_time_to_map(ttype, map, start, end, unit, increment=None, mult=
         # Add the increment
         if increment:
             start_time = increment_datetime_by_string(start_time, increment, mult)
+            if start_time == None:
+		core.fatal(_("Error in increment computation"))
             if interval:
                 end_time = increment_datetime_by_string(start_time, increment, 1)
+		if end_time == None:
+		    core.fatal(_("Error in increment computation"))
 	if map.get_layer():
 	    core.verbose(_("Set absolute valid time for map <%s> with layer %s to %s - %s") % (map.get_map_id(), map.get_layer(), str(start_time), str(end_time)))
         else: