Skip to main content
  1. Posts/

Pybox: A Small Toolbox for Everyday Research Tasks

·451 words·3 mins· loading · loading · · ·
Yangyang Li
Author
Yangyang Li
PhD Candidate at Northwestern University
Table of Contents

Why Pybox
#

I kept searching for the same commands over and over: how to download a file from Google Drive from the command line, how to post a message to Slack from a script. Pybox is my answer: a Python command-line toolbox that collects these small utilities in one place. It grows whenever I find another command worth keeping. Current features:

  • Download files from Google Drive, both single files and whole folders
  • Send messages to Slack channels
  • Download many files asynchronously
Downloading a whole Google Drive folder requires authentication through the Google API.

Installation
#

Pybox is published on PyPI:

pip install pyboxes

A Conda package is planned:

conda install pyboxes  # Coming soon

Usage
#

Run pybox -h to see the available commands:

Usage: pybox [options] <command>

  This tool include a bunch of useful commands:

  1. Download single file or all files in a folder for Google Driver
  2. Send message to Slack
  3. more to come...

Options:
  -h, --help  Show this message and exit.

Commands:
  asAyncdown  Download files in terms of links asynchronously.
  gfile      Download file in Google Driver.
  gfolder    Download files in folders in Google Drive.
  slack      Send message to Slack.

  Yangyang-Li https://yangyangli.top/ 2022

Features
#

I plan to keep adding commands as I find them useful, and to keep the existing ones tested and reliable. If there is a command or feature you would like to see, open an issue and we can discuss it.

Take a tour
#

Download files from Google Drive
#

Download a single file from a sharing link:

$ pybox gfile <url> <name> <size>

Download every file in a folder, given a client ID and folder ID:

$ pybox gfolder <client_id> <folder_id>

See the usage documentation for details.

Send a message to a Slack channel
#

$ pybox slack [options] <webhook-url>

See the usage documentation for details.

Download multiple files asynchronously
#

Download a single file:

$ pybox asyncdown -u <url> -o <output>

Download multiple files listed in a text file:

$ pybox asyncdown -f <url-file>

For example, suppose urls.txt has the file name in the first column and the download URL in the second. pybox asyncdown -f urls.txt downloads all of them in parallel.

ENCFF888ZZV.fastq.gz https://www.encodeproject.org/files/ENCFF888ZZV/@@download/ENCFF888ZZV.fastq.gz
ENCFF883SEZ.fastq.gz https://www.encodeproject.org/files/ENCFF883SEZ/@@download/ENCFF883SEZ.fastq.gz
ENCFF035OMK.fastq.gz https://www.encodeproject.org/files/ENCFF035OMK/@@download/ENCFF035OMK.fastq.gz
ENCFF288CVJ.fastq.gz https://www.encodeproject.org/files/ENCFF288CVJ/@@download/ENCFF288CVJ.fastq.gz

Contributing
#

Contributions are welcome: fork the project on GitHub and read the contributing guide before you start. Please make sure all tests pass before opening a pull request.

Related