updated directory name, changed configs and systemctl slightly, preparing to make it useable for backups

This commit is contained in:
christian
2021-10-28 22:45:30 +02:00
parent 77a225e360
commit d889ee06ea
12 changed files with 321 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
from pathlib import Path
import contextlib
import os
from datetime import timedelta, datetime
class local_dir_remote:
def __init__(self, config):
self.config = config
self.path = config["path"]
def list_dir(self):
path = Path(self.path)
file_list = []
delta = timedelta(minutes=2)
for file_demo in list(path.glob('*')):
mtime = datetime.fromtimestamp(os.stat(file_demo).st_mtime)
if mtime < datetime.now() - delta:
file_list.append(file_demo)
return file_list
def delete_local_demo(self, pathfile):
with contextlib.suppress(FileNotFoundError):
if str(pathfile).endswith('.dem'):
os.remove(pathfile)
print('removed demo: ', pathfile)