Skip to main content

A library to download and execute files from a URL with support for custom directories.

Project description

File Downloader and Executor

This Python library allows you to download files from a URL, save them to a specified directory (or the system's temporary directory by default), and execute or open them based on their type (e.g., .exe for executables, .txt for text files). It provides flexibility for logging, error handling, and customizable download locations.

Features

  • File Downloading: Downloads files from a given URL.
  • File Execution: Executes files automatically after download.
  • Customizable Download Directory: Specifies a custom directory for downloading files or uses the system's temporary directory.
  • Logging: Option to enable or disable logging for the download process.
  • Safety Check: Skips the download if a file with the same name already exists.

Installation

You can install the library via pip:

pip install file-downloader

Usage

Download and Execute File

To use the library, import the download_and_execute function and provide the URL of the file you want to download. You can specify a download directory, and the library will automatically decide what to do based on the file extension.

from file_downloader import download_and_execute

# URL of the file to download
url = "https://example.com/path/to/file"

# Optionally specify the directory where the file will be saved
download_dir = "/path/to/download/directory"

# Download the file and execute it if it's an executable
download_and_execute(url, download_dir=download_dir, enable_logging=True)

How It Works

  1. File Download: The function makes an HTTP GET request to the specified URL and fetches the file.
  2. File Saving: It saves the file to the given download directory or a default system temp directory.
  3. File Execution execute file using subprocess.Popen.
  4. Safety Check: Before downloading, it checks if a file with the same name already exists in the target directory and skips the download if so.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fast_dler-1.0.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file fast_dler-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fast_dler-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for fast_dler-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a62cae1397018deeb72ceb65584dd3712876bed949268e82bb98a252d7d9c529
MD5 22b58b3042612c7ff3346c7558418a29
BLAKE2b-256 7d5ba02f34e9c8b45b1e6674b420dcde1958e2388a8ed64b701f12faba3bb036

See more details on using hashes here.

Supported by

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