예제 #1
0
    def _log_object(self, instance):

        table_str = self._make_table(instance)
        if len(table_str.splitlines()) > get_terminal_lines():
            pydoc.pager(table_str)
        else:
            self.logger.log(table_str)
예제 #2
0
    def _log_table_of_logs(self, job_id, line, limit):
        logs = self.client.logs(job_id, line, limit)
        if not logs:
            self.logger.log("No logs found")
            return

        table_str = self._make_table(logs, job_id)
        if len(table_str.splitlines()) > get_terminal_lines():
            pydoc.pager(table_str)
        else:
            self.logger.log(table_str)
예제 #3
0
    def _log_objects_list(self, objects):
        if not objects:
            self.logger.warning("No data found")
            return

        table_data = self._get_table_data(objects)
        table_str = self._make_table(table_data)
        if len(table_str.splitlines()) > get_terminal_lines():
            pydoc.pager(table_str)
        else:
            self.logger.log(table_str)
예제 #4
0
 def _log_logs_list(self, data, table, table_data, follow):
     if not data:
         self.logger.log("No Logs found")
         return
     if follow:
         if data[-1].get("message") == "PSEOF":
             self.is_logs_complete = True
         else:
             self.last_line_number = data[-1].get("line")
         for log in data:
             log_str = "{}\t{}\t{}"
             self.logger.log(
                 log_str.format(
                     style(fg="blue", text=str(log.get("jobId"))),
                     style(fg="red", text=str(log.get("line"))),
                     log.get("message")))
     else:
         table_str = self._make_table(data, table, table_data)
         if len(table_str.splitlines()) > get_terminal_lines():
             pydoc.pager(table_str)
         else:
             self.logger.log(table_str)