aboutsummaryrefslogtreecommitdiff
path: root/wrap.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-02-02 20:51:22 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2015-02-02 20:51:22 +0200
commit5a21b37149165661eb4389b7e7caf91f81f35b22 (patch)
tree7986eae5b19b608efcf50714581f5b87f3ecd281 /wrap.py
parentf23e6c72f4b4e1805af02245d816cbccdbf7d619 (diff)
downloadmeson-5a21b37149165661eb4389b7e7caf91f81f35b22.zip
meson-5a21b37149165661eb4389b7e7caf91f81f35b22.tar.gz
meson-5a21b37149165661eb4389b7e7caf91f81f35b22.tar.bz2
Logging fix.
Diffstat (limited to 'wrap.py')
-rw-r--r--wrap.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/wrap.py b/wrap.py
index 4402cba..2c3e087 100644
--- a/wrap.py
+++ b/wrap.py
@@ -13,7 +13,7 @@
# limitations under the License.
import mlog
-import glob, urllib.request, os, hashlib, shutil
+import urllib.request, os, hashlib, shutil
class PackageDefinition:
def __init__(self, fname):
@@ -46,6 +46,8 @@ class Resolver:
fname = os.path.join(self.subdir_root, packagename + '.wrap')
if not os.path.isfile(fname):
return None
+ if not os.path.isdir(self.cachedir):
+ os.mkdir(self.cachedir)
p = PackageDefinition(fname)
self.download(p, packagename)
self.extract_package(p)
@@ -63,30 +65,29 @@ class Resolver:
def download(self, p, packagename):
ofname = os.path.join(self.cachedir, p.get('source_filename'))
if os.path.exists(ofname):
- print('Using', packagename, 'from cache.')
+ mlog.log('Using', mlog.bold(packagename), 'from cache.')
return
srcurl = p.get('source_url')
- print('Dowloading', packagename, 'from', srcurl)
+ mlog.log('Dowloading', mlog.bold(packagename), 'from', srcurl)
(srcdata, dhash) = self.get_data(srcurl)
expected = p.get('source_hash')
if dhash != expected:
raise RuntimeError('Incorrect hash for source %s:\n %s expected\n %s actual.' % (packagename, expected, dhash))
if p.has_patch():
purl = p.get('patch_url')
- print('Downloading patch from', purl)
+ mlog.log('Downloading patch from', mlog.bold(purl))
(pdata, phash) = self.get_data(purl)
expected = p.get('patch_hash')
if phash != expected:
raise RuntimeError('Incorrect hash for patch %s:\n %s expected\n %s actual.' % (packagename, expected, phash))
open(os.path.join(self.cachedir, p.get('patch_filename')), 'wb').write(pdata)
else:
- print('Package does not require patch.')
+ mlog.log('Package does not require patch.')
open(ofname, 'wb').write(srcdata)
def extract_package(self, package):
if os.path.isdir(os.path.join(self.subdir_root, package.get('directory'))):
return
- print(os.path.join(self.cachedir, package.get('source_filename')))
shutil.unpack_archive(os.path.join(self.cachedir, package.get('source_filename')), self.subdir_root)
if package.has_patch():
shutil.unpack_archive(os.path.join(self.cachedir, package.get('patch_filename')), self.subdir_root)