1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-07-17 12:33:28 +01:00

Adding an HTTP-based resource getter.

This commit is contained in:
Sergei Trofimov
2015-09-03 13:32:54 +01:00
parent 047308a904
commit bfed59a7cf
4 changed files with 175 additions and 14 deletions
setup.py
wlauto
core
resource_getters
utils

@ -32,6 +32,7 @@ import pkgutil
import traceback
import logging
import random
import hashlib
from datetime import datetime, timedelta
from operator import mul, itemgetter
from StringIO import StringIO
@ -799,3 +800,18 @@ def mask_to_list(mask):
size = len(bin(mask)) - 2 # because of "0b"
return [size - i - 1 for i in xrange(size)
if mask & (1 << size - i - 1)]
def sha256(path, chunk=2048):
"""Calculates SHA256 hexdigest of the file at the specified path."""
h = hashlib.sha256()
with open(path, 'rb') as fh:
buf = fh.read(chunk)
while buf:
h.update(buf)
buf = fh.read(chunk)
return h.hexdigest()
def urljoin(*parts):
return '/'.join(p.rstrip('/') for p in parts)