From cfa71c5b23706c9ecf23c4567246db23e6babf0b Mon Sep 17 00:00:00 2001 From: tamservo Date: Sun, 30 Jul 2023 21:00:07 -0400 Subject: [PATCH] Removed print statements, and changed flap order. --- robottas.py | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/robottas.py b/robottas.py index b5c4361..b6103d4 100755 --- a/robottas.py +++ b/robottas.py @@ -43,7 +43,6 @@ class Robottas(commands.Bot): async def send_message(self, message): - print(f"in send_message {message} {self.channel}") if self.channel is None: return @@ -51,17 +50,13 @@ class Robottas(commands.Bot): def send_delay_message(self, message): - print("in send_delay_message") self.message_queue.append((time.time(), message)) - print(f"adding message: {message} at {time.time()}") async def process_delay_messages(self): - print("in process_delay_queue") while len(self.message_queue) > 0 and \ self.message_queue[0][0] < time.time() - self.delay: - print(f"removing at {time.time()}") message = self.message_queue.pop(0)[1] await self.send_message(message) await asyncio.sleep(1) @@ -157,7 +152,6 @@ class Robottas(commands.Bot): async def load_lap_data(self, data): - print(f"load_lap_data: {str(data)}") if "CurrentLap" in data.keys(): current_lap = data["CurrentLap"] @@ -175,7 +169,6 @@ class Robottas(commands.Bot): def load_podium_data(self, data): - print("in load_podium_data") if "Lines" in data.keys(): for position in data["Lines"].keys(): if 'RacingNumber' in data["Lines"][position].keys(): @@ -208,7 +201,7 @@ class Robottas(commands.Bot): return message except: - print("Error in sending podium message.") + pass return "I don't know the podium yet :(" @@ -254,7 +247,6 @@ class Robottas(commands.Bot): report = None while (len(session_data) > 0 or len(status_data) > 0) and self.is_reporting: # If only one of them has data, use that one - print("starting loop") if len(session_data) == 0: event = status_data.pop(0) event_type = "STATUS" @@ -278,7 +270,6 @@ class Robottas(commands.Bot): report = None if event_type == "SESSION": - print("Session event") # Get the lap from the event cur_lap = event["Lap"] @@ -295,7 +286,6 @@ class Robottas(commands.Bot): # Must be a status event else: - print("Status event") key = None if "TrackStatus" in event.keys(): key = "TrackStatus" @@ -333,24 +323,19 @@ class Robottas(commands.Bot): def load_timing_stats_data(self, data): - print("in timing stats") if "Lines" in data.keys(): lines = data["Lines"] for driver_num in lines.keys(): line = lines[driver_num] - print(f"driver_num {driver_num}") if "PersonalBestLapTime" in line.keys(): position = -1 try: position = line["PersonalBestLapTime"]["Position"] - print(f"got position {position}") except: pass if position == 1: - print(f"setting fastest_lap {driver_num}") self.fastest_lap = self.driver_dict[driver_num] - print(f"flap {driver_num} {self.fastest_lap}") return @@ -383,7 +368,6 @@ class Robottas(commands.Bot): def load_initial(self, message): - print( f"in load_initial: {message['R'].keys()}" ) # Load podium data if 'R' in message.keys(): if 'TopThree' in message['R'].keys(): @@ -406,12 +390,10 @@ class Robottas(commands.Bot): if 'LapCount' in message['R'].keys(): if 'TotalLaps' in message['R']['LapCount'].keys(): self.total_laps = int(message['R']['LapCount']['TotalLaps']) - print(f"self.total_laps: {self.total_laps}") # Load weather data if 'WeatherData' in message['R'].keys(): - print( 'WeatherData in keys' ) weather_obj = message['R']['WeatherData'] weather_text = "Track Weather Report\n" for k in weather_obj.keys(): @@ -422,7 +404,6 @@ class Robottas(commands.Bot): # Load fastest lap data if 'TimingStats' in message['R'].keys(): - print( 'Flap in keys' ) flap_obj = message['R']['TimingStats'] self.load_timing_stats_data(flap_obj) @@ -430,8 +411,6 @@ class Robottas(commands.Bot): async def process_message(self, message): try: if isinstance(message, collections.abc.Sequence): - print("process_message - in isinstance") - if message[0] == 'Heartbeat': return @@ -454,7 +433,7 @@ class Robottas(commands.Bot): self.load_timing_stats_data(message[1]) else: - print(f"Not sure how to handle message:{message[0]}") + pass # Check to see if this is the initial "R" record from the response elif "R" in message.keys(): @@ -462,7 +441,7 @@ class Robottas(commands.Bot): self.load_initial(message) except Exception as e: - print(f"process_message error {e}\n\n") + pass def get_messages_from_db(self): @@ -484,7 +463,6 @@ class Robottas(commands.Bot): return messages except: - print("db error... continuing") return [] @@ -514,7 +492,6 @@ class Robottas(commands.Bot): while self.is_reporting: # Do processing - print("reporting loop") # process any new messages in the db messages = self.get_messages_from_db() @@ -524,7 +501,7 @@ class Robottas(commands.Bot): await asyncio.sleep(3) except: - print(f"problem with messages") + pass # process any messages in the delay queue await self.process_delay_messages() @@ -547,7 +524,6 @@ class Robottas(commands.Bot): dir_path = os.path.dirname(os.path.realpath(__file__)) command_txt = os.path.join(dir_path, self.collector_command) command_txt += self.collector_params - print(f"command_txt: {command_txt}") self.collector_proc = Popen(command_txt.split()) @@ -557,7 +533,7 @@ class Robottas(commands.Bot): if self.collector_proc != None: self.collector_proc.kill() except: - print("Tried to kill collection process") + pass async def decode_watched(self, w): @@ -823,7 +799,7 @@ class Robottas(commands.Bot): @self.command() async def flap(ctx): if self.fastest_lap != '': - await ctx.send( self.fastest_lap + self.flag_dict['FLAP'] ) + await ctx.send( self.flag_dict['FLAP'] + self.fastest_lap ) else: await ctx.send( "No " + self.flag_dict['FLAP'] + " yet." )