[1.1.1] shutil.move(pic,sfile) returns error (ScreenImage coercion to string)

Asked by Joe White

This script works in SikuliX 1.1.0. I get a screenshot named
"OSX10.11.5 2016-08-01 15.11.10 Empty checkbox not found left of Reduce Transparency"

In 1.1.1 I get this error which seems to not like the parms in shutil.move(pic,sfile) where the
script reads as below. Not sure what changed here???
############################## Script ###########################
def snapit(msg):
    bounds = getBounds()
    pic = Screen(0).capture(bounds)
    print("snapshot taken, + msg")
    msg = msg.rstrip("\n")
    sfile = path + "OSX10.11.5 " + time.strftime("%Y-%m-%d %H.%M.%S ") + msg + ".png"
    shutil.move(pic,sfile)
############################### LOG #############################
[log] ( ⌘+⌥ ) TYPE "h"

[log] App.open [2990:System Preferences]

2016-08-01 15\:15\:01, Dragged System Preferences Window to top

[log] CLICK on L(1738,448)@S(0)[0,0 1920x1080] (581 msec)
2016-08-01 15\:15\:02, Clicked on Accessibility

2016-08-01 15\:15\:06, Empty checkbox not found left of Reduce Transparency

snapshot taken, + msg
[error] script [ mac10-11-onboard ] stopped with error in line 536
[error] TypeError ( coercing to Unicode: need string, org.sikuli.script.ScreenImage type found )
[error] --- Traceback --- error source first
line: module ( function ) statement
293: shutil ( move ) File "/Users/joe/SikuliX-1.1.1/SikuliX.app/Contents/Java/sikulix.jar/Lib/shutil.py", line 293, in move
22: main ( snapit ) shutil.move(pic,sfile)
172: main ( clickitdir ) snapit(msg)
318: main ( reducetrans ) rc = clickitdir(reducet,desc,"left",echkbox,desc2,75)
[error] --- Traceback --- end --------------

Question information

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

not a bug

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

def snapit(msg):
    bounds = getBounds()
    pic = Screen(0).capture(bounds) # pic now is a ScreenImage object
    print("snapshot taken, + msg")
    msg = msg.rstrip("\n")
    sfile = path + "OSX10.11.5 " + time.strftime("%Y-%m-%d %H.%M.%S ") + msg + ".png"
    shutil.move(pic,sfile)

--- possible solution:
def snapit(msg):
    pic = capture(getBounds())
    print("snapshot taken," + msg)
    msg = msg.strip()
    sfile ="%s_%s_%s" % ("OSX10.11.5", time.strftime("%Y-%m-%d %H.%M.%S"), msg) # spaces in filenames not recommended
    pic.getFile(path, sfile) # stores the image as path+sfile.png

Can you help with this problem?

Provide an answer of your own, or ask Joe White for more information if necessary.

To post a message you must log in.