def TestDownload(self):
try:
a = datetime.now()
info('Excuting regular download test for network speed')
url = self.config.cloudConfig.DownloadSpeedTestUrl if 'DownloadSpeedTestUrl' in self.config.cloudConfig else defaultUrl
debug(url + ' ' + download_path)
request.urlretrieve(url, download_path)
request.urlcleanup()
b = datetime.now()
c = b - a
if path.exists(download_path):
size = path.getsize(download_path)/mb
self.downloadSpeed = size/c.total_seconds()
remove(download_path)
return True
except socket_error as serr:
error ('TestDownload:' + str(serr))
ret = False
Daemon.OnFailure('cloud', serr.errno)
return
except:
exception('TestDownload Failed')
return False
评论列表
文章目录