Merge branch 'misc/tar-python' of git://github.com/ibmibmibm/MPD

This commit is contained in:
Max Kellermann 2020-06-10 17:54:22 +02:00
commit 96a273bf3b
1 changed files with 7 additions and 1 deletions

View File

@ -7,5 +7,11 @@ def untar(tarball_path, parent_path, base):
except FileNotFoundError:
pass
os.makedirs(parent_path, exist_ok=True)
subprocess.check_call(['/bin/tar', 'xfC', tarball_path, parent_path])
try:
subprocess.check_call(['/bin/tar', 'xfC', tarball_path, parent_path])
except FileNotFoundError:
import tarfile
tar = tarfile.open(tarball_path)
tar.extractall(path=parent_path)
tar.close()
return path