Alex Lourie has uploaded a new change for review.

Change subject: packaging: setup: update DB backup with human-readable sizes
......................................................................

packaging: setup: update DB backup with human-readable sizes

Change-Id: I7a264cff4aa12b3456e390e6507fb6fc88706aba
Bug-Url: https://bugzilla.redhat.com/1019741
Signed-off-by: Alex Lourie <alou...@redhat.com>
---
M packaging/common_utils.py
1 file changed, 19 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-dwh refs/changes/61/20261/1

diff --git a/packaging/common_utils.py b/packaging/common_utils.py
index 4740b62..0551d5f 100755
--- a/packaging/common_utils.py
+++ b/packaging/common_utils.py
@@ -62,8 +62,8 @@
 # DB related messages
 DB_BACKUP_HEADER = (
     '\nExisting DB was found on the system. The size of the detected DB '
-    'is {dbsize} Mb, free space in the backup folder {backup} '
-    'is {foldersize} Mb. \n'
+    'is {dbsize}, free space in the backup folder {backup} '
+    'is {foldersize}. \n'
 )
 
 DB_BACKUP_SHOW_STOP = (
@@ -74,7 +74,7 @@
 DB_BACKUP_SHOW_CONTINUE = (
     '\nThe upgrade utility can backup the existing database. The time and '
     'space required for the database backup depend on its size. The detected '
-    'DB size is {dbsize} Mb. This process can take a considerable time, and in 
'
+    'DB size is {dbsize}. This process can take a considerable time, and in '
     'some cases may take few hours to complete. Would you like to continue '
     'and backup the existing database?\n'
     'Answering "no" will skip the backup step and continue the upgrade '
@@ -880,8 +880,18 @@
         envDict={'ENGINE_PGPASS': PGPASS_FILE}
     )
     size = int(out[0]['pg_database_size'])
-    size = size / pow(20,2) # Get size in MB
+    size = size / pow(20, 2)  # Get size in MB
     return size
+
+
+def getSizeHuman(size):
+
+    if size < 1000:
+        return '{size} MB'.format(size=size)
+    else:
+        return '{size} GB'.format(
+            size=size/pow(20, 2)
+        )
 
 
 def performBackup(db_dict, backupPath, PGPASS_FILE):
@@ -891,15 +901,18 @@
     doBackup = None
     proceed = None
 
+    dbSizeHuman = getSizeHuman(dbSize)
+    backupPathFreeHuman = getSizeHuman(backupPathFree)
+
     if (dbSize * 1.1) < backupPathFree:
         # allow upgrade, ask for backup
         msg = '{header}{cont}'.format(
             header=DB_BACKUP_HEADER,
             cont=DB_BACKUP_SHOW_CONTINUE,
         ).format(
-            dbsize=dbSize,
+            dbsize=dbSizeHuman,
             backup=backupPath,
-            foldersize=backupPathFree,
+            foldersize=backupPathFreeHuman,
         )
         if askYesNo(msg):
             proceed = DB_BACKUP_CONTINUE_WITH


-- 
To view, visit http://gerrit.ovirt.org/20261
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a264cff4aa12b3456e390e6507fb6fc88706aba
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-dwh
Gerrit-Branch: master
Gerrit-Owner: Alex Lourie <alou...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to