Browse Source

Add opener to env

pull/3423/head
Ruud 11 years ago
parent
commit
f0daee669b
  1. 3
      couchpotato/core/plugins/base.py
  2. 3
      couchpotato/environment.py
  3. 2
      couchpotato/runner.py

3
couchpotato/core/plugins/base.py

@ -40,7 +40,6 @@ class Plugin(object):
http_time_between_calls = 0
http_failed_request = {}
http_failed_disabled = {}
http_opener = requests.Session()
def __new__(cls, *args, **kwargs):
new_plugin = super(Plugin, cls).__new__(cls)
@ -184,7 +183,7 @@ class Plugin(object):
headers['Connection'] = headers.get('Connection', 'keep-alive')
headers['Cache-Control'] = headers.get('Cache-Control', 'max-age=0')
r = self.http_opener
r = Env.get('http_opener')
# Don't try for failed requests
if self.http_failed_disabled.get(host, 0) > 0:

3
couchpotato/environment.py

@ -24,8 +24,7 @@ class Env(object):
_quiet = False
_daemonized = False
_desktop = None
_engine = None
_session = None
_http_opener = None
''' Data paths and directories '''
_app_dir = ""

2
couchpotato/runner.py

@ -18,6 +18,7 @@ from couchpotato.api import NonBlockHandler, ApiHandler
from couchpotato.core.event import fireEventAsync, fireEvent
from couchpotato.core.helpers.encoding import sp
from couchpotato.core.helpers.variable import getDataDir, tryInt
import requests
from tornado.httpserver import HTTPServer
from tornado.web import Application, StaticFileHandler, RedirectHandler
@ -141,6 +142,7 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
Env.set('data_dir', sp(data_dir))
Env.set('log_path', sp(os.path.join(log_dir, 'CouchPotato.log')))
Env.set('db', db)
Env.set('http_opener', requests.Session())
Env.set('cache_dir', cache_dir)
Env.set('cache', FileSystemCache(python_cache))
Env.set('console_log', options.console_log)

Loading…
Cancel
Save