def handle(self, *args, **options): # get the params from the command line self.refreshRate = options['rate'] self.filterByType = options['type'] self.excludeOffline = options['excludeoffline'] # set up interrupt handler for ctrl+C exit event signal.signal(signal.SIGINT, signal_handler) Utils.ClearConsole() # Constantly refresh while (True): # Create a new table for the results each time table = None table = PrettyTable(['CID', 'Type', 'TimeCreated', 'FromUser', 'NumReports', 'ModAction' , 'Online']) # Get the list of reports reports = self._GetReports() # For each report group, gather the data to be displayed # and add it to the table if there is any data returned for report in reports: data = self._GetTableDataForReport(report) if (data): table.add_row(data) # Print the results and pause for the refreshRate print (table) time.sleep(float(self.refreshRate)) Utils.ClearConsole() print('Updating results every ', self.refreshRate, ' seconds')
def handle(self, *args, **options): numberToDisplay = int(options['num']) # Get the most recent errors recentErrors = Error.objects.order_by('-timeCreated')[:numberToDisplay] Utils.ClearConsole() errors = DataCollector.ServerErrorsToString(recentErrors) # Print each one, in reversed list order # (Console printing stops at the last thing printed) for error in reversed(errors): print(error)