sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #48432
Re: [Question #673348]: using xlrd: Error attempting to delete file after wb.release_resources()
Question #673348 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/673348
Ron Turrentine posted a new comment:
I finally found the culprit to the issue by using subprocess.Popen. It
returned a much more useful error than os.remove did.
The error it is returning is: "The process cannot access the file
becaus4e it is being used by another process."
This makes me believe that the XLRD "release_resources" method for the
workbook is not really truly releasing the workbook from memory to allow
me to delete it.
Any other suggestions on how I can clear the workbook from memory in
order to successfully delete it?
Ron
PS: Here's my working function using Popen that finally helped me see
the issue:
def DelFile(self):
from subprocess import Popen, PIPE, STDOUT
try:
command = "cmd.exe /c del /f \"" + self.NewFile + "\""
output = Popen(command, stderr=PIPE)
ret = output.communicate()
if ret:
raise StandardError(str(ret[1]))
except:
exc_type, exc_val, exc_tb = sys.exc_info()
ErrorText = "***** ERROR IN SCRIPTNAME = " + sys.argv[0] + " *****\n"
ErrorText += "Date/Time : " + str(datetime.datetime.now()) + "\n"
ErrorText += "Host name : " + socket.getfqdn() + "\n"
ErrorText += "User name : " + getpass.getuser() + "\n"
ErrorText += "Line Number: " + str(exc_tb.tb_lineno) + "\n"
ErrorText += "Error Type : " + exc_type.__name__ + "\n"
ErrorText += "Error Value: " + str(exc_val.message) + "\n"
ErrorText += "***************************************************************\n\r"
print ErrorText
self.LogError()
###############################
And here is the output:
***** ERROR IN SCRIPTNAME = //corpDpt02/CHMShare/Testing_Services/Automation Comparison/Sikuli Scripts/SurgCancDownloadOnly.sikuli *****
Date/Time : 2018-09-07 09:09:55.462000
Host name : CORPBYE8557A.hca.corpad.net
User name : BYE8557
Line Number: 66
Error Type : StandardError
Error Value: The process cannot access the file because it is being used by another process.
***************************************************************
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.