We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
https://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.84).aspx by default does not wait for the command to complete, so Log.Warning(Sys.Clipboard) happens before diff completes. To make it wait you need to specify True as the third parameter of the Run method.
WshShell.Run(diffCmd, 0, True)
Alternatively, you can use Python's built-in https://docs.python.org/3/library/subprocess.html#subprocess.check_output so you won't have to deal with the clipboard:
import subprocess
def diffTwoFilesToLog(file1, file2):
output = subprocess.check_output(["C:\\Program Files (x86)\\GnuWin32\\bin\\diff.exe", file1, file2])
output = output.decode() # convert byte-string to string
Log.Warning(output)
OK so I worked around the problem by not using the clipboard and getting what I needed via standard output. I changed WshShell.Run to WShShell.Exec, then got the standard output from the object that WshShel.Exec returns.
def diffTwoFilesToLog(file1, file2): diffCmd = "\"C:\\Program Files (x86)\\GnuWin32\\bin\\diff.exe\" " + file1 + " " + file2 execResult = WshShell.Exec(diffCmd) sout = execResult.StdOut Log.Warning(sout.ReadAll())
I'm still a bit confused why Sys.Clipboard was not working before with the previous example though.