Merge pull request #228 from adam111316/feature/RemoveUnusedUrlOpeners

Remove unused SickBeardURLOpener and AuthURLOpener classes
This commit is contained in:
adam111316 2015-02-24 15:22:15 +08:00
commit ecc008c501
3 changed files with 3 additions and 51 deletions

View file

@ -4,6 +4,7 @@
* Remove unused libraries fuzzywuzzy and pysrt * Remove unused libraries fuzzywuzzy and pysrt
* Change webserve code to a logical layout and PEP8 * Change webserve code to a logical layout and PEP8
* Add text to explain params passed to extra scripts on Config/Post Processing * Add text to explain params passed to extra scripts on Config/Post Processing
* Remove unused SickBeardURLOpener and AuthURLOpener classes
[develop changelog] [develop changelog]

View file

@ -16,58 +16,11 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
import re import re
import datetime
import sickbeard import sickbeard
import urllib
import datetime
from lib.dateutil import parser from lib.dateutil import parser
from sickbeard.common import Quality
from common import USER_AGENT, Quality
class SickBeardURLopener(urllib.FancyURLopener):
version = USER_AGENT
class AuthURLOpener(SickBeardURLopener):
"""
URLOpener class that supports http auth without needing interactive password entry.
If the provided username/password don't work it simply fails.
user: username to use for HTTP auth
pw: password to use for HTTP auth
"""
def __init__(self, user, pw):
self.username = user
self.password = pw
# remember if we've tried the username/password before
self.numTries = 0
# call the base class
urllib.FancyURLopener.__init__(self)
def prompt_user_passwd(self, host, realm):
"""
Override this function and instead of prompting just give the
username/password that were provided when the class was instantiated.
"""
# if this is the first try then provide a username/password
if self.numTries == 0:
self.numTries = 1
return (self.username, self.password)
# if we've tried before then return blank which cancels the request
else:
return ('', '')
# this is pretty much just a hack for convenience
def openit(self, url):
self.numTries = 0
return SickBeardURLopener.open(self, url)
class SearchResult: class SearchResult:

View file

@ -65,8 +65,6 @@ from sickbeard import clients
from lib.cachecontrol import CacheControl, caches from lib.cachecontrol import CacheControl, caches
from itertools import izip, cycle from itertools import izip, cycle
urllib._urlopener = classes.SickBeardURLopener()
def indentXML(elem, level=0): def indentXML(elem, level=0):
''' '''