When using --mini and no extension is found, try all of the standard upload extensions. Fixes #62

This commit is contained in:
Matt Martz 2014-04-17 16:13:55 -05:00
parent 3e9c6e3532
commit 23fba2520a
1 changed files with 13 additions and 0 deletions

View File

@ -543,6 +543,19 @@ def speedtest():
text = f.read() text = f.read()
f.close() f.close()
extension = re.findall('upload_extension: "([^"]+)"', text.decode()) extension = re.findall('upload_extension: "([^"]+)"', text.decode())
if not extension:
for ext in ['php', 'asp', 'aspx', 'jsp']:
try:
f = urlopen('%s/speedtest/upload.%s' % (args.mini, ext))
except:
pass
else:
data = f.read().strip()
if (f.code == 200 and
len(data.splitlines()) == 1 and
re.match('size=[0-9]', data)):
extension = [ext]
break
if not urlparts or not extension: if not urlparts or not extension:
print_('Please provide the full URL of your Speedtest Mini server') print_('Please provide the full URL of your Speedtest Mini server')
sys.exit(1) sys.exit(1)