cleaned code

This commit is contained in:
galgolan 2016-09-05 03:04:33 +03:00
parent c4bf94acb1
commit fc3ccb6802
1 changed files with 6 additions and 7 deletions

View File

@ -19,8 +19,6 @@ import os
import re import re
import sys import sys
import math import math
import gzip
from StringIO import StringIO
import signal import signal
import socket import socket
import requests import requests
@ -203,7 +201,7 @@ def build_user_agent():
'speedtest-cli/%s' % __version__ 'speedtest-cli/%s' % __version__
) )
user_agent = ' '.join(ua_tuple) user_agent = ' '.join(ua_tuple)
return 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36' return user_agent
def build_request(url, data=None, headers={}): def build_request(url, data=None, headers={}):
@ -379,12 +377,13 @@ def getConfig():
""" """
uh = requests.get('http://www.speedtest.net/speedtest-config.php', headers = {'user-agent':user_agent}) uh = requests.get('http://www.speedtest.net/speedtest-config.php', headers = {'user-agent':user_agent})
configxml = [] configxml = uh.text
configxml.append(uh.text)
uh.close() if(int(uh.status_code) != 200):
return None
try: try:
try: try:
#print_(configxml)
root = ET.fromstring(''.encode().join(configxml)) root = ET.fromstring(''.encode().join(configxml))
config = { config = {
'client': root.find('client').attrib, 'client': root.find('client').attrib,