Skip to content

Commit

Permalink
Merge pull request #1085 from kapicorp/revert-1083-fix/libmagic-impor…
Browse files Browse the repository at this point in the history
…t-error

Revert "fix: import libmagic only when its needed"
  • Loading branch information
ademariag authored Nov 11, 2023
2 parents 413bde0 + 74baa0d commit 89ebfb2
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions kapitan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import collections
import json
import logging
import magic
import math
import os
import re
Expand Down Expand Up @@ -531,14 +532,6 @@ def make_request(source):
def unpack_downloaded_file(file_path, output_path, content_type):
"""unpacks files of various MIME type and stores it to the output_path"""

try:
import magic
except ImportError:
logger.error(
"Error with unpacking content: libmagic is not installed. Install it with 'apt install libmagic1' or 'apk|brew install libmagic'"
)
sys.exit(1)

if content_type == None or content_type == "application/octet-stream":
if re.search(r"^Zip archive data.*", magic.from_file(file_path)):
content_type = "application/zip"
Expand Down

0 comments on commit 89ebfb2

Please sign in to comment.