coderxio / dailymed-api

REST API for DailyMed SPLs
https://coderx.io/
MIT License
12 stars 5 forks source link

23/download unzip loop #28

Closed finish06 closed 4 years ago

finish06 commented 4 years ago

Fixes coderxio/dailymed-api#23

Explanation

  1. get_zips.py now calls extract_zips.py. This allows for each SPL to be downloaded, extracted, and deleted before the next SPL is obtained.
  2. get_zips.py reads and writes the SPL.zip file in chunks to prevent memory issues in low memory environments.
  3. get_zips.py includes cmd line arguments to specific number of files to unzip, the number of SPLs to download or the specific SPL to download.
    
    usage: get_zips.py [-h] [--unzip u] [--download d | --select s]

Download and unzip SPL data.

optional arguments: -h, --help show this help message and exit --unzip u Number of files to unzip from SPL --download d Number of SPL files to download, max 4 --select s Specific SPL file to download, i.e. 1, 2, 3 or 4



## Rationale
To allow getting zips on the droplet and improve testing in dev environment.

## Tests
1. What testing did you do?
Downloaded SPL files via a variety of cmd line arguments
1. `python get_zips.py`
2. `python get_zips.py --unzip 2 --download 4`
3. `python get_zips.py --unzip 20 --download 1`
4. `python get_zips.py --unzip 2 --select 4`
finish06 commented 4 years ago

Reran the following scenarios with success:

python get_zips.py
python get_zips.py --unzip 2 --download 4
python get_zips.py --unzip 20 --download 1
python get_zips.py --unzip 2 --select 4
finish06 commented 4 years ago

Help menu:

usage: get_zips.py [-h] [--unzip int] [--download int | --select int]

Download and unzip SPL data.

optional arguments:
  -h, --help      show this help message and exit
  --unzip int     Optional number of files to extract from SPL zip.
  --download int  Optional number of SPL zip files to download, max 4.
  --select int    Optional SPL zip file to download, i.e. 1, 2, 3 or 4