Skip to main content

Testing installation of Package

Project description

Documentation for the Downloader class

The Downloader class provides functionality to download and unzip files from a specified URL using Selenium WebDriver.

Class Methods

__init__(self, download_directory="./", headless=True)

The constructor method initializes the Downloader object. It takes two optional parameters:

  • download_directory (default: "./"): Specifies the directory where the downloaded files will be saved.
  • headless (default: True): Determines whether the Chrome WebDriver runs in headless mode or not.

_wait_for_download(self, timeout=120)

This private method waits for the download to complete. It checks the Chrome Downloads page and returns the file paths of completed downloads. It takes an optional timeout parameter (default: 120 seconds) to specify the maximum time to wait for the download to complete.

download_zip_files(self, url)

This method downloads zip files from a given URL. It performs the following steps:

  1. Navigates to the specified URL.
  2. Waits for the page to load.
  3. Locates and clicks the accept button.
  4. Finds the table element containing the files.
  5. Iterates through each row of the table and checks if the file has a ".svs" extension.
  6. If a ".svs" file is found, locates and clicks the download button.
  7. Waits for the download to complete.
  8. Logs the downloaded data.
  9. Closes the WebDriver.

download_specific_project_files(self, txt_file="./")

This method downloads zip files for specific projects listed in a text file. It takes an optional txt_file parameter (default: "./") that specifies the path to the text file containing project names. The method reads the file and iterates through each project name, calling the download_zip_files method for each project.

unzip_files(directory=None)

This static method extracts files from tar.gz archives in a specified directory. It takes a required directory parameter that specifies the directory where the tar.gz files are located. The method loops through all files in the directory, identifies the ones with the ".tar.gz" extension, checks if the file size is greater than 0, and extracts the contents of the archive using the tarfile module.

Example Usage

# Create an instance of the Downloader class
downloader = Downloader(download_directory="./downloads", headless=True)

# Download zip files for specific projects listed in a text file
downloader.download_specific_project_files(txt_file="./projects.txt")

# Unzip files in the specified directory
downloader.unzip_files(directory="./downloads")

Note: Before using this class, make sure you have the required dependencies installed (Selenium WebDriver, ChromeDriver, and tarfile module).

👥 Authors

👤 Manas

👤 Nishita

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

svs_dataset_downloader-0.0.3.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file svs_dataset_downloader-0.0.3.tar.gz.

File metadata

File hashes

Hashes for svs_dataset_downloader-0.0.3.tar.gz
Algorithm Hash digest
SHA256 5f60f4bed2dcdead1acb0f34adf9283cdeb190e46e597ef1160235162e3b3ab0
MD5 c070cf346a3c44c295c110badb86b05d
BLAKE2b-256 3fa092a3b5f7656b5fa5a23f422ca8d7a6f92a32c8d0515fb3e48fb3379f3be7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page