Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/extractcode/libarchive2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import mmap
import os

import ctypes.util
from ctypes import c_char_p, c_wchar_p
from ctypes import c_int, c_longlong
from ctypes import c_size_t, c_ssize_t
Expand Down Expand Up @@ -85,6 +86,7 @@
# keys for plugin-provided locations
EXTRACTCODE_LIBARCHIVE_LIBDIR = 'extractcode.libarchive.libdir'
EXTRACTCODE_LIBARCHIVE_DLL = 'extractcode.libarchive.dll'
_LIBRARY_NAME = 'libarchive'


def load_lib():
Expand All @@ -96,11 +98,17 @@ def load_lib():
dll = get_location(EXTRACTCODE_LIBARCHIVE_DLL)
libdir = get_location(EXTRACTCODE_LIBARCHIVE_LIBDIR)
if not (dll and libdir) or not os.path.isfile(dll) or not os.path.isdir(libdir):
raise Exception(
'CRITICAL: libarchive DLL is not installed. '
'Unable to continue: you need to install a valid extractcode-libarchive '
'plugin with a valid libarchive DLL available.'
)
filepath = ctypes.util.find_library(_LIBRARY_NAME)
libarchive = ctypes.cdll.LoadLibrary(filepath)
if not libarchive:
raise ImportError(
'CRITICAL: libarchive DLL is not installed. '
'Unable to continue: you need to install a valid extractcode-libarchive '
'plugin with a valid libarchive DLL available '
'or to have "libarchive" library installed in your system.'
)
logger.warning('Cannot to use plugin for libarchive, defaulting to system library at ' + filepath)
return libarchive
return command.load_shared_library(dll, libdir)


Expand Down
16 changes: 11 additions & 5 deletions src/extractcode/sevenzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import os
import pprint
import re
from shutil import which

import attr

Expand Down Expand Up @@ -80,11 +81,16 @@ def get_bin_locations():
cmd_loc = get_location(EXTRACTCODE_7ZIP_EXE)
libdir = get_location(EXTRACTCODE_7ZIP_LIBDIR)
if not (cmd_loc and libdir) or not os.path.isfile(cmd_loc) or not os.path.isdir(libdir):
raise Exception(
'CRITICAL: 7zip executable is not installed. '
'Unable to continue: you need to install a valid extractcode-7z '
'plugin with a valid executable available.'
)
sevenzip = which('7z')
if not sevenzip:
raise ImportError(
'CRITICAL: 7zip executable is not installed. '
'Unable to continue: you need to install a valid extractcode-7z '
'plugin with a valid executable available '
'or install p7zip in your system, so that a "7z" program is available on your PATH'
)
logger.warning('Cannot to use plugin for libarchive, defaulting to system binary at ' + sevenzip)
return '', sevenzip

return libdir, cmd_loc

Expand Down