ajout initial. script pour virer les vieux pdf/codes. lanc par cron (utilisateur : respbat)
darcs-hash:20061025154637-f46e9-a741063049c83301872af3e84942ba2cab6ab183.gz
This commit is contained in:
parent
550d216a58
commit
54f95fb3ec
1 changed files with 27 additions and 0 deletions
27
intranet/intranet-garbage-collector.py
Executable file
27
intranet/intranet-garbage-collector.py
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python
|
||||
import crans.utils.files, os, time, crans.impression.digicode
|
||||
tools = crans.utils.files
|
||||
PDF_FOLDER = "/var/impression/fichiers/"
|
||||
|
||||
def cleanFolder(pathToFolder):
|
||||
print "cleaning %s" % pathToFolder
|
||||
if not os.path.isdir(pathToFolder):
|
||||
raise Exception, "%s n'est pas un dossier" % pathOfFolder
|
||||
fileList = os.listdir(pathToFolder)
|
||||
for aFile in fileList:
|
||||
aFilePath = os.path.join(pathToFolder, aFile)
|
||||
if os.path.isdir(aFilePath):
|
||||
cleanFolder(aFilePath)
|
||||
if tools.dirIsEmpty(aFilePath):
|
||||
os.rmdir(aFilePath)
|
||||
if os.path.isfile(aFilePath):
|
||||
if tools.fileIsOlderThan(aFilePath, days=1):
|
||||
os.remove(aFilePath)
|
||||
|
||||
now = time.localtime()
|
||||
displaytime = time.strftime("%A %d %B %Y, %X",now)
|
||||
print "................ %s ................" % displaytime
|
||||
cleanFolder(PDF_FOLDER)
|
||||
print "*** Cleaning codes"
|
||||
crans.impression.digicode.menage()
|
||||
print
|
Loading…
Add table
Add a link
Reference in a new issue