Skip to content

Commit

Permalink
BLD: fix travis caching on py3
Browse files Browse the repository at this point in the history
  • Loading branch information
y-p committed Feb 2, 2014
1 parent 4b66c6b commit c4760e7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
20 changes: 15 additions & 5 deletions ci/ironcache/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,32 @@
import base64
from hashlib import sha1
from iron_cache import *
import traceback as tb

key='KEY.%s.%s' %(os.environ.get('TRAVIS_REPO_SLUG','unk'),
os.environ.get('JOB_NAME','unk'))
print(key)

if sys.version_info[0] > 2:
key = sha1(bytes(key,encoding='utf8')).hexdigest()[:8]+'.'
else:
key = sha1(key).hexdigest()[:8]+'.'
key = bytes(key,encoding='utf8')

key = sha1(key).hexdigest()[:8]+'.'

b = b''
cache = IronCache()
for i in range(20):
print("getting %s" % key+str(i))
try:
item = cache.get(cache="travis", key=key+str(i))
b += bytes(base64.b64decode(item.value))
except:
v = item.value
if sys.version_info[0] > 2:
v = bytes(v,encoding='utf8')
b += bytes(base64.b64decode(v))
except Exception as e:
try:
print(tb.format_exc(e))
except:
print("exception during exception, oh my")
break

with open(os.path.join(os.environ.get('HOME',''),"ccache.7z"),'wb') as f:
Expand Down
11 changes: 8 additions & 3 deletions ci/ironcache/put.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@

key='KEY.%s.%s' %(os.environ.get('TRAVIS_REPO_SLUG','unk'),
os.environ.get('JOB_NAME','unk'))

key='KEY.%s.%s' %(os.environ.get('TRAVIS_REPO_SLUG','unk'),
os.environ.get('JOB_NAME','unk'))
print(key)

if sys.version_info[0] > 2:
key = sha1(bytes(key,encoding='utf8')).hexdigest()[:8]+'.'
else:
key = sha1(key).hexdigest()[:8]+'.'
key = bytes(key,encoding='utf8')

key = sha1(key).hexdigest()[:8]+'.'

os.chdir(os.environ.get('HOME'))

Expand Down

0 comments on commit c4760e7

Please sign in to comment.