diff --git a/plogical/IncScheduler.py b/plogical/IncScheduler.py index d8bb7d2db..99621f68f 100644 --- a/plogical/IncScheduler.py +++ b/plogical/IncScheduler.py @@ -71,7 +71,6 @@ def startBackup(type): if job.frequency == type: - ### now run backups for web in job.jobsites_set.all(): @@ -431,14 +430,28 @@ def runGoogleDriveBackups(type): # print('Fetch all folders in main folder: %s (%s) time:-%s' % (file.get('name'), file.get('id'), file.get('createdTime'))) # logging.writeToFile('Fetch all folders in main folder: %s (%s) time:-%s' % (file.get('name'), file.get('id'),file.get('createdTime'))) ab = file.get('createdTime')[:10] - filename = file.get('name') + print(f'File from gdrive {file.get("name")}') + filename = file.get("name") fileDeleteID = file.get('id') timestamp = time.mktime(datetime.datetime.strptime(ab, "%Y-%m-%d").timetuple()) + + print(f'Folder creation time on gdrive {timestamp}') + logging.writeToFile(f'Folder creation time on gdrive {timestamp}') + CUrrenttimestamp = time.time() - timerrtention = gDriveData['FileRetentiontime'] + try: + timerrtention = gDriveData['FileRetentiontime'] + print(f'Retention time {timerrtention}') + logging.writeToFile(f'Retention time {timerrtention}') + except: + print(f'Retention time not defined.') + if (timerrtention == '1d'): new = CUrrenttimestamp - float(86400) + print(f'New time {new}') if (new >= timestamp): + print(f'New time {new}, Folder created time {timestamp}') + logging.writeToFile(f'New time {new}, Folder created time {timestamp}') resp = drive.files().delete(fileId=fileDeleteID).execute() logging.writeToFile('Delete file %s ' % filename) elif (timerrtention == '1w'): diff --git a/plogical/getSystemInformation.py b/plogical/getSystemInformation.py index 80ce83746..52df5d528 100755 --- a/plogical/getSystemInformation.py +++ b/plogical/getSystemInformation.py @@ -110,7 +110,6 @@ def GetRemainingDiskUsageInMBs(): return used_disk, free_disk, percent_used - @staticmethod def populateOLSReport(): SystemInformation.olsReport = open("/tmp/lshttpd/.rtreport", "r").readlines() diff --git a/plogical/test.py b/plogical/test.py index 15d9387ea..e69de29bb 100644 --- a/plogical/test.py +++ b/plogical/test.py @@ -1,19 +0,0 @@ -import psutil - -def get_disk_usage(): - total_disk = psutil.disk_usage('/').total / (1024 * 1024) # Total disk space in MB - used_disk = psutil.disk_usage('/').used / (1024 * 1024) # Used disk space in MB - free_disk = psutil.disk_usage('/').free / (1024 * 1024) # Free disk space in MB - percent_used = psutil.disk_usage('/').percent # Percentage of disk used - - return { - "current_disk_usage_mb": used_disk, - "current_disk_free_mb": free_disk, - "percentage_disk_used": percent_used - } - -# Usage example: -disk_info = get_disk_usage() -print("Current disk usage (MB):", disk_info["current_disk_usage_mb"]) -print("Current disk free (MB):", disk_info["current_disk_free_mb"]) -print("Percentage of disk used:", disk_info["percentage_disk_used"], "%")