|
@@ -597,29 +597,48 @@ def RunCommand(prog, flags = "", overwrite = False, quiet = False, verbose = Fal
|
|
|
|
|
|
ps = grass.start_command(prog, flags, overwrite, quiet, verbose, **kwargs)
|
|
ps = grass.start_command(prog, flags, overwrite, quiet, verbose, **kwargs)
|
|
|
|
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): command started")
|
|
|
|
+
|
|
if stdin:
|
|
if stdin:
|
|
ps.stdin.write(stdin)
|
|
ps.stdin.write(stdin)
|
|
ps.stdin.close()
|
|
ps.stdin.close()
|
|
ps.stdin = None
|
|
ps.stdin = None
|
|
|
|
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): decoding string")
|
|
stdout, stderr = map(lambda x: utils.DecodeString(x) if type(x) is types.StringType else x, ps.communicate())
|
|
stdout, stderr = map(lambda x: utils.DecodeString(x) if type(x) is types.StringType else x, ps.communicate())
|
|
|
|
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): get return code")
|
|
ret = ps.returncode
|
|
ret = ps.returncode
|
|
|
|
|
|
- if ret != 0 and parent:
|
|
|
|
- GError(parent = parent,
|
|
|
|
- message = stderr)
|
|
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): print error")
|
|
|
|
+ if ret != 0 and parent:
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): error %s" % stderr)
|
|
|
|
+ if (stderr == None):
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): nothing to print ???")
|
|
|
|
+ else:
|
|
|
|
+ GError(parent = parent,
|
|
|
|
+ message = stderr)
|
|
|
|
+
|
|
|
|
+ if ret != 0:
|
|
|
|
+ return None
|
|
|
|
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): print read error")
|
|
if not read:
|
|
if not read:
|
|
if not getErrorMsg:
|
|
if not getErrorMsg:
|
|
return ret
|
|
return ret
|
|
else:
|
|
else:
|
|
return ret, _formatMsg(stderr)
|
|
return ret, _formatMsg(stderr)
|
|
|
|
|
|
|
|
+ if stdout:
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): return stdout %s" % stdout)
|
|
|
|
+ else:
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): return stdout = None")
|
|
if not getErrorMsg:
|
|
if not getErrorMsg:
|
|
return stdout
|
|
return stdout
|
|
|
|
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): return ret, stdout")
|
|
if read and getErrorMsg:
|
|
if read and getErrorMsg:
|
|
return ret, stdout, _formatMsg(stderr)
|
|
return ret, stdout, _formatMsg(stderr)
|
|
|
|
|
|
|
|
+ Debug.msg(1, "gcmd.RunCommand(): return result")
|
|
return stdout, _formatMsg(stderr)
|
|
return stdout, _formatMsg(stderr)
|