By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,911 Members | 1,124 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,911 IT Pros & Developers. It's quick & easy.

Temp File Cleanup for McMillan Installer Pgms

P: n/a
After using the McMillan installer and executables built with
it for a while, I've noticed some residual files accumulating
on my disk. The installer docs mentions these.

Here's code I wrote to clean these up:

--------------------Program Fillows----------------------

import fnmatch
import os
import os.path
import stat
import tempfile
import time

currentTime = time.time()

def PathIsOld(pathName):
accessTime = os.stat(pathName)[stat.ST_ATIME]
createTime = os.stat(pathName)[stat.ST_CTIME]
modifiedTime = os.stat(pathName)[stat.ST_MTIME]
return (((currentTime - accessTime) > 5000) or (
(currentTime - createTime) > 50000)) and (
(currentTime - modifiedTime) > 5000)
def GetMEISubdirectories(aDir):
for fName in os.listdir(aDir):
if fnmatch.fnmatch(fName, "*"):
if fName.lower()[:4] == '_mei':
fullName = os.path.join(aDir, fName)
fMode = os.stat(fullName)[stat.ST_MODE]
if stat.S_ISDIR(fMode):
yield fullName

def GetMEIFiles(aDir):
for fName in os.listdir(aDir):
if fName.lower()[:4] == '_mei':
fullName = os.path.join(aDir, fName)
fMode = os.stat(fullName)[stat.ST_MODE]
if stat.S_ISREG(fMode):
yield fullName
def GetTempLocation():
return tempfile.gettempdir()

def GetMEIDirectories():
return filter(
PathIsOld,
GetMEISubdirectories(GetTempLocation())
)

def DeleteMEIDirectory(d):
for fileName in os.listdir(d):
fullName = os.path.join(d, fileName)
try:
os.remove(fullName)
except:
pass
try:
os.rmdir(d)
except:
pass

for d in GetMEIDirectories():
DeleteMEIDirectory(d)

for f in GetMEIFiles(GetTempLocation()):
if PathIsOld(f):
os.remove(f)

-----------------------End of Program -------------------------

What are the top 10 reasons for not including this in every
program that I turn into an executable with the McMillan
installer?

TIA

Al
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.