From b6c599f4a90e3852a11098f704eb227c9f436588 Mon Sep 17 00:00:00 2001
From: David Trattnig <david.trattnig@o94.at>
Date: Wed, 27 Nov 2019 15:43:52 +0100
Subject: [PATCH] Removed unused code and added comments.

---
 libraries/database/broadcasts.py                 |  3 ++-
 modules/communication/liquidsoap/communicator.py |  9 +++++----
 modules/communication/redis/adapter.py           |  7 +++++--
 modules/communication/redis/messenger.py         | 10 ++++++----
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/libraries/database/broadcasts.py b/libraries/database/broadcasts.py
index 7fcc5b3e..736f472d 100644
--- a/libraries/database/broadcasts.py
+++ b/libraries/database/broadcasts.py
@@ -251,6 +251,7 @@ class Playlist(DB.Model, AuraDatabaseModel):
 
     @staticmethod
     def select_playlist(playlist_id):
+        # TODO Returns multiple playlists - Hence, order playlists also by "latest version". Maybe cleanup others before?
         return DB.session.query(Playlist).filter(Playlist.playlist_id == playlist_id).order_by(Playlist.schedule_start).all()
     
     @hybrid_property
@@ -288,7 +289,7 @@ class PlaylistEntry(DB.Model, AuraDatabaseModel):
     @hybrid_property
     def volume(self):
         return 100
-        
+
     @hybrid_property
     def type(self):
         if self.uri.startswith("http"):
diff --git a/modules/communication/liquidsoap/communicator.py b/modules/communication/liquidsoap/communicator.py
index d5a37a9f..33869e4f 100644
--- a/modules/communication/liquidsoap/communicator.py
+++ b/modules/communication/liquidsoap/communicator.py
@@ -169,7 +169,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
             self.enable_transaction()
             self.__send_lqc_command__(self.client, "http", cmd)
             self.disable_transaction()
-        except LQConnectionError as e:
+        except LQConnectionError:
             # we already caught and handled this error in __send_lqc_command__, but we do not want to execute this function further
             pass
 
@@ -290,8 +290,9 @@ class LiquidSoapCommunicator(ExceptionLogger):
         # grab the actual active entry
         (show, old_entry) = self.scheduler.get_active_entry()
         # determine its type
-        # FIXME Move to <get_active_entry>
-        old_type = ScheduleEntryType.FILESYSTEM
+        # TODO Move to <get_active_entry>
+        # FIXME No need to switch if current type = new type
+        old_type = ScheduleEntryType.FILESYSTEM # Set default if no previous track is available
         if old_entry:
             old_type = old_entry.type
 
@@ -312,7 +313,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
             # insert playlist entry
             self.logger.critical("Trackservice entry not written here anymore")
 #            self.insert_track_service_entry(new_entry)
-        except LQConnectionError as e:
+        except LQConnectionError:
             # we already caught and handled this error in __send_lqc_command__, but we do not want to execute this function further and pass the exception
             pass
 
diff --git a/modules/communication/redis/adapter.py b/modules/communication/redis/adapter.py
index ad97f8d8..f095dced 100644
--- a/modules/communication/redis/adapter.py
+++ b/modules/communication/redis/adapter.py
@@ -49,7 +49,8 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
     redisclient = None
 #    connection_tester = None
     liquidsoapcommunicator = None
-
+    socket = None
+    
     # ------------------------------------------------------------------------------------------ #
     def __init__(self, config):
         threading.Thread.__init__(self)
@@ -67,7 +68,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
         self.components = {'controller':'01', 'scheduling':'02', 'playd':'03', 'recorder':'04', 'helpers':'09'}
         self.fromMail = ''
         self.adminMails = ''
-
+        self.can_send = None
         self.redisclient = ClientRedisAdapter(config)
 #        self.connection_tester = ConnectionTester()
 
@@ -237,6 +238,8 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
         Send a message to the client
         :param message: string
         """
+
+        # FIXME Review logic
         if not self.can_send:
             self.logger.info("sending a "+str(len(message))+" long message via REDIS.")
             self.socket.send(message.encode("utf-8"))
diff --git a/modules/communication/redis/messenger.py b/modules/communication/redis/messenger.py
index be3bf587..d489205d 100644
--- a/modules/communication/redis/messenger.py
+++ b/modules/communication/redis/messenger.py
@@ -264,9 +264,10 @@ class RedisMessenger():
         @param state: Der State
         @return result
         """
-
+        
+        # FIXME Make Mailer functional: Invalid constructor
         if self.fromMail and self.adminMails:
-            subject = "Possible comba problem on job " + state['job'] + " - " + level
+            #subject = "Possible comba problem on job " + state['job'] + " - " + level
             mailmessage = "Hi Admin,\n comba reports a possible problem\n\n"
             mailmessage = mailmessage + level + "!\n"
             mailmessage = mailmessage + message + "\n\n"
@@ -275,8 +276,9 @@ class RedisMessenger():
             mailmessage = mailmessage + "Job:\t" + state['job'] + "\n"
             mailmessage = mailmessage + "Code:\t" + state['code'] + "\n"
             mailmessage = mailmessage + "Value:\t" + str(state['value']) + "\n"
-            mailer = AuraMailer(self.adminMails, self.fromMail)
-            mailer.send_admin_mail(subject, mailmessage)
+
+            #mailer = AuraMailer(self.adminMails, self.fromMail)
+            #mailer.send_admin_mail(subject, mailmessage)
         else:
             return False
 
-- 
GitLab