You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by lp...@apache.org on 2017/08/29 13:25:39 UTC
[36/50] [abbrv] ambari git commit: AMBARI-21812. Installing mpack
with .tgz extension fails with global name 'path' is not defined (amagyar)
AMBARI-21812. Installing mpack with .tgz extension fails with global name 'path' is not defined (amagyar)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2d56dcb6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2d56dcb6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2d56dcb6
Branch: refs/heads/feature-branch-AMBARI-21307
Commit: 2d56dcb6c06cce42e5f50427a51c551f7dc667a1
Parents: 91155b1
Author: Attila Magyar <am...@hortonworks.com>
Authored: Tue Aug 29 09:33:07 2017 +0200
Committer: Attila Magyar <am...@hortonworks.com>
Committed: Tue Aug 29 09:33:07 2017 +0200
----------------------------------------------------------------------
.../libraries/functions/tar_archive.py | 24 ++++++++------------
1 file changed, 10 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2d56dcb6/ambari-common/src/main/python/resource_management/libraries/functions/tar_archive.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/tar_archive.py b/ambari-common/src/main/python/resource_management/libraries/functions/tar_archive.py
index c682c3e..e6d8924 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/tar_archive.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/tar_archive.py
@@ -57,25 +57,21 @@ def untar_archive(archive, directory):
)
def extract_archive(archive, directory):
- if archive.endswith('.tar.gz') or path.endswith('.tgz'):
- mode = 'r:gz'
- elif archive.endswith('.tar.bz2') or path.endswith('.tbz'):
- mode = 'r:bz2'
- else:
- raise ValueError, "Could not extract `%s` as no appropriate extractor is found" % path
- with closing(tarfile.open(archive, mode)) as tar:
+ with closing(tarfile.open(archive, mode(archive))) as tar:
tar.extractall(directory)
def get_archive_root_dir(archive):
- if archive.endswith('.tar.gz') or path.endswith('.tgz'):
- mode = 'r:gz'
- elif archive.endswith('.tar.bz2') or path.endswith('.tbz'):
- mode = 'r:bz2'
- else:
- raise ValueError, "Could not extract `%s` as no appropriate extractor is found" % path
root_dir = None
- with closing(tarfile.open(archive, mode)) as tar:
+ with closing(tarfile.open(archive, mode(archive))) as tar:
names = tar.getnames()
if names:
root_dir = os.path.commonprefix(names)
return root_dir
+
+def mode(archive):
+ if archive.endswith('.tar.gz') or archive.endswith('.tgz'):
+ return 'r:gz'
+ elif archive.endswith('.tar.bz2') or archive.endswith('.tbz'):
+ return 'r:bz2'
+ else:
+ raise ValueError("Could not extract `%s` as no appropriate extractor is found" % archive)
\ No newline at end of file