46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import os
|
|
import time
|
|
import shutil
|
|
import logging
|
|
import requests
|
|
|
|
|
|
# File Paths
|
|
local_path = 'C:\\BlueIris\\New\\'
|
|
# remote_path = 'Y:\\'
|
|
remote_path = '\\\\MEDIASERVER\\BlueIris\\'
|
|
|
|
# Logging Setup
|
|
logging.basicConfig(filename='mover.log', format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p',
|
|
level=logging.INFO)
|
|
|
|
# Check if the mapped drive is connected
|
|
remoteOn = os.path.exists(remote_path)
|
|
|
|
if remoteOn is True:
|
|
for file in os.listdir(local_path):
|
|
t = os.path.getmtime(local_path + file)
|
|
age = (time.time() - t) / 86400
|
|
if age >= 1:
|
|
if file.startswith('Kitty'):
|
|
shutil.move(local_path + file, remote_path + 'Kitty\\' + file)
|
|
# print('Kitty File ' + local_path + file + remote_path + 'Kitty\\' + file)
|
|
logging.info('-- Moved Kitty file %s', file)
|
|
else:
|
|
shutil.move(local_path + file, remote_path + file)
|
|
# print('Normal File ' + local_path + file + remote_path + file)
|
|
logging.info('-- Moved %s', file)
|
|
for file in os.listdir(remote_path):
|
|
t = os.path.getmtime(remote_path + file)
|
|
age = (time.time() -t) / 86400
|
|
if age >= 7 and file != 'Clipboard':
|
|
os.remove(remote_path + file)
|
|
logging.info('-- Deleted %s', file)
|
|
else:
|
|
print('Not connected')
|
|
logging.info(' -- Error - Server Not connected')
|
|
|
|
requests.post("https://ntfy.dandembinski.com/security",
|
|
data="Remote storage server is unavailable",
|
|
headers={ "Priority": "5"} )
|
|
|