Upload files to "/"
This commit is contained in:
commit
0808fbbad9
51
30daykill.py
Normal file
51
30daykill.py
Normal file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import pathlib
|
||||
from datetime import datetime
|
||||
import glob
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
days = sys.argv[1]
|
||||
WatchedLocation = str(sys.argv[2])
|
||||
|
||||
|
||||
if days.isnumeric():
|
||||
print("true")
|
||||
else:
|
||||
print("shite")
|
||||
exit(0)
|
||||
|
||||
ToLive = int(days) * int(86400)
|
||||
|
||||
print(ToLive)
|
||||
def checkAgeOfFile(filename):
|
||||
fname = pathlib.Path(filename)
|
||||
# print(fname)
|
||||
print(int(time.time()) - fname.stat()[-1:][0])
|
||||
if (int(time.time()) - fname.stat()[-1:][0]) > ToLive:
|
||||
return True
|
||||
print("true")
|
||||
else:
|
||||
return False
|
||||
print("false")
|
||||
|
||||
|
||||
def deleteFilesNFolders(location):
|
||||
if os.path.isdir(location):
|
||||
print("This is a dir: " + location)
|
||||
shutil.rmtree(location)
|
||||
if os.path.isfile(location):
|
||||
print("This is a file: " + location)
|
||||
os.remove(location)
|
||||
|
||||
|
||||
for x in glob.glob(WatchedLocation):
|
||||
# print(x)
|
||||
# print("poopy")
|
||||
if checkAgeOfFile(x):
|
||||
print("poop")
|
||||
print(x)
|
||||
deleteFilesNFolders(x)
|
||||
Loading…
Reference in New Issue
Block a user