Skip to content

Commit

Permalink
Documentation (#5)
Browse files Browse the repository at this point in the history
* added to README.md and docstrings

* fixed get_vendor_files test, added to README.md

* updated README with additional information

* fixed test_cli with validate-file changes

* changed mock_creds to mock_vendor_creds

* added tests, changed get_control_number

* fixed mock_sheet_config_no_creds fixture
  • Loading branch information
charlottekostelic authored Oct 15, 2024
1 parent a2a3b40 commit 2c1a055
Show file tree
Hide file tree
Showing 8 changed files with 465 additions and 174 deletions.
66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,66 @@
# vendor-file-cli
CLI tool to retrieve files from vendor servers
CLI tool to retrieve files from vendor servers.

## Setup
### Install with pip
1. Create a folder: `$ mkdir vendor-file-cli`
2. Navidate to folder: `$ cd vendor-file-cli`
3. Create a virtual environment and activate it:
`$ python -m venv .venv & $ source ./.venv/scripts/activate`
4. Install from Github:
`$ pip install git+https://github.com/BookOps-CAT/vendor-file-cli`


### Install with Poetry
1. Clone repository
2. Navigate to project directory in terminal
3. Activate virtual environment in poetry with `$ poetry shell`
4. Install dependencies with `$ poetry install`



## Usage
```
$ fetch all-available-records
```

This project provides a command line interface to connect to and retrieve files from vendors using FTP/SFTP. Files are copied to the vendor's directory on BookOps' NSDROP SFTP server.

This CLI can also validate MARC records using the models defined in [record-validator](https://github.com/BookOps-CAT/record-validator). Currently this tool is able to validate records for Eastview, Leila, and Amalivre (SASB).

### Commands
The following information is also available using `validator --help`

#### Available commands

##### Retrieve all new files
`$ fetch all-vendor-files`

Reads credentials for all vendor servers from a `yaml` file. Retrieves all new files for all vendors with credentials in the `yaml` file.
- Logs into each vendor's server,
- Creates a lists of files on the server and in the corresponding directory on NSDROP,
- Copies all files from the vendor's server that are not in the NSDROP directory,
- For select vendors the records will be validated before they are copied to NSDROP
- Currently these vendors are Eastview, Leila, and Amalivre (SASB)
- The validation output is written to a [google sheet](https://docs.google.com/spreadsheets/d/1ZYuhMIE1WiduV98Pdzzw7RwZ08O-sJo7HJihWVgSOhQ/edit?usp=sharing).

##### List all vendors configured to work with CLI
`$ fetch available-vendors`

Reads the local `yaml` config file and prints the list of vendors who are configured to work with the CLI.

##### Validate vendor .mrc files
`$ fetch validate-file`
- `-v`/`--vendor` vendor whose files you would like to validate

Validates files for the vendor specified using the `-v`/`--vendor` option.

##### Retrieve files for a specified vendor within a specific timeframe

`$ fetch vendor-files`
- `-v`/`--vendor` vendor whose files you would like to validate
- `-d`/`--day` number of days to go back and retrieve files from
- `-h`/`--hour` number of hours to go back and retrieve files from

Retrieves files for a specified vendor within the specified timeframe. If neither `--day` nor `--hour` is provided, all files will be retrieved. If the file already exists in the corresponding directory on NSDROP, it will be skipped. Command accepts multiple args passed to `-v`/`--vendor`, eg. to fetch files from Eastview and Leila created within the last 10 days:
`$ fetch vendor-files -v eastview -v leila -d 10`
Loading

0 comments on commit 2c1a055

Please sign in to comment.