From b455d5f7fb70b2d7350e7b9aff8ff6d4ada73818 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Fri, 13 Jan 2023 16:04:38 -0500
Subject: linhes-web: fix count.py for empty db

---
 linhes/linhes-web/PKGBUILD                  |  4 ++--
 linhes/linhes-web/website/contents/count.py | 13 ++++++-------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/linhes/linhes-web/PKGBUILD b/linhes/linhes-web/PKGBUILD
index cb68780..8dfb500 100644
--- a/linhes/linhes-web/PKGBUILD
+++ b/linhes/linhes-web/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=linhes-web
 pkgver=9.0.0
-pkgrel=4
+pkgrel=5
 conflicts=()
 pkgdesc="LinHES local website"
 depends=('lighttpd' 'php-cgi')
@@ -9,7 +9,7 @@ arch=('x86_64')
 license=('GPL')
 source=('linhes-web.conf' 'website.tar.gz')
 sha256sums=('e39ce02bde5eb3d359f1286b41751aa715961cf2b2d9a1243c7f01d20ed9c993'
-            '4d6f1e09b1f9ba5585acf8c15097c296a13b00782ee039809ecb5c6ef83dc805')
+            '37124fccf3fe1a69a52a62ffc88a6cc748eaefde9725e8fa315cc2b29f68cf8b')
 
 package() {
     mkdir -p $pkgdir/data/srv/httpd/htdocs/
diff --git a/linhes/linhes-web/website/contents/count.py b/linhes/linhes-web/website/contents/count.py
index d5f3259..2aaa3e1 100644
--- a/linhes/linhes-web/website/contents/count.py
+++ b/linhes/linhes-web/website/contents/count.py
@@ -9,11 +9,8 @@ import socket
 
 def main(argv):
     #get LinHES version
-    verfile = open('/etc/os-release', 'r')
-    for line in verfile:
-        if line.startswith('PRETTY_NAME'):
-            verLHlist = line.split('"')
-            verLH = verLHlist[1]
+    verfile = open('/etc/LinHES-release', 'r')
+    verLH = verfile.read()
     verfile.close()
 
     grandtotal=0
@@ -34,8 +31,10 @@ def main(argv):
             grandtotal+=total
     hours = grandtotal / 60.0
     days = hours / 24.0
-
-    cursor.execute("SELECT unix_timestamp(starttime),unix_timestamp(endtime),title FROM recorded where not (recgroup=(%s))  ORDER by starttime",("LiveTV"))
+    try:
+        cursor.execute("SELECT unix_timestamp(starttime),unix_timestamp(endtime),title FROM recorded where not (recgroup=(%s))  ORDER by starttime",("LiveTV"))
+    except:
+        pass
     result_current = cursor.fetchall()
     for row in result_current:
         start=row[0]
-- 
cgit v0.12

