[GRASS-dev] os.remove

Helmut Kudrnovsky hellik at web.de
Mon Mar 21 04:00:49 PDT 2016

pvanbosgeo wrote
> On 21-03-16 10:12, Paulo van Breugel wrote:
>> Hi devs,
>> In the addon r.forestfrag (python script), I used os.remove() to 
>> remove some temporary files (in lines 230, 258 and 430). However, this 
>> fails in Windows, with an error message like below:
>> WindowsError: [Error 32] The process cannot access the file because it 
>> is being used by another process: 
>> 'c:\\users\\uqdshana\\appdata\\local\\temp\\tmpwlv54l'
>> Removing these lines with os.remove() solves the problem, but than the 
>> user is left with these temporary files. Is there a Window compatible 
>> way to remove them in the script?
> Perhaps I should have looked harder first, the underlying problem 
> (described here: https://www.logilab.org/blogentry/17873) seems to be 
> that the file needs to be closed at OS level, which can be done using 
> os.close().

in one of my addons [1] I'm also using os.remove() of an tempfile. the addon
works also on windows.

yes, closing the file should do it e.g. [2]


best regards
View this message in context: http://osgeo-org.1560.x6.nabble.com/os-remove-tp5257585p5257609.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

More information about the grass-dev mailing list