mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 11:36:59 -05:00
Enhance Logging
This commit is contained in:
parent
1a007abec0
commit
9d103f8309
@ -17,6 +17,7 @@ class Channels():
|
|||||||
|
|
||||||
self.list = {}
|
self.list = {}
|
||||||
self.list_update_time = None
|
self.list_update_time = None
|
||||||
|
|
||||||
self.get_db_channels()
|
self.get_db_channels()
|
||||||
self.get_channels()
|
self.get_channels()
|
||||||
|
|
||||||
@ -30,7 +31,10 @@ class Channels():
|
|||||||
self.get_channel_obj(keyfind, valfind).set_status(updatedict)
|
self.get_channel_obj(keyfind, valfind).set_status(updatedict)
|
||||||
|
|
||||||
def get_db_channels(self):
|
def get_db_channels(self):
|
||||||
|
self.fhdhr.logger.info("Checking for Channel information stored in the database.")
|
||||||
channel_ids = self.fhdhr.db.get_fhdhr_value("channels", "list") or []
|
channel_ids = self.fhdhr.db.get_fhdhr_value("channels", "list") or []
|
||||||
|
if len(channel_ids):
|
||||||
|
self.fhdhr.logger.info("Found %s existing channels in the database." % str(len(channel_ids)))
|
||||||
for channel_id in channel_ids:
|
for channel_id in channel_ids:
|
||||||
channel_obj = Channel(self.fhdhr, self.id_system, channel_id=channel_id)
|
channel_obj = Channel(self.fhdhr, self.id_system, channel_id=channel_id)
|
||||||
channel_id = channel_obj.dict["id"]
|
channel_id = channel_obj.dict["id"]
|
||||||
@ -53,6 +57,7 @@ class Channels():
|
|||||||
updatelist = True
|
updatelist = True
|
||||||
|
|
||||||
if updatelist:
|
if updatelist:
|
||||||
|
self.fhdhr.logger.info("Performing Channel Scan.")
|
||||||
channel_dict_list = self.origin.get_channels()
|
channel_dict_list = self.origin.get_channels()
|
||||||
for channel_info in channel_dict_list:
|
for channel_info in channel_dict_list:
|
||||||
channel_obj = Channel(self.fhdhr, self.id_system, origin_id=channel_info["id"])
|
channel_obj = Channel(self.fhdhr, self.id_system, origin_id=channel_info["id"])
|
||||||
|
|||||||
@ -12,6 +12,7 @@ class fHDHR_Cluster():
|
|||||||
self.friendlyname = self.fhdhr.config.dict["fhdhr"]["friendlyname"]
|
self.friendlyname = self.fhdhr.config.dict["fhdhr"]["friendlyname"]
|
||||||
self.location = None
|
self.location = None
|
||||||
self.location_url = None
|
self.location_url = None
|
||||||
|
|
||||||
if fhdhr.config.dict["fhdhr"]["discovery_address"]:
|
if fhdhr.config.dict["fhdhr"]["discovery_address"]:
|
||||||
self.location = ('http://' + fhdhr.config.dict["fhdhr"]["discovery_address"] + ':' +
|
self.location = ('http://' + fhdhr.config.dict["fhdhr"]["discovery_address"] + ':' +
|
||||||
str(fhdhr.config.dict["fhdhr"]["port"]))
|
str(fhdhr.config.dict["fhdhr"]["port"]))
|
||||||
@ -65,9 +66,15 @@ class fHDHR_Cluster():
|
|||||||
return defdict
|
return defdict
|
||||||
|
|
||||||
def startup_sync(self):
|
def startup_sync(self):
|
||||||
|
self.fhdhr.logger.info("Syncronizing with Cluster.")
|
||||||
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
|
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
|
||||||
|
if not len(list(cluster.keys())):
|
||||||
|
self.fhdhr.logger.info("No Cluster Found.")
|
||||||
|
else:
|
||||||
|
self.fhdhr.logger.info("Found %s clustered services." % str(len(list(cluster.keys()))))
|
||||||
for location in list(cluster.keys()):
|
for location in list(cluster.keys()):
|
||||||
if location != self.location:
|
if location != self.location:
|
||||||
|
self.fhdhr.logger.info("Checking Cluster Syncronization information from %s." % location)
|
||||||
sync_url = location + "/api/cluster?method=get"
|
sync_url = location + "/api/cluster?method=get"
|
||||||
try:
|
try:
|
||||||
sync_open = self.fhdhr.web.session.get(sync_url)
|
sync_open = self.fhdhr.web.session.get(sync_url)
|
||||||
@ -78,12 +85,14 @@ class fHDHR_Cluster():
|
|||||||
self.fhdhr.logger.error("Unreachable: " + location)
|
self.fhdhr.logger.error("Unreachable: " + location)
|
||||||
|
|
||||||
def leave(self):
|
def leave(self):
|
||||||
|
self.fhdhr.logger.info("Leaving cluster.")
|
||||||
self.fhdhr.db.set_fhdhr_value("cluster", "dict", self.default_cluster())
|
self.fhdhr.db.set_fhdhr_value("cluster", "dict", self.default_cluster())
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
|
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
|
||||||
for location in list(cluster.keys()):
|
for location in list(cluster.keys()):
|
||||||
if location != self.location:
|
if location != self.location:
|
||||||
|
self.fhdhr.logger.info("Informing %s that I am departing the Cluster." % location)
|
||||||
sync_url = location + "/api/cluster?method=del&location=" + self.location
|
sync_url = location + "/api/cluster?method=del&location=" + self.location
|
||||||
try:
|
try:
|
||||||
self.fhdhr.web.session.get(sync_url)
|
self.fhdhr.web.session.get(sync_url)
|
||||||
@ -112,6 +121,7 @@ class fHDHR_Cluster():
|
|||||||
def add(self, location):
|
def add(self, location):
|
||||||
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
|
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
|
||||||
if location not in list(cluster.keys()):
|
if location not in list(cluster.keys()):
|
||||||
|
self.fhdhr.logger.info("Adding %s to cluster." % location)
|
||||||
cluster[location] = {"base_url": location}
|
cluster[location] = {"base_url": location}
|
||||||
|
|
||||||
location_info_url = location + "/discover.json"
|
location_info_url = location + "/discover.json"
|
||||||
@ -144,6 +154,7 @@ class fHDHR_Cluster():
|
|||||||
def remove(self, location):
|
def remove(self, location):
|
||||||
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
|
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
|
||||||
if location in list(cluster.keys()):
|
if location in list(cluster.keys()):
|
||||||
|
self.fhdhr.logger.info("Removing %s from cluster." % location)
|
||||||
del cluster[location]
|
del cluster[location]
|
||||||
sync_url = location + "/api/cluster?method=leave"
|
sync_url = location + "/api/cluster?method=leave"
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -134,7 +134,9 @@ class EPG():
|
|||||||
return next(item for item in event_list if item["id"] == event_id)
|
return next(item for item in event_list if item["id"] == event_id)
|
||||||
|
|
||||||
def epg_method_selfadd(self):
|
def epg_method_selfadd(self):
|
||||||
|
self.fhdhr.logger.info("Checking for Optional EPG methods.")
|
||||||
for method in epgtype_list:
|
for method in epgtype_list:
|
||||||
|
self.fhdhr.logger.info("Found %s EPG method." % method)
|
||||||
exec("%s = %s" % ("self." + str(method), str(method) + "." + str(method) + "EPG(self.fhdhr, self.channels)"))
|
exec("%s = %s" % ("self." + str(method), str(method) + "." + str(method) + "EPG(self.fhdhr, self.channels)"))
|
||||||
|
|
||||||
def update(self, method=None):
|
def update(self, method=None):
|
||||||
|
|||||||
@ -15,6 +15,8 @@ class Tuners():
|
|||||||
|
|
||||||
self.tuners = {}
|
self.tuners = {}
|
||||||
|
|
||||||
|
self.fhdhr.logger.info("Creating %s tuners." % str(self.max_tuners))
|
||||||
|
|
||||||
for i in range(1, self.max_tuners + 1):
|
for i in range(1, self.max_tuners + 1):
|
||||||
self.tuners[i] = Tuner(fhdhr, i, epg)
|
self.tuners[i] = Tuner(fhdhr, i, epg)
|
||||||
|
|
||||||
|
|||||||
@ -15,17 +15,23 @@ class fHDHR_HTTP_Server():
|
|||||||
|
|
||||||
self.template_folder = fhdhr.config.internal["paths"]["www_templates_dir"]
|
self.template_folder = fhdhr.config.internal["paths"]["www_templates_dir"]
|
||||||
|
|
||||||
|
self.fhdhr.logger.info("Loading Flask.")
|
||||||
|
|
||||||
self.app = Flask("fHDHR", template_folder=self.template_folder)
|
self.app = Flask("fHDHR", template_folder=self.template_folder)
|
||||||
|
|
||||||
|
self.fhdhr.logger.info("Loading HTTP Pages Endpoints.")
|
||||||
self.pages = fHDHR_Pages(fhdhr)
|
self.pages = fHDHR_Pages(fhdhr)
|
||||||
self.add_endpoints(self.pages, "pages")
|
self.add_endpoints(self.pages, "pages")
|
||||||
|
|
||||||
|
self.fhdhr.logger.info("Loading HTTP Files Endpoints.")
|
||||||
self.files = fHDHR_Files(fhdhr)
|
self.files = fHDHR_Files(fhdhr)
|
||||||
self.add_endpoints(self.files, "files")
|
self.add_endpoints(self.files, "files")
|
||||||
|
|
||||||
|
self.fhdhr.logger.info("Loading HTTP API Endpoints.")
|
||||||
self.api = fHDHR_API(fhdhr)
|
self.api = fHDHR_API(fhdhr)
|
||||||
self.add_endpoints(self.api, "api")
|
self.add_endpoints(self.api, "api")
|
||||||
|
|
||||||
|
self.fhdhr.logger.info("Loading HTTP Stream Endpoints.")
|
||||||
self.watch = fHDHR_WATCH(fhdhr)
|
self.watch = fHDHR_WATCH(fhdhr)
|
||||||
self.add_endpoints(self.watch, "watch")
|
self.add_endpoints(self.watch, "watch")
|
||||||
|
|
||||||
@ -41,6 +47,7 @@ class fHDHR_HTTP_Server():
|
|||||||
endpoint_methods = eval("self." + str(index_name) + "." + str(item) + ".endpoint_methods")
|
endpoint_methods = eval("self." + str(index_name) + "." + str(item) + ".endpoint_methods")
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
endpoint_methods = ['GET']
|
endpoint_methods = ['GET']
|
||||||
|
self.fhdhr.logger.info("Adding endpoint %s available at %s with %s methods." % (endpoint_name, ",".join(endpoints), ",".join(endpoint_methods)))
|
||||||
for endpoint in endpoints:
|
for endpoint in endpoints:
|
||||||
self.add_endpoint(endpoint=endpoint,
|
self.add_endpoint(endpoint=endpoint,
|
||||||
endpoint_name=endpoint_name,
|
endpoint_name=endpoint_name,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import request, abort, Response
|
|||||||
|
|
||||||
class Lineup_Post():
|
class Lineup_Post():
|
||||||
endpoints = ["/lineup.post"]
|
endpoints = ["/lineup.post"]
|
||||||
endpoint_name = "lineup_post"
|
endpoint_name = "api_lineup_post"
|
||||||
endpoint_methods = ["POST"]
|
endpoint_methods = ["POST"]
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
|
|||||||
@ -7,7 +7,7 @@ from fHDHR.tools import sub_el
|
|||||||
|
|
||||||
class Device_XML():
|
class Device_XML():
|
||||||
endpoints = ["/device.xml"]
|
endpoints = ["/device.xml"]
|
||||||
endpoint_name = "device_xml"
|
endpoint_name = "file_device_xml"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import json
|
|||||||
|
|
||||||
class Discover_JSON():
|
class Discover_JSON():
|
||||||
endpoints = ["/discover.json"]
|
endpoints = ["/discover.json"]
|
||||||
endpoint_name = "discover_json"
|
endpoint_name = "file_discover_json"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import send_from_directory
|
|||||||
|
|
||||||
class Favicon_ICO():
|
class Favicon_ICO():
|
||||||
endpoints = ["/favicon.ico"]
|
endpoints = ["/favicon.ico"]
|
||||||
endpoint_name = "favicon"
|
endpoint_name = "file_favicon_ico"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import json
|
|||||||
|
|
||||||
class Lineup_JSON():
|
class Lineup_JSON():
|
||||||
endpoints = ["/lineup.json"]
|
endpoints = ["/lineup.json"]
|
||||||
endpoint_name = "lineup_json"
|
endpoint_name = "file_lineup_json"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import json
|
|||||||
|
|
||||||
class Lineup_Status_JSON():
|
class Lineup_Status_JSON():
|
||||||
endpoints = ["/lineup_status.json"]
|
endpoints = ["/lineup_status.json"]
|
||||||
endpoint_name = "lineup_status_json"
|
endpoint_name = "file_lineup_status_json"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -7,7 +7,7 @@ from fHDHR.tools import sub_el
|
|||||||
|
|
||||||
class Lineup_XML():
|
class Lineup_XML():
|
||||||
endpoints = ["/lineup.xml"]
|
endpoints = ["/lineup.xml"]
|
||||||
endpoint_name = "lineup_xml"
|
endpoint_name = "file_lineup_xml"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import send_from_directory
|
|||||||
|
|
||||||
class Style_CSS():
|
class Style_CSS():
|
||||||
endpoints = ["/style.css"]
|
endpoints = ["/style.css"]
|
||||||
endpoint_name = "style"
|
endpoint_name = "file_style_css"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import request, render_template
|
|||||||
|
|
||||||
class Channels_HTML():
|
class Channels_HTML():
|
||||||
endpoints = ["/channels", "/channels.html"]
|
endpoints = ["/channels", "/channels.html"]
|
||||||
endpoint_name = "channels_html"
|
endpoint_name = "page_channels_html"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import urllib.parse
|
|||||||
|
|
||||||
class Cluster_HTML():
|
class Cluster_HTML():
|
||||||
endpoints = ["/cluster", "/cluster.html"]
|
endpoints = ["/cluster", "/cluster.html"]
|
||||||
endpoint_name = "cluster_html"
|
endpoint_name = "page_cluster_html"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import request, render_template
|
|||||||
|
|
||||||
class Diagnostics_HTML():
|
class Diagnostics_HTML():
|
||||||
endpoints = ["/diagnostics", "/diagnostics.html"]
|
endpoints = ["/diagnostics", "/diagnostics.html"]
|
||||||
endpoint_name = "diagnostics_html"
|
endpoint_name = "page_diagnostics_html"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from fHDHR.tools import humanized_time
|
|||||||
|
|
||||||
class Guide_HTML():
|
class Guide_HTML():
|
||||||
endpoints = ["/guide", "/guide.html"]
|
endpoints = ["/guide", "/guide.html"]
|
||||||
endpoint_name = "guide_html"
|
endpoint_name = "page_guide_html"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import request, render_template
|
|||||||
|
|
||||||
class Index_HTML():
|
class Index_HTML():
|
||||||
endpoints = ["/", "/index", "/index.html"]
|
endpoints = ["/", "/index", "/index.html"]
|
||||||
endpoint_name = "root_html"
|
endpoint_name = "page_root_html"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import request, render_template
|
|||||||
|
|
||||||
class Origin_HTML():
|
class Origin_HTML():
|
||||||
endpoints = ["/origin", "/origin.html"]
|
endpoints = ["/origin", "/origin.html"]
|
||||||
endpoint_name = "origin_html"
|
endpoint_name = "page_origin_html"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import request, render_template
|
|||||||
|
|
||||||
class Settings_HTML():
|
class Settings_HTML():
|
||||||
endpoints = ["/settings", "/settings.html"]
|
endpoints = ["/settings", "/settings.html"]
|
||||||
endpoint_name = "settings_html"
|
endpoint_name = "page_settings_html"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import request, render_template
|
|||||||
|
|
||||||
class Streams_HTML():
|
class Streams_HTML():
|
||||||
endpoints = ["/streams", "/streams.html"]
|
endpoints = ["/streams", "/streams.html"]
|
||||||
endpoint_name = "streams_html"
|
endpoint_name = "page_streams_html"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import request, render_template
|
|||||||
|
|
||||||
class Version_HTML():
|
class Version_HTML():
|
||||||
endpoints = ["/version", "/version.html"]
|
endpoints = ["/version", "/version.html"]
|
||||||
endpoint_name = "version_html"
|
endpoint_name = "page_version_html"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask import request, render_template
|
|||||||
|
|
||||||
class xmlTV_HTML():
|
class xmlTV_HTML():
|
||||||
endpoints = ["/xmltv", "/xmltv.html"]
|
endpoints = ["/xmltv", "/xmltv.html"]
|
||||||
endpoint_name = "xmltv_html"
|
endpoint_name = "page_xmltv_html"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import urllib.parse
|
|||||||
|
|
||||||
class Auto():
|
class Auto():
|
||||||
endpoints = ['/auto/<channel>']
|
endpoints = ['/auto/<channel>']
|
||||||
endpoint_name = "auto"
|
endpoint_name = "watch_auto"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import urllib.parse
|
|||||||
|
|
||||||
class Tuner():
|
class Tuner():
|
||||||
endpoints = ['/tuner<tuner_number>/<channel>']
|
endpoints = ['/tuner<tuner_number>/<channel>']
|
||||||
endpoint_name = "tuner"
|
endpoint_name = "watch_tuner"
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
def __init__(self, fhdhr):
|
||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user