mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 13:53:15 -07:00
parent
c07745d79c
commit
8570a6bfc8
7 changed files with 28 additions and 24 deletions
|
@ -18,7 +18,6 @@ APP_NAME = os.path.basename(APP_FILENAME)
|
|||
LOG_DIR = os.path.join(PROGRAM_DIR, 'logs')
|
||||
LOG_FILE = os.path.join(LOG_DIR, 'nzbtomedia.log')
|
||||
PID_FILE = os.path.join(LOG_DIR, 'nzbtomedia.pid')
|
||||
LOCK_SOCKET = None
|
||||
CONFIG_FILE = os.path.join(PROGRAM_DIR, 'autoProcessMedia.cfg')
|
||||
CONFIG_SPEC_FILE = os.path.join(PROGRAM_DIR, 'autoProcessMedia.cfg.spec')
|
||||
CONFIG_MOVIE_FILE = os.path.join(PROGRAM_DIR, 'autoProcessMovie.cfg')
|
||||
|
@ -199,7 +198,7 @@ def initialize(section=None):
|
|||
TRANSMISSIONHOST, TRANSMISSIONPORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \
|
||||
METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \
|
||||
__INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \
|
||||
GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, LOCK_SOCKET, \
|
||||
GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \
|
||||
DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \
|
||||
VFRAMERATE, LOG_DB, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, \
|
||||
ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \
|
||||
|
|
|
@ -58,7 +58,7 @@ class autoProcessComics:
|
|||
|
||||
logger.debug("Opening URL: %s" % (url), section)
|
||||
try:
|
||||
r = requests.get(url, auth=(username, password), params=params, stream=True, verify=False)
|
||||
r = requests.get(url, auth=(username, password), params=params, stream=True, verify=False, timeout=(30, 300))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL", section)
|
||||
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
|
||||
|
|
|
@ -54,7 +54,7 @@ class autoProcessGames:
|
|||
logger.debug("Opening URL: %s" % (url),section)
|
||||
|
||||
try:
|
||||
r = requests.get(url, params=params, verify=False)
|
||||
r = requests.get(url, params=params, verify=False, timeout=(30, 300))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL")
|
||||
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
|
||||
|
|
|
@ -26,7 +26,7 @@ class autoProcessMovie:
|
|||
logger.debug("Opening URL: %s with PARAMS: %s" % (url, params))
|
||||
|
||||
try:
|
||||
r = requests.get(url, params=params, verify=False)
|
||||
r = requests.get(url, params=params, verify=False, timeout=(30, 60))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL %s" % url)
|
||||
return results
|
||||
|
@ -234,7 +234,7 @@ class autoProcessMovie:
|
|||
logger.postprocess("Starting %s scan for %s" % (method, inputName), section)
|
||||
|
||||
try:
|
||||
r = requests.get(url, params=params, verify=False)
|
||||
r = requests.get(url, params=params, verify=False, timeout=(30, 1800))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL", section)
|
||||
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
|
||||
|
@ -275,7 +275,7 @@ class autoProcessMovie:
|
|||
logger.debug("Opening URL: %s with PARAMS: %s" % (url, params), section)
|
||||
|
||||
try:
|
||||
r = requests.get(url, params=params, verify=False)
|
||||
r = requests.get(url, params=params, verify=False, timeout=(30, 120))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL %s" % (url), section)
|
||||
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
|
||||
|
@ -296,7 +296,7 @@ class autoProcessMovie:
|
|||
logger.debug("Opening URL: %s" % (url), section)
|
||||
|
||||
try:
|
||||
r = requests.get(url, params={'media_id': media_id}, verify=False)
|
||||
r = requests.get(url, params={'media_id': media_id}, verify=False, timeout=(30, 600))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL %s" % (url), section)
|
||||
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
|
||||
|
|
|
@ -18,7 +18,7 @@ class autoProcessMusic:
|
|||
logger.debug("Opening URL: %s with PARAMS: %s" % (url, params))
|
||||
|
||||
try:
|
||||
r = requests.get(url, params=params, verify=False)
|
||||
r = requests.get(url, params=params, verify=False, timeout=(30, 120))
|
||||
except Exception, e:
|
||||
logger.error("Unable to open URL")
|
||||
return None
|
||||
|
@ -106,7 +106,7 @@ class autoProcessMusic:
|
|||
logger.debug("Opening URL: %s with PARAMS: %s" % (url, params), section)
|
||||
|
||||
try:
|
||||
r = requests.get(url, params=params, verify=False)
|
||||
r = requests.get(url, params=params, verify=False, timeout=(30, 300))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL %s" % (url) ,section)
|
||||
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
|
||||
|
|
|
@ -16,7 +16,7 @@ class autoProcessTV:
|
|||
def command_complete(self, url, params, headers, section):
|
||||
r = None
|
||||
try:
|
||||
r = requests.get(url, params=params, headers=headers, stream=True, verify=False)
|
||||
r = requests.get(url, params=params, headers=headers, stream=True, verify=False, timeout=(30, 60))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL: %s" % (url1), section)
|
||||
return None
|
||||
|
@ -34,7 +34,7 @@ class autoProcessTV:
|
|||
def CDH(self, url2, headers):
|
||||
r = None
|
||||
try:
|
||||
r = requests.get(url2, params={}, headers=headers, stream=True, verify=False)
|
||||
r = requests.get(url2, params={}, headers=headers, stream=True, verify=False, timeout=(30, 60))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL: %s" % (url2), section)
|
||||
return False
|
||||
|
@ -269,12 +269,12 @@ class autoProcessTV:
|
|||
s = requests.Session()
|
||||
login = "%s%s:%s%s/login" % (protocol,host,port,web_root)
|
||||
login_params = {'username': username, 'password': password}
|
||||
s.post(login, data=login_params, stream=True, verify=False)
|
||||
r = s.get(url, auth=(username, password), params=fork_params, stream=True, verify=False)
|
||||
s.post(login, data=login_params, stream=True, verify=False, timeout=(30, 60))
|
||||
r = s.get(url, auth=(username, password), params=fork_params, stream=True, verify=False, timeout=(30, 1800))
|
||||
elif section == "NzbDrone":
|
||||
logger.debug("Opening URL: %s with data: %s" % (url, str(data)), section)
|
||||
r = None
|
||||
r = requests.post(url, data=data, headers=headers, stream=True, verify=False)
|
||||
r = requests.post(url, data=data, headers=headers, stream=True, verify=False, timeout=(30, 1800))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL: %s" % (url), section)
|
||||
return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
|
||||
|
|
|
@ -32,7 +32,7 @@ def reportNzb(failure_link, clientAgent):
|
|||
else:
|
||||
return
|
||||
try:
|
||||
r = requests.post(failure_link, headers=headers)
|
||||
r = requests.post(failure_link, headers=headers, timeout=(30, 300))
|
||||
except Exception as e:
|
||||
logger.error("Unable to open URL %s due to %s" % (failure_link, e))
|
||||
return
|
||||
|
@ -802,7 +802,7 @@ def find_download(clientAgent, download_id):
|
|||
params['output'] = 'json'
|
||||
params['value'] = download_id
|
||||
try:
|
||||
r = requests.get(url, params=params, verify=False)
|
||||
r = requests.get(url, params=params, verify=False, timeout=(30, 120))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL")
|
||||
return False # failure
|
||||
|
@ -822,7 +822,7 @@ def get_nzoid(inputName):
|
|||
params['mode'] = "queue"
|
||||
params['output'] = 'json'
|
||||
try:
|
||||
r = requests.get(url, params=params, verify=False)
|
||||
r = requests.get(url, params=params, verify=False, timeout=(30, 120))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL")
|
||||
return nzoid # failure
|
||||
|
@ -964,7 +964,7 @@ def find_imdbid(dirName, inputName):
|
|||
logger.debug("Opening URL: %s" % url)
|
||||
|
||||
try:
|
||||
r = requests.get(url, params={'y': year, 't': title}, verify=False)
|
||||
r = requests.get(url, params={'y': year, 't': title}, verify=False, timeout=(60, 300))
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL %s" % url)
|
||||
return
|
||||
|
@ -1045,7 +1045,7 @@ def import_subs(filename):
|
|||
|
||||
def server_responding(baseURL):
|
||||
try:
|
||||
requests.get(baseURL, timeout=60, verify=False)
|
||||
requests.get(baseURL, timeout=(30, 60), verify=False)
|
||||
return True
|
||||
except (requests.ConnectionError, requests.exceptions.Timeout):
|
||||
return False
|
||||
|
@ -1141,15 +1141,18 @@ class PosixProcess():
|
|||
|
||||
def __init__(self):
|
||||
self.pidpath = nzbtomedia.PID_FILE
|
||||
self.lock_socket = None
|
||||
|
||||
def alreadyrunning(self):
|
||||
try:
|
||||
nzbtomedia.LOCK_SOCKET = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
||||
nzbtomedia.LOCK_SOCKET.bind('\0' + 'nzbtomedia')
|
||||
return False
|
||||
self.lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
||||
self.lock_socket.bind('\0' + self.pidpath)
|
||||
self.lasterror = False
|
||||
return self.lasterror
|
||||
except socket.error as e:
|
||||
if "Address already in use" in e:
|
||||
return True
|
||||
self.lasterror = True
|
||||
return self.lasterror
|
||||
except AttributeError: pass
|
||||
if os.path.exists(self.pidpath):
|
||||
# Make sure it is not a "stale" pidFile
|
||||
|
@ -1181,5 +1184,7 @@ class PosixProcess():
|
|||
|
||||
def __del__(self):
|
||||
if not self.lasterror:
|
||||
if self.lock_socket:
|
||||
self.lock_socket.close()
|
||||
if os.path.isfile(self.pidpath):
|
||||
os.unlink(self.pidpath)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue