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)
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
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:
- Ask Michiel for credentials.json
- Create your own Google spreadsheet (see below)
- 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.
source venv/bin/activate
python wtosbc/main.py
mypy . --ignore-missing-imports
or
mypy . --ignore-missing-imports --strict
pytest
This application uses the Google spreadsheets API via gspread. Signed credentials are needed to access your own spreadsheets. gspread uses a service account key.
-
Go to Google Developer Console and create a new project.
-
Under "API and services", search for the "Google Sheets API" and enable.
-
Go to "Credentials" and select "Create credentials" -> "Service account key".
-
Select new service account and fill in a name. You don't have to specify a role. Select JSON as the key type.
-
Save the downloaded file as credentials.json in the main folder.
-
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. -
Retrieve the spreadsheet key from the spreadsheet url and add it to config.py.
You are now ready to run the program.