code: def exec_command(args, env=None):
       
      try:
          cmd = subprocess.Popen(args, 
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE, 
                                 bufsize=buffSize,
                                 env=env)
      except OSError, e:
          raise Exception("Execution of command failed.\n",
                          "  Command: %s\n  Error: %s" % (' '.join(args), str(e)))
      out, err = cmd.communicate(None)
      if cmd.returncode != 0:
          raise Exception("Execution of command failed with error code: %s\n%s\n" 
                          % (cmd.returncode, err))
      return out
docs: Convenience function that executes command and returns result.
      
      @param args: Tuple of command and arguments.
      @param env:  Dictionary of environment variables.
                   (Environment is not modified if None.)
      @return:     Command output.