Skip to content

Commit

Permalink
Removed unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
theypsilon committed Feb 11, 2025
1 parent 4ace7aa commit 5f287f9
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/downloader/full_run_service_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from downloader.job_system import JobSystem
from downloader.jobs.fetch_file_worker import SafeFileFetcher
from downloader.jobs.reporters import DownloaderProgressReporter, FileDownloadProgressReporter, InstallationReportImpl
from downloader.jobs.worker_context import make_downloader_worker_context
from downloader.jobs.worker_context import DownloaderWorkerContext
from downloader.logger import DebugOnlyLoggerDecorator, Logger, FilelogManager, PrintLogManager, FileLoggerDecorator, \
PrintLogger
from downloader.os_utils import LinuxOsUtils
Expand Down Expand Up @@ -92,7 +92,7 @@ def create(self, config: Config):
free_space_reservation = LinuxFreeSpaceReservation(logger=self._logger, config=config) if system_file_system.is_file(FILE_MiSTer_version) else UnlimitedFreeSpaceReservation()
linux_updater = LinuxUpdater(self._logger, config, system_file_system, safe_file_fetcher)

workers_ctx = make_downloader_worker_context(
workers_ctx = DownloaderWorkerContext(
job_ctx=job_system,
waiter=waiter,
logger=self._logger,
Expand Down
3 changes: 1 addition & 2 deletions src/downloader/jobs/open_db_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
# You can download the latest version of this tool from:
# https://github.com/MiSTer-devel/Downloader_MiSTer

from downloader.db_entity import DbEntity, DbEntityValidationException, make_db_tag
from downloader.file_system import FsError
from downloader.db_entity import DbEntity, make_db_tag
from downloader.job_system import WorkerResult
from downloader.jobs.open_db_job import OpenDbJob
from downloader.jobs.process_db_job import ProcessDbJob
Expand Down
1 change: 0 additions & 1 deletion src/downloader/jobs/open_zip_contents_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# https://github.com/MiSTer-devel/Downloader_MiSTer

import os
from typing import List

from downloader.job_system import WorkerResult
from downloader.jobs.index import Index
Expand Down
1 change: 0 additions & 1 deletion src/downloader/jobs/validate_file_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# https://github.com/MiSTer-devel/Downloader_MiSTer

from typing import Optional
from pathlib import Path

from downloader.file_system import FileSystem
from downloader.job_system import WorkerResult, ProgressReporter
Expand Down
34 changes: 1 addition & 33 deletions src/downloader/jobs/worker_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,46 +53,14 @@ class DownloaderWorkerContext:
file_filter_factory: FileFilterFactory
target_paths_calculator_factory: TargetPathsCalculatorFactory
config: Config
fail_policy: DownloaderWorkerFailPolicy
fail_policy: DownloaderWorkerFailPolicy = DownloaderWorkerFailPolicy.FAULT_TOLERANT

def swallow_error(self, e: Exception, print: bool = True):
if self.fail_policy == DownloaderWorkerFailPolicy.FAIL_FAST:
raise e
self.logger.debug(e)
if print: self.logger.print(f"ERROR: {e}")

def make_downloader_worker_context(
job_ctx: JobContext,
http_gateway: HttpGateway,
logger: Logger,
file_system: FileSystem,
waiter: Waiter,
progress_reporter: ProgressReporter,
file_download_session_logger: FileDownloadSessionLogger,
installation_report: InstallationReportImpl,
free_space_reservation: FreeSpaceReservation,
external_drives_repository: ExternalDrivesRepository,
file_filter_factory: FileFilterFactory,
target_paths_calculator_factory: TargetPathsCalculatorFactory,
config: Config,
fail_policy: DownloaderWorkerFailPolicy = DownloaderWorkerFailPolicy.FAULT_TOLERANT
) -> DownloaderWorkerContext:
return DownloaderWorkerContext(
job_ctx=job_ctx,
http_gateway=http_gateway,
logger=logger,
file_system=file_system,
waiter=waiter,
progress_reporter=progress_reporter,
file_download_session_logger=file_download_session_logger,
installation_report=installation_report,
free_space_reservation=free_space_reservation,
external_drives_repository=external_drives_repository,
file_filter_factory=file_filter_factory,
target_paths_calculator_factory=target_paths_calculator_factory,
config=config,
fail_policy=fail_policy
)

class DownloaderWorker(Worker):
@abstractmethod
Expand Down
4 changes: 2 additions & 2 deletions src/test/fake_online_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from downloader.job_system import Job, JobFailPolicy, JobSystem
from downloader.jobs.process_db_job import ProcessDbJob
from downloader.jobs.reporters import FileDownloadProgressReporter, InstallationReportImpl, InstallationReport
from downloader.jobs.worker_context import DownloaderWorker, DownloaderWorkerFailPolicy, make_downloader_worker_context
from downloader.jobs.worker_context import DownloaderWorker, DownloaderWorkerFailPolicy, DownloaderWorkerContext
from downloader.local_store_wrapper import StoreWrapper
from downloader.online_importer import InstallationBox, OnlineImporter as ProductionOnlineImporter
from downloader.target_path_calculator import TargetPathsCalculatorFactory
Expand Down Expand Up @@ -78,7 +78,7 @@ def __init__(
self._report_tracker = ProgressReporterTracker(self._file_download_reporter)
self._job_system = JobSystem(self._report_tracker, logger=logger, max_threads=1, fail_policy=JobFailPolicy.FAIL_FAST, max_timeout=1)
external_drives_repository = ExternalDrivesRepository(file_system=self.file_system)
self._worker_ctx = make_downloader_worker_context(
self._worker_ctx = DownloaderWorkerContext(
job_ctx=self._job_system,
waiter=waiter,
logger=logger,
Expand Down

0 comments on commit 5f287f9

Please sign in to comment.