Browse code

Fix TDNF package size calculation, raise an exception for a missing package. (bug 1590034)

Change-Id: Ibdbfc651c51f7a616cd12e7ab3040b60fc8a8f30
Reviewed-on: http://photon-jenkins.eng.vmware.com/503
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: suezzelur <anishs@vmware.com>

xiaolin-vmware authored on 2016/02/05 02:57:31
Showing 2 changed files
... ...
@@ -77,14 +77,15 @@ class Installer(object):
77 77
             self.window.addstr(0, 0, 'Opps, Installer got interrupted.\n\nPress any key to get to the bash...')
78 78
             self.window.content_window().getch()
79 79
 
80
-        modules.commons.dump(modules.commons.LOG_ERROR, modules.commons.LOG_FILE_NAME)        
80
+        modules.commons.dump(modules.commons.LOG_FILE_NAME)        
81 81
         sys.exit(1)
82 82
 
83 83
     def install(self, params):
84 84
         try:
85 85
             return self.unsafe_install(params)
86
-        except:
86
+        except Exception as inst:
87 87
             if self.iso_installer:
88
+                modules.commons.log(modules.commons.LOG_ERROR, repr(inst))
88 89
                 self.exit_gracefully(None, None)
89 90
             else:
90 91
                 raise
... ...
@@ -375,7 +376,7 @@ class Installer(object):
375 375
                 item = name_size_pairs[index + 1] 
376 376
                 size = item[item.find("(") + 1:item.find(")")]
377 377
                 return int(size)
378
-
378
+        raise LookupError("Cannot find package {} in the repo.".format(package))
379 379
     def get_size_of_packages(self):
380 380
         #call tdnf info to get the install size of all the packages.
381 381
         process = subprocess.Popen(['tdnf', 'info', '--installroot', self.photon_root], stdout=subprocess.PIPE)
... ...
@@ -134,4 +134,10 @@ def dump(type, filename):
134 134
     command = "journalctl -p {0} | grep --line-buffered \"{1}\" > {2}".format(LOG_LEVEL_DESC[type], SIGNATURE, filename)
135 135
     process = subprocess.Popen([command], shell=True)
136 136
     retval = process.wait()
137
-    return retval
138 137
\ No newline at end of file
138
+    return retval
139
+
140
+def dump(filename):
141
+    command = "journalctl | grep --line-buffered \"{0}\" > {1}".format(SIGNATURE, filename)
142
+    process = subprocess.Popen([command], shell=True)
143
+    retval = process.wait()    
144
+    return retval