Skip to content

Commit

Permalink
bug fix: some logging to backup retention
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jan 3, 2024
1 parent 903ab81 commit 2e959ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
19 changes: 16 additions & 3 deletions plogical/IncScheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def startBackup(type):
if job.frequency == type:



### now run backups
for web in job.jobsites_set.all():

Expand Down Expand Up @@ -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'):
Expand Down
1 change: 0 additions & 1 deletion plogical/getSystemInformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def GetRemainingDiskUsageInMBs():

return used_disk, free_disk, percent_used


@staticmethod
def populateOLSReport():
SystemInformation.olsReport = open("/tmp/lshttpd/.rtreport", "r").readlines()
Expand Down
19 changes: 0 additions & 19 deletions plogical/test.py
Original file line number Diff line number Diff line change
@@ -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"], "%")

0 comments on commit 2e959ec

Please sign in to comment.