Python Developer Test Submission

Instructions

Thank you for your interest in our job opening. As a next step, we are expecting you to complete a short assignment.

You need to write a script using Python and share the code or link to directly execute the code.

Task

You are given a list of URLs that point to image files on the web. Your task is to download these image files concurrently using multithreading in Python. You should use object-oriented programming concepts to organize your code into classes and objects.

Here are the requirements for your solution:

  1. Create a DownloadManager class that manages the download of the image files. The DownloadManager should take in a list of URLs to download when it is instantiated.
  2. Create a DownloadThread class that extends the Thread class from the threading module. The DownloadThread should take in a URL to download when it is instantiated. The DownloadThread should download the image file from the URL and save it to disk.
  3. Use the DownloadThread class to download the image files concurrently. Use a fixed number of threads to download the image files concurrently. You can specify the number of threads to use when you instantiate the DownloadManager.
  4. Once all the image files are downloaded, print a message indicating that the download is complete.

Here’s an example of how the DownloadManager class should be used along with the urls:

urls = [
“https://free-thesis.com/wp-content/uploads/2022/02/Depression-Detection-Framework-EEG-free-thesis.png”,
“https://free-thesis.com/wp-content/uploads/2018/04/output-of-PSO-tuned-MPPT-control.png”,
“https://free-thesis.com/wp-content/uploads/2018/04/PSO-Tuned-MPPT-Control-of-PV-array.png”,
“https://free-thesis.com/wp-content/uploads/2018/04/2-1.png”,
“https://free-thesis.com/wp-content/uploads/2018/04/motor_5.png”,
“https://free-thesis.com/wp-content/uploads/2018/04/motor_2.png”,
]

dm = DownloadManager(urls, num_threads=5)
dm.start_download()

Kindly Submit the solution through this form.