In Sikuli r930, how to trigger a commad, such as "Ping" ?

Asked by Milton_Wu

Hi, Sir,

In Sikuli r905 version,
I can trigger a "ping" command through os.systm("Ping www.google.com > test.log")
It works fine to record the ping result in a file.

However, in the latest version r930,
the sikuli always show an type error: "TypeError: unsupported operand type(s) for +: 'NoneType' and 'list"

Do I have any chance to use command in Sikuli r930 version?

I also attach the source code and error message in the following.
Thnaks in advance.
~~~~~~~~~~~~~~~~~~~~~~~
Sample Source Code:
=================================
import os
import sys
import time

#need to create the file in the corresponding path
My_Log_File = "C:\Log\MyTest.log"
Ping_IP = "www.google.com"

if os.path.exists(My_Log_File):
    os.remove(My_Log_File)

time.sleep (3)
os.system("ping "+ Ping_IP + ">" + My_Log_File)
time.sleep (3)
log_file = open(My_Log_File, "a+")
log_file.write("=====Test=====\n")
log_file.close()
=====================================
Error message in r930:
------------------------------------------------------------
[info] Sikuli vision engine loaded.
[info] Windows utilities loaded.

[info] VDictProxy loaded.

[error] Stopped
[error] An error occurs at line 13
[error] Error message: Traceback (most recent call last):
 File "C:\Users\pegatron\AppData\Local\Temp\sikuli-tmp8426656929974300277.py", line 13, in
 os.system("ping "+ Ping_IP + ">" + My_Log_File)
 File "C:\win8\Sikuli-r930-win32\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\subprocess.py", line 456, in call
 File "C:\win8\Sikuli-r930-win32\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\subprocess.py", line 751, in __init__
 File "C:\win8\Sikuli-r930-win32\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\subprocess.py", line 1236, in _execute_child
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
---------------------------------------------------------------------

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Not a Sikuli problem. Jython does not accept your command string.

I guess, it is because of the backslashes:
either double (escape) them or use raw string r"text" (preferable in this case):

My_Log_File = r"C:\Log\MyTest.log"

Revision history for this message
Milton_Wu (milton-wu) said :
#2

Thanks for your prompt response.

However, I still got the same error message.
after I change my My_Log_File to My_Log_File = r"C:\Log\MyTest.log" ,
I still get the same message.

In fact the original sample source code can run on Sikuli r905 version. (Latest official version)
Do you have other suggestions?
Thanks so much.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

I just tested with may Win7 32Bit with r930 in its standard place (C:\Program Files\Sikuli X\).

I had no problems with the code snippet. It works a s expected.

Are you some how mixing up older and newer Sikuli stuff? Experimenting with Win 8?

The respective line in Jython subprocess:
args = _shell_command + args

this means that _shell_command is not assigned the expected value in your environment.
This happens, if the underlying system cannot be identified as a Windows system.

So something seems to be special in your situation.

Revision history for this message
Milton_Wu (milton-wu) said :
#4

You almost guess what I've done.
I try to run both r905 and r930 on Windows 8.
But only r905 Sikuli in its standard path.
(In fact, Sikuli's functions in r930 are almost workable even the files are placed in any path of my computer. :P)

Therefore, when I see your comment "tested with my Win7 32Bit with r930 in its standard place (C:\Program Files\Sikuli X\).", I try to move my r930 to its standard path.
Then the result is correct. !!!
Thank you very much. :)

Therefore, is it the keypoint that if we want to use portable version of Sikuli, we still need to place the file in the corresponding path?

By the way, the reason why I use r930 is that r905 can't run on newer version of Windows 8. (After Developer Preview) ><
Do you have any plan to support Sikuli on Windows 8, especially for those run ARM CPU?

Thanks again.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#5

--- if we want to use portable version of Sikuli
Sikuli still needs the "path-to-Sikuli-directory\libs" and "path-to-Java\jre6\bin" in the system path when running.
With the portable version, the easiest way is, to adapt the Sikuli-IDE.bat or Sikuli-IDE-w.bat to your situation

--- Windows 8
Since I am on Mac, I took the chance yesterday to use the newest Parallels 7 option: auto install of Win 8 consumer Preview. It works perfectly. I managed to install Java 6 with no problem and Sikuli works too on Win 8 (32-Bit version) as expected.

--- Windows 8, especially for those run ARM CPU
This is not really a question for Sikuli as such, it is more the question, wether it is possible to build the native prereqs (OpenCV, Tesseract, ...) in this environment. As long as Java 6 is available (including the AWT transparent window support), Sikuli should work, if the native modules are available.

Revision history for this message
Milton_Wu (milton-wu) said :
#6

Thanks RaiMan, that solved my question.