diff options
| author | Bryan Galdrikian <[email protected]> | 2018-05-31 11:36:08 -0700 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2018-05-31 11:36:08 -0700 |
| commit | 7115f60b91b5717d90f643fd692010905c7004db (patch) | |
| tree | effd68c6978751c517d54c2f2bb5bb6e7dc93e18 /buildtools/packman/win-bootstrap/install_package.py | |
| parent | Updating BlastTool zip (diff) | |
| download | blast-1.1.3_rc1.tar.xz blast-1.1.3_rc1.zip | |
Blast 1.1.3. See docs/release_notes.txt.v1.1.3_rc1
Diffstat (limited to 'buildtools/packman/win-bootstrap/install_package.py')
| -rwxr-xr-x[-rw-r--r--] | buildtools/packman/win-bootstrap/install_package.py | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/buildtools/packman/win-bootstrap/install_package.py b/buildtools/packman/win-bootstrap/install_package.py index 730962a..3aa294e 100644..100755 --- a/buildtools/packman/win-bootstrap/install_package.py +++ b/buildtools/packman/win-bootstrap/install_package.py @@ -1,39 +1,39 @@ -import logging -import zipfile -import tempfile -import sys -import shutil - -__author__ = 'hfannar' -logging.basicConfig(level=logging.WARNING, format="%(message)s") -logger = logging.getLogger('install_package') - - -class TemporaryDirectory: - def __init__(self): - self.path = None - - def __enter__(self): - self.path = tempfile.mkdtemp() - return self.path - - def __exit__(self, type, value, traceback ): - # Remove temporary data created - shutil.rmtree(self.path) - - -def install_package(package_src_path, package_dst_path): - with zipfile.ZipFile(package_src_path, allowZip64=True) as zip_file, TemporaryDirectory() as temp_dir: - zip_file.extractall(temp_dir) - # Recursively copy (temp_dir will be automatically cleaned up on exit) - try: - # Recursive copy is needed because both package name and version folder could be missing in - # target directory: - shutil.copytree(temp_dir, package_dst_path) - except OSError, exc: - logger.warning("Directory %s already present, packaged installation aborted" % package_dst_path) - else: - logger.info("Package successfully installed to %s" % package_dst_path) - - +import logging
+import zipfile
+import tempfile
+import sys
+import shutil
+
+__author__ = 'hfannar'
+logging.basicConfig(level=logging.WARNING, format="%(message)s")
+logger = logging.getLogger('install_package')
+
+
+class TemporaryDirectory:
+ def __init__(self):
+ self.path = None
+
+ def __enter__(self):
+ self.path = tempfile.mkdtemp()
+ return self.path
+
+ def __exit__(self, type, value, traceback ):
+ # Remove temporary data created
+ shutil.rmtree(self.path)
+
+
+def install_package(package_src_path, package_dst_path):
+ with zipfile.ZipFile(package_src_path, allowZip64=True) as zip_file, TemporaryDirectory() as temp_dir:
+ zip_file.extractall(temp_dir)
+ # Recursively copy (temp_dir will be automatically cleaned up on exit)
+ try:
+ # Recursive copy is needed because both package name and version folder could be missing in
+ # target directory:
+ shutil.copytree(temp_dir, package_dst_path)
+ except OSError, exc:
+ logger.warning("Directory %s already present, packaged installation aborted" % package_dst_path)
+ else:
+ logger.info("Package successfully installed to %s" % package_dst_path)
+
+
install_package(sys.argv[1], sys.argv[2])
\ No newline at end of file |