import gzip
from time import sleep
from lib.command import Command
-from lib.tools import process, ProcessInThread
+from lib.tools import process, ProcessInThread, downloadProcessHook
class BehatCommand(Command):
selenium = re.search(r'http:[a-z0-9/._-]+selenium-server-standalone-[0-9.]+\.jar', content, re.I)
if selenium:
logging.info('Downloading Selenium from %s' % (selenium.group(0)))
- urllib.urlretrieve(selenium.group(0), seleniumPath)
+ if (logging.getLogger().level <= logging.INFO):
+ urllib.urlretrieve(selenium.group(0), seleniumPath, downloadProcessHook)
+ # Force a new line after the hook display
+ logging.info('')
+ else:
+ urllib.urlretrieve(selenium.group(0), seleniumPath)
else:
logging.warning('Could not locate Selenium server to download')
http://github.com/FMCorz/mdk
"""
+import sys
import os
import signal
import subprocess
return (proc.returncode, out, err)
+def downloadProcessHook(count, size, total):
+ """Hook to report the downloading a file using urllib.urlretrieve"""
+ downloaded = int((count * size) / (1024))
+ total = int(total / (1024)) if total != 0 else '?'
+ sys.stderr.write("\r %sKB / %sKB" % (downloaded, total))
+ sys.stderr.flush()
+
+
def stableBranch(version):
if version == 'master':
return 'master'