Skip to content

Commit c4760e7

Browse files
author
y-p
committed
BLD: fix travis caching on py3
1 parent 4b66c6b commit c4760e7

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

ci/ironcache/get.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,32 @@
99
import base64
1010
from hashlib import sha1
1111
from iron_cache import *
12+
import traceback as tb
1213

1314
key='KEY.%s.%s' %(os.environ.get('TRAVIS_REPO_SLUG','unk'),
1415
os.environ.get('JOB_NAME','unk'))
16+
print(key)
17+
1518
if sys.version_info[0] > 2:
16-
key = sha1(bytes(key,encoding='utf8')).hexdigest()[:8]+'.'
17-
else:
18-
key = sha1(key).hexdigest()[:8]+'.'
19+
key = bytes(key,encoding='utf8')
20+
21+
key = sha1(key).hexdigest()[:8]+'.'
1922

2023
b = b''
2124
cache = IronCache()
2225
for i in range(20):
2326
print("getting %s" % key+str(i))
2427
try:
2528
item = cache.get(cache="travis", key=key+str(i))
26-
b += bytes(base64.b64decode(item.value))
27-
except:
29+
v = item.value
30+
if sys.version_info[0] > 2:
31+
v = bytes(v,encoding='utf8')
32+
b += bytes(base64.b64decode(v))
33+
except Exception as e:
34+
try:
35+
print(tb.format_exc(e))
36+
except:
37+
print("exception during exception, oh my")
2838
break
2939

3040
with open(os.path.join(os.environ.get('HOME',''),"ccache.7z"),'wb') as f:

ci/ironcache/put.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212

1313
key='KEY.%s.%s' %(os.environ.get('TRAVIS_REPO_SLUG','unk'),
1414
os.environ.get('JOB_NAME','unk'))
15+
16+
key='KEY.%s.%s' %(os.environ.get('TRAVIS_REPO_SLUG','unk'),
17+
os.environ.get('JOB_NAME','unk'))
18+
print(key)
19+
1520
if sys.version_info[0] > 2:
16-
key = sha1(bytes(key,encoding='utf8')).hexdigest()[:8]+'.'
17-
else:
18-
key = sha1(key).hexdigest()[:8]+'.'
21+
key = bytes(key,encoding='utf8')
22+
23+
key = sha1(key).hexdigest()[:8]+'.'
1924

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

0 commit comments

Comments
 (0)