def cleanupdir(temporarydir):
osgen = os.walk(temporarydir)
try:
while True:
i = osgen.next()
## make sure all directories can be accessed
for d in i[1]:
if not os.path.islink(os.path.join(i[0], d)):
os.chmod(os.path.join(i[0], d), stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR)
for p in i[2]:
try:
if not os.path.islink(os.path.join(i[0], p)):
os.chmod(os.path.join(i[0], p), stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR)
except Exception, e:
#print e
pass
except StopIteration:
pass
try:
shutil.rmtree(temporarydir)
except:
## nothing that can be done right now, so just give up
pass
评论列表
文章目录