From d3bcf5aad566eddc2514d84c148ed1f7d0ee4033 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Tue, 16 Jan 2018 18:22:01 +0000
Subject: supplemental-web: fe_status.py: change get frontend method and add IP
 address

---
 abs/core/supplemental-web/PKGBUILD              |  4 +--
 abs/core/supplemental-web/contents/fe_status.py | 39 +++++++++++++------------
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/abs/core/supplemental-web/PKGBUILD b/abs/core/supplemental-web/PKGBUILD
index ea70a2e..4fcef9e 100644
--- a/abs/core/supplemental-web/PKGBUILD
+++ b/abs/core/supplemental-web/PKGBUILD
@@ -1,7 +1,7 @@
 pkgbase=supplemental-web
 pkgname=('supplemental-web' 'supplemental-web-slave')
-pkgver=8.4
-pkgrel=3
+pkgver=8.5
+pkgrel=1
 arch=('i686' 'x86_64')
 license=('GPL')
 backup=('data/srv/httpd/cgi/extra.cfg.txt')
diff --git a/abs/core/supplemental-web/contents/fe_status.py b/abs/core/supplemental-web/contents/fe_status.py
index 993ef72..439d0c5 100644
--- a/abs/core/supplemental-web/contents/fe_status.py
+++ b/abs/core/supplemental-web/contents/fe_status.py
@@ -25,7 +25,8 @@ def parse_xml(frontend):
         tree = ET.parse(xml)
         root = tree.getroot()
     except:
-        msg("   Couldn't connect to %s" %frontend)
+        #msg("   Couldn't connect to %s" %frontend)
+        temp_dict['state'] = "offline"
         return temp_dict
 
     lst = root.find("State")
@@ -51,23 +52,25 @@ def parse_xml(frontend):
 
 
 def mythfe_status(cursor,mythDB):
-    frontends=list(Frontend.fromUPNP())
     status_dict={}
-    #try:
+    try:
         #frontends = mythDB.getFrontends() #use cursor instead so it doesn't test connection
-        #cursor.execute("select hostname from settings where value = 'FrontendIdleTimeout'")
-        #frontends=cursor.fetchall()
-    #except:
-        #msg("Excptions")
-        #return
+        cursor.execute("select distinct hostname from settings where hostname is not null;")
+        frontends=cursor.fetchall()
+    except:
+        #msg("Exceptions")
+        return
 
     for i in frontends:
+        i=''.join(i)
         try:
-            fe_hostname = socket.gethostbyaddr(i.host)[0]
+            fe_hostname = socket.gethostbyaddr(i)[0]
         except:
-            print "DNS lookup failed for %s" %i.host
-            fe_hostname = i.host
-        status_dict[fe_hostname] = parse_xml(i.host)
+            #print "DNS lookup failed for %s" %i
+            fe_hostname = socket.gethostbyname(i)
+        ip_addr = socket.gethostbyname(i)
+        fe_hostname = "%s (%s)" %(fe_hostname,ip_addr)
+        status_dict[fe_hostname] = parse_xml(ip_addr)
 
     return status_dict
 
@@ -102,12 +105,12 @@ def print_html(status_dict):
     print "</table>"
     print '</div>'
 
-    print '''
-    <div id="footer">
-       </br>
-       <p>Offline systems are not listed</p>
-    </div>
-'''
+#    print '''
+#    <div id="footer">
+#       </br>
+#       <p>Offline systems are not listed</p>
+#    </div>
+#'''
 
 
 def main():
-- 
cgit v0.12

