Output/stdout from python script in Sikuli IDE was cut

Asked by Li Jinjing on 2019-01-18


Here we use Sikuli for UI automation testing on Windows environment.

Recently, I run a simple python script as below to get the information of installed APP on windows, three scenarioes:
1) Run "python Getinstall.py" in powershell console or cmd console, I could get all information, output/stdout is 6.26KB
2) Run script in Sikuli IDE, only I could get partly information, output/stdout is 3.87KB
3) Run "runsikulix.cmd -r C:\test.sikuli", output/stdout is same as 2):
      +++ using: -Xms1024M -Xmx1024M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine -jar C:\Sikuli\sikulix.jar -r C:\test.sikuli

I am new user, I guess maybe the output was limited in sikulix.jar, I just want to know how could I reset or modify the corresponding code or paras about this phenomenon?

BTW, the python script is as below, very simple:
import subprocess

args = [r"C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe", "-ExecutionPolicy", "Unrestricted", r"C:\Sikuli\scripts\GetInstalledSoftware.ps1"]

p = subprocess.Popen(args, stdout=subprocess.PIPE)
dt = p.stdout.read()
print dt.decode("gbk")

Thanks a lot

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

shouldn't you wait for subprocess completion?

Please check wether the simple read does so.

The termination of the script after the print might happen too fast and the subprocess is killed.

BTW: There is a feature, to run PowerShell snippets from within SikuliX script. I would highly appreciate, if you would give it a try and feedback.
see: https://sikulix-2014.readthedocs.io/en/latest/scripting.html#running-scripts-and-snippets-from-within-other-scripts-and-run-scripts-one-after-the-other

... towards the end: runScript(snippet)

Li Jinjing (jinjingpiggy) said : #2

Thanks for your reply.

I followed the steps in the Example for powershell, run "returnCode = runScript('powershell get-process)" in sikuli IDE,
 the result is :
[info] runcmd: cmd.exe /S /C "type C:\Users\CMIT\AppData\Local\Temp\Sikulix_881594347\sikuli-2746129110149361635.ps1 | powershell -noprofile -"

Seem not correct, :)

Li Jinjing (jinjingpiggy) said : #3

And I think this runScript is a little limited for us, cause we need to deal the strings from powershell script.

And are there any suggestions about how to use subprocess.popen or os.popen in Sikuli IDE?

Can you help with this problem?

Provide an answer of your own, or ask Li Jinjing for more information if necessary.

To post a message you must log in.