mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Rename container.py to isolation_provider.py
First step in encapsulating the isolation provider.
This commit is contained in:
parent
2da973232b
commit
1114a0dfa1
4 changed files with 11 additions and 12 deletions
|
@ -5,7 +5,7 @@ from typing import Any, Callable, List, Optional, TypeVar
|
|||
import click
|
||||
from colorama import Back, Fore, Style
|
||||
|
||||
from . import args, container, errors
|
||||
from . import args, errors, isolation_provider
|
||||
from .document import ARCHIVE_SUBDIR, SAFE_EXTENSION
|
||||
from .logic import DangerzoneCore
|
||||
from .util import get_version
|
||||
|
@ -73,7 +73,7 @@ def cli_main(
|
|||
exit(1)
|
||||
|
||||
# Ensure container is installed
|
||||
container.install()
|
||||
isolation_provider.install()
|
||||
|
||||
# Convert the document
|
||||
print_header("Converting document to safe PDF")
|
||||
|
|
|
@ -11,8 +11,7 @@ from typing import List, Optional
|
|||
from colorama import Fore, Style
|
||||
from PySide2 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from .. import container, errors
|
||||
from ..container import convert
|
||||
from .. import errors, isolation_provider
|
||||
from ..document import SAFE_EXTENSION, Document
|
||||
from ..util import get_resource_path, get_subprocess_startupinfo, get_version
|
||||
from .logic import Alert, DangerzoneGui
|
||||
|
@ -115,7 +114,7 @@ class InstallContainerThread(QtCore.QThread):
|
|||
super(InstallContainerThread, self).__init__()
|
||||
|
||||
def run(self) -> None:
|
||||
container.install()
|
||||
isolation_provider.install()
|
||||
self.finished.emit()
|
||||
|
||||
|
||||
|
@ -167,8 +166,8 @@ class WaitingWidget(QtWidgets.QWidget):
|
|||
state: Optional[str] = None
|
||||
|
||||
try:
|
||||
container_runtime = container.get_runtime()
|
||||
except container.NoContainerTechException as e:
|
||||
container_runtime = isolation_provider.get_runtime()
|
||||
except isolation_provider.NoContainerTechException as e:
|
||||
log.error(str(e))
|
||||
state = "not_installed"
|
||||
|
||||
|
@ -632,7 +631,7 @@ class ConvertTask(QtCore.QObject):
|
|||
self.error = False
|
||||
|
||||
def convert_document(self) -> None:
|
||||
convert(
|
||||
isolation_provider.convert(
|
||||
self.document,
|
||||
self.ocr_lang,
|
||||
self.stdout_callback,
|
||||
|
@ -667,7 +666,7 @@ class DocumentsListWidget(QtWidgets.QListWidget):
|
|||
|
||||
def start_conversion(self) -> None:
|
||||
if not self.thread_pool_initized:
|
||||
max_jobs = container.get_max_parallel_conversions()
|
||||
max_jobs = isolation_provider.get_max_parallel_conversions()
|
||||
self.thread_pool = ThreadPool(max_jobs)
|
||||
|
||||
for doc_widget in self.document_widgets:
|
||||
|
|
|
@ -12,7 +12,7 @@ from typing import Callable, List, Optional
|
|||
import appdirs
|
||||
import colorama
|
||||
|
||||
from . import container, errors
|
||||
from . import errors, isolation_provider
|
||||
from .document import Document
|
||||
from .settings import Settings
|
||||
from .util import get_resource_path
|
||||
|
@ -59,13 +59,13 @@ class DangerzoneCore(object):
|
|||
self, ocr_lang: Optional[str], stdout_callback: Optional[Callable] = None
|
||||
) -> None:
|
||||
def convert_doc(document: Document) -> None:
|
||||
success = container.convert(
|
||||
success = isolation_provider.convert(
|
||||
document,
|
||||
ocr_lang,
|
||||
stdout_callback,
|
||||
)
|
||||
|
||||
max_jobs = container.get_max_parallel_conversions()
|
||||
max_jobs = isolation_provider.get_max_parallel_conversions()
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=max_jobs) as executor:
|
||||
executor.map(convert_doc, self.documents)
|
||||
|
||||
|
|
Loading…
Reference in a new issue