Update to latest version of pake, fixes #87, thanks @cedricmoullet and @AugustusKling
This commit is contained in:
@@ -18,6 +18,27 @@ import urllib2
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
if hasattr(subprocess, 'check_output'):
|
||||||
|
check_output = subprocess.check_output
|
||||||
|
else:
|
||||||
|
# Copied with minor modifications from the Python source code
|
||||||
|
# http://hg.python.org/cpython/file/9cb1366b251b/Lib/subprocess.py#l549
|
||||||
|
def check_output(*popenargs, **kwargs):
|
||||||
|
if 'stdout' in kwargs:
|
||||||
|
raise ValueError(
|
||||||
|
'stdout argument not allowed, it will be overridden.')
|
||||||
|
process = subprocess.Popen(stdout=subprocess.PIPE,
|
||||||
|
*popenargs, **kwargs)
|
||||||
|
output, unused_err = process.communicate()
|
||||||
|
retcode = process.poll()
|
||||||
|
if retcode:
|
||||||
|
cmd = kwargs.get("args")
|
||||||
|
if cmd is None:
|
||||||
|
cmd = popenargs[0]
|
||||||
|
raise subprocess.CalledProcessError(retcode, cmd, output=output)
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
class PakeError(RuntimeError):
|
class PakeError(RuntimeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -130,7 +151,7 @@ class Target(object):
|
|||||||
def download(self, url, md5=None):
|
def download(self, url, md5=None):
|
||||||
content = urllib2.urlopen(url).read()
|
content = urllib2.urlopen(url).read()
|
||||||
if md5 and hashlib.md5(content).hexdigest() != md5:
|
if md5 and hashlib.md5(content).hexdigest() != md5:
|
||||||
raise pake.BuildError(t, 'corrupt download')
|
raise BuildError(self, 'corrupt download')
|
||||||
# FIXME Python on Windoze corrupts the content when writing it
|
# FIXME Python on Windoze corrupts the content when writing it
|
||||||
# FIXME probably something to do with encodings
|
# FIXME probably something to do with encodings
|
||||||
with open(self.name, 'w') as f:
|
with open(self.name, 'w') as f:
|
||||||
@@ -161,7 +182,7 @@ class Target(object):
|
|||||||
args = flatten_expand_list(args)
|
args = flatten_expand_list(args)
|
||||||
self.info(' '.join(args))
|
self.info(' '.join(args))
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(args, **kwargs)
|
output = check_output(args, **kwargs)
|
||||||
with open(self.name, 'w') as f:
|
with open(self.name, 'w') as f:
|
||||||
f.write(output)
|
f.write(output)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
@@ -316,7 +337,7 @@ def main(argv=sys.argv):
|
|||||||
def output(*args):
|
def output(*args):
|
||||||
args = flatten_expand_list(args)
|
args = flatten_expand_list(args)
|
||||||
logger.debug(' '.join(args))
|
logger.debug(' '.join(args))
|
||||||
return subprocess.check_output(args)
|
return check_output(args)
|
||||||
|
|
||||||
|
|
||||||
def rule(pattern):
|
def rule(pattern):
|
||||||
|
|||||||
Reference in New Issue
Block a user