Browse Source

Add execution time attribute to the class Module

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58114 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 11 years ago
parent
commit
08f4e66cb4
1 changed files with 4 additions and 0 deletions
  1. 4 0
      lib/python/pygrass/modules/interface/module.py

+ 4 - 0
lib/python/pygrass/modules/interface/module.py

@@ -52,6 +52,7 @@ from __future__ import print_function
 import subprocess
 from itertools import izip_longest
 from xml.etree.ElementTree import fromstring
+import time
 
 
 from grass.pygrass.errors import GrassError, ParameterError
@@ -298,6 +299,7 @@ class Module(object):
         diz['name'] = 'stderr'
         self.outputs['stderr'] = Parameter(diz=diz)
         self.popen = None
+        self.time = None
 
         if args or kargs:
             self.__call__(*args, **kargs)
@@ -460,6 +462,7 @@ class Module(object):
         if self.outputs['stderr'].value:
             self.stderr_ = self.outputs['stderr'].value
         cmd = self.make_cmd()
+        start = time.time()
         self.popen = subprocess.Popen(cmd,
                                       stdin=self.stdin_,
                                       stdout=self.stdout_,
@@ -469,6 +472,7 @@ class Module(object):
             stdout, stderr = self.popen.communicate(input=self.stdin)
             self.outputs['stdout'].value = stdout if stdout else ''
             self.outputs['stderr'].value = stderr if stderr else ''
+            self.time = time.time() - start
 
 ###############################################################################