mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 13:46:58 -05:00
commit
931dc6bd52
@ -37,6 +37,10 @@ def run(settings, logger, db):
|
|||||||
fhdhr = fHDHR_OBJ(settings, logger, db)
|
fhdhr = fHDHR_OBJ(settings, logger, db)
|
||||||
fhdhrweb = fHDHR_HTTP_Server(fhdhr)
|
fhdhrweb = fHDHR_HTTP_Server(fhdhr)
|
||||||
|
|
||||||
|
# Ensure spawn on Windows instead of fork
|
||||||
|
if settings.dict["main"]["opersystem"] in ["Windows"]:
|
||||||
|
multiprocessing.set_start_method('spawn')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
print("HTTP Server Starting")
|
print("HTTP Server Starting")
|
||||||
|
|||||||
@ -4,9 +4,10 @@ import configparser
|
|||||||
import pathlib
|
import pathlib
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import platform
|
||||||
|
|
||||||
import fHDHR.exceptions
|
import fHDHR.exceptions
|
||||||
from fHDHR.tools import isint, isfloat, is_arithmetic
|
from fHDHR.tools import isint, isfloat, is_arithmetic, is_docker
|
||||||
|
|
||||||
|
|
||||||
class Config():
|
class Config():
|
||||||
@ -158,6 +159,22 @@ class Config():
|
|||||||
if self.dict["fhdhr"]["stream_type"] not in ["direct", "ffmpeg"]:
|
if self.dict["fhdhr"]["stream_type"] not in ["direct", "ffmpeg"]:
|
||||||
raise fHDHR.exceptions.ConfigurationError("Invalid stream type. Exiting...")
|
raise fHDHR.exceptions.ConfigurationError("Invalid stream type. Exiting...")
|
||||||
|
|
||||||
|
opersystem = platform.system()
|
||||||
|
self.dict["main"]["opersystem"] = opersystem
|
||||||
|
if opersystem in ["Linux", "Darwin"]:
|
||||||
|
# Linux/Mac
|
||||||
|
if os.getuid() == 0 or os.geteuid() == 0:
|
||||||
|
print('Warning: Do not run fHDHR with root privileges.')
|
||||||
|
elif opersystem in ["Windows"]:
|
||||||
|
# Windows
|
||||||
|
if os.environ.get("USERNAME") == "Administrator":
|
||||||
|
print('Warning: Do not run fHDHR as Administrator.')
|
||||||
|
else:
|
||||||
|
print("Uncommon Operating System, use at your own risk.")
|
||||||
|
|
||||||
|
isdocker = is_docker()
|
||||||
|
self.dict["main"]["isdocker"] = isdocker
|
||||||
|
|
||||||
if self.dict["fhdhr"]["stream_type"] == "ffmpeg":
|
if self.dict["fhdhr"]["stream_type"] == "ffmpeg":
|
||||||
try:
|
try:
|
||||||
ffmpeg_command = [self.dict["ffmpeg"]["ffmpeg_path"],
|
ffmpeg_command = [self.dict["ffmpeg"]["ffmpeg_path"],
|
||||||
@ -173,6 +190,8 @@ class Config():
|
|||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
ffmpeg_version = None
|
ffmpeg_version = None
|
||||||
self.dict["ffmpeg"]["version"] = ffmpeg_version
|
self.dict["ffmpeg"]["version"] = ffmpeg_version
|
||||||
|
else:
|
||||||
|
self.dict["ffmpeg"]["version"] = "N/A"
|
||||||
|
|
||||||
if not self.dict["fhdhr"]["discovery_address"] and self.dict["fhdhr"]["address"] != "0.0.0.0":
|
if not self.dict["fhdhr"]["discovery_address"] and self.dict["fhdhr"]["address"] != "0.0.0.0":
|
||||||
self.dict["fhdhr"]["discovery_address"] = self.dict["fhdhr"]["address"]
|
self.dict["fhdhr"]["discovery_address"] = self.dict["fhdhr"]["address"]
|
||||||
|
|||||||
@ -108,7 +108,11 @@ class SSDPServer():
|
|||||||
|
|
||||||
(host, port) = address
|
(host, port) = address
|
||||||
|
|
||||||
header, payload = data.decode().split('\r\n\r\n')[:2]
|
try:
|
||||||
|
header, payload = data.decode().split('\r\n\r\n')[:2]
|
||||||
|
except ValueError:
|
||||||
|
self.logger.error("Error with Received packet from {}: {}".format(address, data))
|
||||||
|
return
|
||||||
|
|
||||||
lines = header.split('\r\n')
|
lines = header.split('\r\n')
|
||||||
cmd = lines[0].split(' ')
|
cmd = lines[0].split(' ')
|
||||||
|
|||||||
@ -31,20 +31,18 @@ class Version_HTML():
|
|||||||
fakefile.write(" <th></th>\n")
|
fakefile.write(" <th></th>\n")
|
||||||
fakefile.write(" </tr>\n")
|
fakefile.write(" </tr>\n")
|
||||||
|
|
||||||
fakefile.write(" <tr>\n")
|
table_guts = [
|
||||||
fakefile.write(" <td>%s</td>\n" % ("fHDHR"))
|
["fHDHR", self.fhdhr.version],
|
||||||
fakefile.write(" <td>%s</td>\n" % (str(self.fhdhr.version)))
|
["Python", sys.version],
|
||||||
fakefile.write(" </tr>\n")
|
["Operating System", self.fhdhr.config.dict["main"]["opersystem"]],
|
||||||
|
["Using Docker", self.fhdhr.config.dict["main"]["isdocker"]],
|
||||||
|
["ffmpeg", self.fhdhr.config.dict["ffmpeg"]["version"]]
|
||||||
|
]
|
||||||
|
|
||||||
fakefile.write(" <tr>\n")
|
for item in table_guts:
|
||||||
fakefile.write(" <td>%s</td>\n" % ("Python"))
|
|
||||||
fakefile.write(" <td>%s</td>\n" % (str(sys.version)))
|
|
||||||
fakefile.write(" </tr>\n")
|
|
||||||
|
|
||||||
if self.fhdhr.config.dict["fhdhr"]["stream_type"] == "ffmpeg":
|
|
||||||
fakefile.write(" <tr>\n")
|
fakefile.write(" <tr>\n")
|
||||||
fakefile.write(" <td>%s</td>\n" % ("ffmpeg"))
|
fakefile.write(" <td>%s</td>\n" % (str(item[0])))
|
||||||
fakefile.write(" <td>%s</td>\n" % (str(self.fhdhr.config.dict["ffmpeg"]["version"])))
|
fakefile.write(" <td>%s</td>\n" % (str(item[1])))
|
||||||
fakefile.write(" </tr>\n")
|
fakefile.write(" </tr>\n")
|
||||||
|
|
||||||
for line in page_elements["end"]:
|
for line in page_elements["end"]:
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
import re
|
||||||
import ast
|
import ast
|
||||||
import requests
|
import requests
|
||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
@ -6,6 +8,17 @@ UNARY_OPS = (ast.UAdd, ast.USub)
|
|||||||
BINARY_OPS = (ast.Add, ast.Sub, ast.Mult, ast.Div, ast.Mod)
|
BINARY_OPS = (ast.Add, ast.Sub, ast.Mult, ast.Div, ast.Mod)
|
||||||
|
|
||||||
|
|
||||||
|
def is_docker():
|
||||||
|
path = "/proc/self/cgroup"
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
return False
|
||||||
|
with open(path) as f:
|
||||||
|
for line in f:
|
||||||
|
if re.match("\d+:[\w=]+:/docker(-[ce]e)?/\w+", line):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def sub_el(parent, name, text=None, **kwargs):
|
def sub_el(parent, name, text=None, **kwargs):
|
||||||
el = xml.etree.ElementTree.SubElement(parent, name, **kwargs)
|
el = xml.etree.ElementTree.SubElement(parent, name, **kwargs)
|
||||||
if text:
|
if text:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user