updated directory name, changed configs and systemctl slightly, preparing to make it useable for backups
This commit is contained in:
Executable
+25
@@ -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)
|
||||
Reference in New Issue
Block a user