Skip to content
This repository has been archived by the owner on Aug 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #96 from martindurant/absolute_env
Browse files Browse the repository at this point in the history
Fix for env not within usual directory
  • Loading branch information
martindurant committed Oct 13, 2017
2 parents f7d069d + a7527b0 commit 717dbd4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 8 additions & 3 deletions knit/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,20 @@ def zip_env(self, env_path):
zFile = os.path.join(env_dir, fname)

# ZipFile does not have a contextmanager in Python 2.6
f = zipfile.ZipFile(zFile, 'w')
f = zipfile.ZipFile(zFile, 'w', allowZip64=True)
try:
logger.info('Creating: %s' % zFile)
for root, dirs, files in os.walk(env_path):
for file in files:
relfile = os.path.join(
os.path.relpath(root, self.conda_envs), file)
os.path.relpath(root, env_dir), file)
absfile = os.path.join(root, file)
try:
os.stat(absfile)
except OSError:
logger.info('Skipping zip for %s' % absfile)
continue
f.write(absfile, relfile)
return zFile

finally:
f.close()
5 changes: 3 additions & 2 deletions knit/yarn_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def app_attempts(self, app_id):
r = requests.get(self.url + 'cluster/apps/{}/appattempts'.format(
app_id), timeout=self.timeout)
self._verify_response(r)
return r.json()['appAttempts']['appAttempt']
return r.json().get('appAttempts', {'app_attempt': []})['appAttempt']

def app_containers(self, app_id=None, info=None):
"""
Expand Down Expand Up @@ -259,7 +259,8 @@ def kill(self, app_id):
def _verify_response(self, r):
if not r.ok:
try:
raise YARNException(r.json()['RemoteException']['message'])
ex = r.json()['RemoteException']
raise YARNException(ex.get('message', str(ex)))
except (ValueError, IndexError):
raise YARNException(r.text)

Expand Down

0 comments on commit 717dbd4

Please sign in to comment.