mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 13:23:18 -07:00
add check for server_running with 60s timeout. Fixes #494
This commit is contained in:
parent
50dc6c16f5
commit
b34e0aca32
7 changed files with 66 additions and 32 deletions
|
@ -3,7 +3,7 @@ import time
|
|||
import nzbtomedia
|
||||
import requests
|
||||
import time
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, remoteDir
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, remoteDir, server_responding
|
||||
from nzbtomedia.nzbToMediaSceneExceptions import process_all_exceptions
|
||||
from nzbtomedia import logger
|
||||
|
||||
|
@ -30,6 +30,16 @@ class autoProcessComics:
|
|||
except:
|
||||
remote_path = 0
|
||||
|
||||
if ssl:
|
||||
protocol = "https://"
|
||||
else:
|
||||
protocol = "http://"
|
||||
|
||||
url = "%s%s:%s%s/post_process" % (protocol, host, port, web_root)
|
||||
if not server_responding(url):
|
||||
logger.error("Server did not respond. Exiting", section)
|
||||
return [1, "%s: Failed to post-process - %s did not respond." % (section, section) ]
|
||||
|
||||
inputName, dirName = convert_to_ascii(inputName, dirName)
|
||||
clean_name, ext = os.path.splitext(inputName)
|
||||
if len(ext) == 4: # we assume this was a standrard extension.
|
||||
|
@ -44,13 +54,6 @@ class autoProcessComics:
|
|||
if inputName != None:
|
||||
params['nzb_name'] = inputName
|
||||
|
||||
if ssl:
|
||||
protocol = "https://"
|
||||
else:
|
||||
protocol = "http://"
|
||||
|
||||
url = "%s%s:%s%s/post_process" % (protocol, host, port, web_root)
|
||||
|
||||
success = False
|
||||
|
||||
logger.debug("Opening URL: %s" % (url), section)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import nzbtomedia
|
||||
import requests
|
||||
import shutil
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, server_responding
|
||||
from nzbtomedia.nzbToMediaSceneExceptions import process_all_exceptions
|
||||
from nzbtomedia import logger
|
||||
|
||||
|
@ -30,9 +30,12 @@ class autoProcessGames:
|
|||
else:
|
||||
protocol = "http://"
|
||||
|
||||
inputName, dirName = convert_to_ascii(inputName, dirName)
|
||||
|
||||
url = "%s%s:%s%s/api" % (protocol, host, port, web_root)
|
||||
if not server_responding(url):
|
||||
logger.error("Server did not respond. Exiting", section)
|
||||
return [1, "%s: Failed to post-process - %s did not respond." % (section, section) ]
|
||||
|
||||
inputName, dirName = convert_to_ascii(inputName, dirName)
|
||||
|
||||
fields = inputName.split("-")
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import requests
|
|||
import nzbtomedia
|
||||
|
||||
from nzbtomedia.nzbToMediaSceneExceptions import process_all_exceptions
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, rmDir, find_imdbid, find_download, listMediaFiles, remoteDir, import_subs
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, rmDir, find_imdbid, find_download, listMediaFiles, remoteDir, import_subs, server_responding
|
||||
from nzbtomedia import logger
|
||||
from nzbtomedia.transcoder import transcoder
|
||||
|
||||
|
@ -125,6 +125,9 @@ class autoProcessMovie:
|
|||
protocol = "http://"
|
||||
|
||||
baseURL = "%s%s:%s%s/api/%s" % (protocol, host, port, web_root, apikey)
|
||||
if not server_responding(baseURL):
|
||||
logger.error("Server did not respond. Exiting", section)
|
||||
return [1, "%s: Failed to post-process - %s did not respond." % (section, section) ]
|
||||
|
||||
imdbid = find_imdbid(dirName, inputName)
|
||||
release = self.get_release(baseURL, imdbid, download_id)
|
||||
|
|
|
@ -3,7 +3,7 @@ import time
|
|||
import requests
|
||||
import nzbtomedia
|
||||
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, remoteDir, listMediaFiles
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, remoteDir, listMediaFiles, server_responding
|
||||
from nzbtomedia.nzbToMediaSceneExceptions import process_all_exceptions
|
||||
from nzbtomedia import logger
|
||||
|
||||
|
@ -58,6 +58,12 @@ class autoProcessMusic:
|
|||
else:
|
||||
protocol = "http://"
|
||||
|
||||
|
||||
url = "%s%s:%s%s/api" % (protocol,host,port,web_root)
|
||||
if not server_responding(url):
|
||||
logger.error("Server did not respond. Exiting", section)
|
||||
return [1, "%s: Failed to post-process - %s did not respond." % (section, section) ]
|
||||
|
||||
if not os.path.isdir(dirName) and os.path.isfile(dirName): # If the input directory is a file, assume single file download and split dir/name.
|
||||
dirName = os.path.split(os.path.normpath(dirName))[0]
|
||||
|
||||
|
@ -80,8 +86,6 @@ class autoProcessMusic:
|
|||
logger.info("Status shown as failed from Downloader, but %s valid video files found. Setting as successful." % (str(good_files)), section)
|
||||
status = 0
|
||||
|
||||
url = "%s%s:%s%s/api" % (protocol,host,port,web_root)
|
||||
|
||||
if status == 0:
|
||||
|
||||
params = {}
|
||||
|
|
|
@ -8,7 +8,7 @@ import nzbtomedia
|
|||
|
||||
from nzbtomedia.nzbToMediaAutoFork import autoFork
|
||||
from nzbtomedia.nzbToMediaSceneExceptions import process_all_exceptions
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, flatten, rmDir, listMediaFiles, remoteDir, import_subs
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, flatten, rmDir, listMediaFiles, remoteDir, import_subs, server_responding
|
||||
from nzbtomedia import logger
|
||||
from nzbtomedia.transcoder import transcoder
|
||||
|
||||
|
@ -32,11 +32,27 @@ class autoProcessTV:
|
|||
return missing
|
||||
|
||||
def processEpisode(self, section, dirName, inputName=None, failed=False, clientAgent = "manual", inputCategory=None):
|
||||
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
||||
port = nzbtomedia.CFG[section][inputCategory]["port"]
|
||||
try:
|
||||
ssl = int(nzbtomedia.CFG[section][inputCategory]["ssl"])
|
||||
except:
|
||||
ssl = 0
|
||||
if ssl:
|
||||
protocol = "https://"
|
||||
else:
|
||||
protocol = "http://"
|
||||
try:
|
||||
web_root = nzbtomedia.CFG[section][inputCategory]["web_root"]
|
||||
except:
|
||||
web_root = ""
|
||||
if not server_responding("%s%s:%s%s" % (protocol,host,port,web_root)):
|
||||
logger.error("Server did not respond. Exiting", section)
|
||||
return [1, "%s: Failed to post-process - %s did not respond." % (section, section) ]
|
||||
|
||||
# auto-detect correct fork
|
||||
fork, fork_params = autoFork(section, inputCategory)
|
||||
|
||||
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
||||
port = nzbtomedia.CFG[section][inputCategory]["port"]
|
||||
try:
|
||||
username = nzbtomedia.CFG[section][inputCategory]["username"]
|
||||
password = nzbtomedia.CFG[section][inputCategory]["password"]
|
||||
|
@ -47,14 +63,6 @@ class autoProcessTV:
|
|||
apikey = nzbtomedia.CFG[section][inputCategory]["apikey"]
|
||||
except:
|
||||
apikey = ""
|
||||
try:
|
||||
ssl = int(nzbtomedia.CFG[section][inputCategory]["ssl"])
|
||||
except:
|
||||
ssl = 0
|
||||
try:
|
||||
web_root = nzbtomedia.CFG[section][inputCategory]["web_root"]
|
||||
except:
|
||||
web_root = ""
|
||||
try:
|
||||
delete_failed = int(nzbtomedia.CFG[section][inputCategory]["delete_failed"])
|
||||
except:
|
||||
|
@ -202,11 +210,6 @@ class autoProcessTV:
|
|||
else:
|
||||
logger.warning("FAILED: Transcoding failed for files in %s" % (dirName), section)
|
||||
|
||||
if ssl:
|
||||
protocol = "https://"
|
||||
else:
|
||||
protocol = "http://"
|
||||
|
||||
url = None
|
||||
if section == "SickBeard":
|
||||
url = "%s%s:%s%s/home/postprocess/processEpisode" % (protocol,host,port,web_root)
|
||||
|
|
|
@ -899,6 +899,13 @@ def import_subs(filename):
|
|||
except:
|
||||
logger.error("Failed to download subtitles for %s" %(filename), 'SUBTITLES')
|
||||
|
||||
def server_responding(baseURL):
|
||||
try:
|
||||
requests.get(baseURL, timeout=60)
|
||||
return True
|
||||
except (requests.ConnectionError, requests.exceptions.Timeout):
|
||||
return False
|
||||
|
||||
def backupVersionedFile(old_file, version):
|
||||
numTries = 0
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import re
|
|||
import nzbtomedia
|
||||
from nzbtomedia.nzbToMediaAutoFork import autoFork
|
||||
from nzbtomedia import nzbToMediaDB
|
||||
from nzbtomedia.nzbToMediaUtil import get_downloadInfo
|
||||
from nzbtomedia.nzbToMediaUtil import get_downloadInfo, server_responding
|
||||
|
||||
# Initialize the config
|
||||
nzbtomedia.initialize()
|
||||
|
@ -15,6 +15,17 @@ section = nzbtomedia.CFG.findsection('tv').isenabled()
|
|||
print section
|
||||
fork, fork_params = autoFork('SickBeard', 'tv')
|
||||
|
||||
if server_responding("http://127.0.0.1:5050"):
|
||||
print "CouchPotato Running"
|
||||
if server_responding("http://127.0.0.1:7073"):
|
||||
print "SickBeard Running"
|
||||
if server_responding("http://127.0.0.1:8181"):
|
||||
print "HeadPhones Running"
|
||||
if server_responding("http://127.0.0.1:8085"):
|
||||
print "Gamez Running"
|
||||
if server_responding("http://127.0.0.1:8090"):
|
||||
print "Mylar Running"
|
||||
|
||||
from babelfish import Language
|
||||
print Language('eng')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue