sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #19393
Re: [Question #232844]: Can Sikuli search the sub-folders to find screenshots?
Question #232844 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/232844
Status: Open => Answered
RaiMan proposed the following answer:
Since getBundlPath returns a string, str() is not needed:
your def() a little bit pythonized ;-)
def set_screenshot_path(my_screenshot_path):
print "The current screenshot path is " + getBundlePath()
if not os.path.isdir(my_screenshot_path):
raise Exception("%s does not exist."%my_screenshot_path)
if not my_screenshot_path == getBundlePath(): # in does not filter subfolders
print "[SETTING] Changing the screenshot path from %s to %s"%(getBundlePath(), my_screenshot_path)
setBundlePath(my_screenshot_path)
BTW: raise in functions only makes sense, if you really want to stop the
complete execution here. Otherwise the functions should return
true/false or value/none (like Sikuli's exists() )
def set_screenshot_path(my_screenshot_path):
print "[INFO] The current screenshot path is " + getBundlePath()
if not os.path.isdir(my_screenshot_path):
print "[ERROR] %s does not exist."%my_screenshot_path
return None
if not my_screenshot_path == getBundlePath(): # in does not filter subfolders
print "[SETTING] Changing the screenshot path from %s to %s"%(getBundlePath(), my_screenshot_path)
setBundlePath(my_screenshot_path)
return getBundlePath()
if not set_screenshot_path(new_screenshot_path):
print "[FATAL] terminating"
exit(1)
# or any corrective action
*** your problem does ...
is not your def, but at the point, where the new_screenshot_path is set.
set_screenshot_path("c:\\test")
or
set_screenshot_path(r"c:\test")
the interpretation of escape characters only takes place when Python has
to "read" a literal "some text"
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.