@@ -168,6 +168,12 @@ def tabulate_cpu_recs(recs):
168168 ]
169169 return tabulate_recs (recs , header )
170170
171+ def print_unit (title , content ):
172+ print "%s" % title
173+ print ""
174+ print content
175+ print ""
176+
171177def main ():
172178 """Entry Point"""
173179
@@ -185,10 +191,9 @@ def main():
185191 if args .logs :
186192 host = HostFromLogs (args .logs )
187193 else :
188- if args .machine :
189- if not args .username or not args .password :
190- print "Error: you must specify a username and password to query a remote machine."
191- sys .exit (1 )
194+ if args .machine and not args .username or not args .password :
195+ print "Error: you must specify a username and password to query a remote machine."
196+ sys .exit (1 )
192197
193198 host = Host (args .machine , args .username , args .password )
194199
@@ -202,35 +207,20 @@ def main():
202207 options = filter_choices
203208
204209 if 'bios' in options :
205- print "Bios Info:"
206- print ""
207- print rec_to_table (host .get_info ())
208- print ""
210+ print_unit ("Bios Info:" , rec_to_table (host .get_info ()))
209211
210212 if 'cpu' in options :
211- print "CPU Info:"
212- print ""
213- print tabulate_cpu_recs (host .get_cpu_info ())
214- print ""
213+ print_unit ("CPU Info:" , tabulate_cpu_recs (host .get_cpu_info ()))
215214
216215 if 'nic' in options :
217216 devices = pci_filter_for_nics (host .get_pci_devices ())
218- print "Ethernet Controller Info:"
219- print ""
220- print tabulate_pci_recs ([dev .get_rec () for dev in devices ])
221- print ""
217+ print_unit ("Ethernet Controller Info:" , tabulate_pci_recs ([dev .get_rec () for dev in devices ]))
222218
223219 if 'storage' in options :
224220 devices = pci_filter_for_storage (host .get_pci_devices ())
225- print "Storage Controller Info:"
226- print ""
227- print tabulate_pci_recs ([dev .get_rec () for dev in devices ])
228- print ""
221+ print_unit ("Storage Controller Info:" , tabulate_pci_recs ([dev .get_rec () for dev in devices ]))
229222
230223 if 'gpu' in options :
231224 devices = pci_filter_for_gpu (host .get_pci_devices ())
232225 if devices :
233- print "GPU Info:"
234- print ""
235- print tabulate_pci_recs ([dev .get_rec () for dev in devices ])
236- print ""
226+ print_unit ("GPU Info:" , tabulate_pci_recs ([dev .get_rec () for dev in devices ]))
0 commit comments