revert some unneeded urlopen expansions
This commit is contained in:
parent
8265419ac1
commit
0758d5a75d
|
@ -188,8 +188,7 @@ class FileGetter(threading.Thread):
|
||||||
self.result = [0]
|
self.result = [0]
|
||||||
try:
|
try:
|
||||||
if (time.time() - self.starttime) <= 10:
|
if (time.time() - self.starttime) <= 10:
|
||||||
req = Request(self.url)
|
f = urlopen(self.url)
|
||||||
f = urlopen(req)
|
|
||||||
while 1 and not shutdown_event.isSet():
|
while 1 and not shutdown_event.isSet():
|
||||||
self.result.append(len(f.read(10240)))
|
self.result.append(len(f.read(10240)))
|
||||||
if self.result[-1] == 0:
|
if self.result[-1] == 0:
|
||||||
|
@ -253,8 +252,7 @@ class FilePutter(threading.Thread):
|
||||||
try:
|
try:
|
||||||
if ((time.time() - self.starttime) <= 10 and
|
if ((time.time() - self.starttime) <= 10 and
|
||||||
not shutdown_event.isSet()):
|
not shutdown_event.isSet()):
|
||||||
req = Request(self.url)
|
f = urlopen(self.url, self.data)
|
||||||
f = urlopen(req, self.data)
|
|
||||||
f.read(11)
|
f.read(11)
|
||||||
f.close()
|
f.close()
|
||||||
self.result = len(self.data)
|
self.result = len(self.data)
|
||||||
|
@ -317,8 +315,7 @@ def getConfig():
|
||||||
we are interested in
|
we are interested in
|
||||||
"""
|
"""
|
||||||
|
|
||||||
req = Request('http://www.speedtest.net/speedtest-config.php')
|
uh = urlopen('http://www.speedtest.net/speedtest-config.php')
|
||||||
uh = urlopen(req)
|
|
||||||
configxml = []
|
configxml = []
|
||||||
while 1:
|
while 1:
|
||||||
configxml.append(uh.read(10240))
|
configxml.append(uh.read(10240))
|
||||||
|
@ -351,8 +348,7 @@ def closestServers(client, all=False):
|
||||||
distance
|
distance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
req = Request('http://www.speedtest.net/speedtest-servers.php')
|
uh = urlopen('http://www.speedtest.net/speedtest-servers.php')
|
||||||
uh = urlopen(req)
|
|
||||||
serversxml = []
|
serversxml = []
|
||||||
while 1:
|
while 1:
|
||||||
serversxml.append(uh.read(10240))
|
serversxml.append(uh.read(10240))
|
||||||
|
@ -409,8 +405,7 @@ def getBestServer(servers):
|
||||||
url = os.path.dirname(server['url'])
|
url = os.path.dirname(server['url'])
|
||||||
for i in range(0, 3):
|
for i in range(0, 3):
|
||||||
try:
|
try:
|
||||||
req = Request('%s/latency.txt' % url)
|
uh = urlopen('%s/latency.txt' % url)
|
||||||
uh = urlopen(req)
|
|
||||||
except (HTTPError, URLError):
|
except (HTTPError, URLError):
|
||||||
cum.append(3600)
|
cum.append(3600)
|
||||||
continue
|
continue
|
||||||
|
@ -593,8 +588,7 @@ def speedtest():
|
||||||
url = args.mini
|
url = args.mini
|
||||||
urlparts = urlparse(url)
|
urlparts = urlparse(url)
|
||||||
try:
|
try:
|
||||||
req = Request(args.mini)
|
f = urlopen(args.mini)
|
||||||
f = urlopen(req)
|
|
||||||
except:
|
except:
|
||||||
print_('Invalid Speedtest Mini URL')
|
print_('Invalid Speedtest Mini URL')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in New Issue