Updated to use Machine Name instead of mapped folder. For some reason Task Scheduler stopped working with the mapped folder. I think there's also some older updates where I changed how old files are before being moved.
This commit is contained in:
@@ -1,39 +0,0 @@
|
|||||||
import os
|
|
||||||
import time
|
|
||||||
import shutil
|
|
||||||
import logging
|
|
||||||
from twilio.rest import Client
|
|
||||||
|
|
||||||
# Twilio Account setup
|
|
||||||
account_sid = 'AC051785f6dd5a93184641d01103eb8cd4'
|
|
||||||
auth_token = 'd40c831e56785afaa9294fd3c5a88e6e'
|
|
||||||
client = Client(account_sid, auth_token)
|
|
||||||
|
|
||||||
# File Paths
|
|
||||||
local_path = 'C:\\BlueIris\\New\\'
|
|
||||||
remote_path = 'Y:\\'
|
|
||||||
|
|
||||||
# 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(remote_path):
|
|
||||||
t = os.path.getmtime(remote_path + file)
|
|
||||||
age = (time.time() -t) / 86400
|
|
||||||
if age >= 30 and file != 'Clipboard':
|
|
||||||
print(file)
|
|
||||||
#os.remove(remote_path + file)
|
|
||||||
#logging.info('-- Deleted %s', file)
|
|
||||||
else:
|
|
||||||
print('Not connected')
|
|
||||||
logging.info(' -- Error - Server Not connected')
|
|
||||||
|
|
||||||
message = client.messages.create(
|
|
||||||
messaging_service_sid='MG864145600a43493122488250262ccbc9',
|
|
||||||
body='Remote storage server is unavailable',
|
|
||||||
to='+14409351551'
|
|
||||||
)
|
|
||||||
5
main.py
5
main.py
@@ -11,7 +11,8 @@ client = Client(account_sid, auth_token)
|
|||||||
|
|
||||||
# File Paths
|
# File Paths
|
||||||
local_path = 'C:\\BlueIris\\New\\'
|
local_path = 'C:\\BlueIris\\New\\'
|
||||||
remote_path = 'Y:\\'
|
# remote_path = 'Y:\\'
|
||||||
|
remote_path = '\\\\MEDIASERVER\\BlueIris\\'
|
||||||
|
|
||||||
# Logging Setup
|
# Logging Setup
|
||||||
logging.basicConfig(filename='mover.log', format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p',
|
logging.basicConfig(filename='mover.log', format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p',
|
||||||
@@ -24,7 +25,7 @@ if remoteOn is True:
|
|||||||
for file in os.listdir(local_path):
|
for file in os.listdir(local_path):
|
||||||
t = os.path.getmtime(local_path + file)
|
t = os.path.getmtime(local_path + file)
|
||||||
age = (time.time() - t) / 86400
|
age = (time.time() - t) / 86400
|
||||||
if age >= 3:
|
if age >= 1:
|
||||||
shutil.move(local_path + file, remote_path + file)
|
shutil.move(local_path + file, remote_path + file)
|
||||||
logging.info('-- Moved %s', file)
|
logging.info('-- Moved %s', file)
|
||||||
for file in os.listdir(remote_path):
|
for file in os.listdir(remote_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user