Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
/ bc Public archive

Script that reads all orders of a topic from wtos.nl, puts everything in the cart of bike-components.de and generates a Google spreadsheet with Python, lxml, Google API, Docker

Notifications You must be signed in to change notification settings

michie1/bc

Repository files navigation

bc

Script that reads all orders of a topic from wtos.nl, puts everything in the basket of bike-components.de and generates a Google spreadsheet (https://wtos.nl/bc)

Development

To install and work on bc locally:

git clone https://github.com/michie1/bc.git
cd bc
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
pip install -e .
pre-commit install

Configuration

Fill in the credentials in wtosbc/config.py, see config.py-example. Put the current bc order number in wtosbc/state.json, see state.json.example. There are 3 options:

  1. Ask Michiel for credentials.json
  2. Create your own Google spreadsheet (see below)
  3. Copy credentials-example.json to wtosbc/credentials.json and visit (http://wtos.nl/bc?test) for the spreadsheet. This is the most easy option for testing and starting working on this project, but this one is shared with multiple people. The spreadsheet key is already set in the example.

Run the program

source venv/bin/activate
python wtosbc/main.py

Type check

mypy . --ignore-missing-imports

or

mypy . --ignore-missing-imports --strict

Test

pytest

Create your own Google spreadsheet

This application uses the Google spreadsheets API via gspread. Signed credentials are needed to access your own spreadsheets. gspread uses a service account key.

  1. Go to Google Developer Console and create a new project.

  2. Under "API and services", search for the "Google Sheets API" and enable.

  3. Go to "Credentials" and select "Create credentials" -> "Service account key".

  4. Select new service account and fill in a name. You don't have to specify a role. Select JSON as the key type.

  5. Save the downloaded file as credentials.json in the main folder.

  6. You will need the client_email from this file. In Google drive create the spreadsheet you want to use. Make sure the spreadsheet settings are set to locale US. Share this spreadsheet with the client_email. In this way you authorise access to the spreadsheet. If you forget to do this, you will get a SpreadhsheetNotFound exception when trying to access shis spreadsheet.

  7. Retrieve the spreadsheet key from the spreadsheet url and add it to config.py.

You are now ready to run the program.

About

Script that reads all orders of a topic from wtos.nl, puts everything in the cart of bike-components.de and generates a Google spreadsheet with Python, lxml, Google API, Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages