"IOError: [Errno 13] Permission denied " - I see this error when trying to capture image using shutill

Asked by Test App

Hi,

I am using the below code to append time stamp to my file name

import shutil
stime = time.strftime("%x,%X")
print stime
img = Screen(0).capture(11,30,1888,995).getFile()
shutil.move(img, 'C:\Sikuli\ManApp scripts\Imagelogs\MI' + stime + '.png')

When i execute the above code i get the following error :

[error] IOError ( [Errno 13] Permission denied: 'C:\\Sikuli\\ManApp scripts\\Imagelogs\\MI09/21/17,10:48:28.png' )
[error] --- Traceback --- error source first line: module ( function ) statement 71: shutil ( copyfile ) IOError: [Errno 13] Permission denied: 'C:\\Sikuli\\ManApp scripts\\Imagelogs\\MI09/21/17,10:48:28.png'
301: shutil ( move ) File "C:\Sikuli\sikulix.jar\Lib\shutil.py", line 130, in copy2
[error] --- Traceback --- end --------------

I have tried using this which works , but need a better format for date and time so used the above method:

shutil.move(img, '/Users/Log/img_' + str(time.time()) + '.png')

Please help.
Thanks in advance

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Test App
Solved:
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

There are two possible reasons for the error:

Either you are missing write access to the C:\Sikuli\ManApp scripts\Imagelogs\ directory
or
the error is caused by illegal characters in the file name.

For testing purposes replace the second line of your script by

stime = time.strftime("%Y-%m-%d-%H-%M-%S")

What do you get?

Revision history for this message
Test App (laxmisaketha) said :
#2

Thank you Manfred

Your solution worked perfect

I can save the image with date and time stamp , No error seen