commit 56f1afd8815cb4ea800fa99cca8bac053685617d Author: dan Date: Fri Aug 6 14:54:29 2021 -0400 Inital Commit diff --git a/main.py b/main.py new file mode 100644 index 0000000..00208ad --- /dev/null +++ b/main.py @@ -0,0 +1,41 @@ +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:\\Users\\ICYN3\\Documents\\dev\\BiFileMover\\' +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) + +print(remoteOn) +if remoteOn is True: + for file in os.listdir(local_path): + t = os.path.getmtime(file) + age = (time.time() - t) / 86400 + if age >= 7: + shutil.move(local_path + file, remote_path + file) + logging.info('-- Moved %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' + ) \ No newline at end of file