Esempio n. 1
0
 def _exec_status(self, q330):
     if self.status[0] == 'all':
         self.status = sorted(Quasar.Status.StatusBits[q330.getDeviceType()].keys())
     all_results = self._batch_ping(q330, self.status)
     for status_type in sorted(self.status):
         if not all_results.has_key(status_type):
             continue
         result_dict = all_results[status_type]
         # Store the raw results
         self._raw_results[status_type] = result_dict
         # Fomat the results
         results = QStatus.formatted({status_type:result_dict})
         key = status_type
         main_title = "%s Status" % key
         self._print("%s:" % main_title)
         self._print("".rjust(len(main_title), "="))
         sub_dict = results[key]
         values = []
         for sub_key in sub_dict.keys():
             values.append(sub_dict[sub_key])
         values.sort()
         max_title_len = max(map(len, map(lambda x: x[1], values)))
         for (idx, title, value) in values:
             self._print("  %s: %s" % (title.rjust(max_title_len), value))
         self._print()
         self._add_result(results[key])
Esempio n. 2
0
 def _exec_info(self, q330):
     ping_result = self._ping_info(q330)
     if ping_result is not None:
         sub_dict = QStatus.formatPingInfo(ping_result)
         values = []
         for sub_key in sub_dict.keys():
             values.append(sub_dict[sub_key])
         values.sort()
         main_title = "Ping Info"
         self._print("%s:" % main_title)
         self._print("".rjust(len(main_title), "="))
         max_title_len = max(map(len, map(lambda x: x[1], values)))
         for (idx, title, value) in values:
             self._print("  %s: %s" % (title.rjust(max_title_len), value))
         self._add_result(sub_dict)
     else:
         raise QTools.QExMessage("Ping failed")