Tweaked, tested paths and turned testing off

This commit is contained in:
Dan
2023-06-02 11:19:57 -04:00
parent c308d9a639
commit 3069ce11c4

50
main.py
View File

@@ -16,36 +16,36 @@ 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',
level=logging.INFO) level=logging.INFO)
# Check if the mapped drive is connected # Check if the mapped drive is connected
remoteOn = os.path.exists(remote_path) remoteOn = os.path.exists(remote_path)
if remoteOn is True: 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 >= 1: if age >= 1:
if file.startswith('kitty'): if file.startswith('Kitty'):
# shutil.move(local_path + file, remote_path + 'Kitty/' + file) shutil.move(local_path + file, remote_path + 'Kitty\\' + file)
print('Kitty File ' + local_path + file, remote_path + 'Kitty/' + file) # print('Kitty File ' + local_path + file + remote_path + 'Kitty\\' + file)
# logging.info('-- Moved Kitty file %s', file) logging.info('-- Moved Kitty file %s', file)
else: else:
# shutil.move(local_path + file, remote_path + file) shutil.move(local_path + file, remote_path + file)
print('Normal File ' + local_path + file, remote_path + 'Kitty/' + file # print('Normal File ' + 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):
t = os.path.getmtime(remote_path + file) t = os.path.getmtime(remote_path + file)
age = (time.time() -t) / 86400 age = (time.time() -t) / 86400
if age >= 30 and file != 'Clipboard': if age >= 30 and file != 'Clipboard':
os.remove(remote_path + file) os.remove(remote_path + file)
logging.info('-- Deleted %s', file) logging.info('-- Deleted %s', file)
else: else:
print('Not connected') print('Not connected')
logging.info(' -- Error - Server Not connected') logging.info(' -- Error - Server Not connected')
message = client.messages.create( message = client.messages.create(
messaging_service_sid='MG864145600a43493122488250262ccbc9', messaging_service_sid='MG864145600a43493122488250262ccbc9',
body='Remote storage server is unavailable', body='Remote storage server is unavailable',
to='+14409351551' to='+14409351551'
) )