← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #268418]: MAC Shell command

 

Question #268418 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/268418

    Status: Open => Answered

RaiMan proposed the following answer:
with versions <1.1.0 you have to use os.popen() or the features of the
subprocess module.

with version 1.1.0, you can do this:

result = run("env")

getting result as a multi line string like this:
0
SHELL=/bin/bash
LC_CTYPE=UTF-8
DYLD_LIBRARY_PATH=/Applications/NetBeans/NetBeans 7.4.app/Contents/Resources/NetBeans/webcommon/bin:
TMPDIR=/var/folders/72/r0r_pc952b97blkfdk5yh0hr0000gn/T/
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home
SHLVL=1
…. more

the first line is the return code, the rest is the stuff going to stdout
and lines after a line *****error***** the stuff that goes to stderr.

to run a script file created from scratch,  just create a file wherever
you want with the shebang in the first line and then the lines you need
to be processed.

then issue 
result = run("<the-path-to-your-commandfile>  option1 option2")

--- crop an image
… also can be done with version 1.1.0 (not documented yet ;-)

img = Image.create("someFile.png")
imgCropped = img.getSub(x, y, w, h) # still in memory 
imgCroppedFile = imgCropped.asFile() # a file in temp

… and this is possible:
find(imgCropped) # just use the in memory image

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.