Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[6c2c92]: plugin.video.vine / proxyconfig.py Maximize Restore History

Download this file

proxyconfig.py    59 lines (43 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sys
import urllib2
import httplib
import socks
class ProxyConfig:
def __init__(self, type, server, port, dns = True, user = None, password = None):
self.server = server
self.type = type
self.port = port
self.user = user
self.password = password
self.dns = dns
self.urllib2_socket = None
self.httplib_socket = None
#==============================================================================
def Enable(self):
self.urllib2_socket = None
self.httplib_socket = None
log = sys.modules[u"__main__"].log
try:
log(u"Using proxy: type %i rdns: %i server: %s port: %s user: %s pass: %s" % (self.type, self.dns, self.server, self.port, u"***", u"***") )
self.urllib2_socket = urllib2.socket.socket
self.httplib_socket = httplib.socket.socket
socks.setdefaultproxy(self.type, self.server, self.port, self.dns, self.user, self.password)
socks.wrapmodule(urllib2)
socks.wrapmodule(httplib)
except ( Exception ) as exception:
log(u"Error processing proxy settings", xbmc.LOGERROR)
log(u"Exception: " + exception.me, xbmc.LOGERROR)
def Disable(self):
if self.urllib2_socket is not None:
urllib2.socket.socket = self.urllib2_socket
if self.httplib_socket is not None:
httplib.socket.socket = self.httplib_socket
self.urllib2_socket = None
self.httplib_socket = None
def toString(self):
#string = ""
#if self.user is not None and self.password is not None:
# string = "%s:%s@" % (self.user, self.password)
#string = string + "%s:%s" % (self.server, self.port)
string = u"%s:%s" % (self.server, self.port)
return string