Skip to content

Commit 6018ceb

Browse files
authored
Merge pull request #41 from mlibrary/move-reports-to-mayhem
changed dropbox to smb for digifeeds reports
2 parents ac6e181 + 563cc00 commit 6018ceb

File tree

9 files changed

+56
-61
lines changed

9 files changed

+56
-61
lines changed

β€Ž.config/rclone/.keep

Whitespace-only changes.

β€Ž.config/rclone/rclone.conf.example

-32
This file was deleted.

β€Ž.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ requirements.txt
1717

1818
docs/_build
1919
bin/digifeeds/*.config
20-
.config/rclone/rclone.conf
21-
.config/rclone/*.json
20+
21+
.config/rclone/*
22+
!.config/rclone/.keep
2223

2324
tmp/*
2425
!tmp/.keep

β€ŽREADME.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ AIM's python code repository
1919

2020
This will:
2121
* set up the initial environment variables file
22-
* set up the rclone config with the example file
2322
* build the docker image
2423
* install the python dependencies
2524
* Set up the database for digifeeds
@@ -28,11 +27,9 @@ AIM's python code repository
2827

2928
3. Edit `.env` with actual environment variables
3029

31-
4. Edit `.config/rclone/rclone.conf` with your actual values
30+
4. If using VSCode for editing, the repository is set up for use with dev containers. You will have to rebuild the container in there.
3231

33-
5. If using VSCode for editing, the repository is set up for use with dev containers. You will have to rebuild the container in there.
34-
35-
6. In the app container, use `poetry shell` to enable the virtual environment. Otherwise use:
32+
5. In the app container, use `poetry shell` to enable the virtual environment. Otherwise use:
3633

3734
```bash
3835
docker compose run --rm app poetry run YOUR_COMMAND
@@ -120,6 +117,14 @@ docker compose run --rm app poetry run aim digifeeds --help
120117
121118
This will show the commands available for the digifeeds cli applciation.
122119
120+
### Rclone
121+
122+
This applicaiton uses [Rclone](https://rclone.org/) to work with remote storage. It uses the [rclone-python](https://pypi.org/project/rclone-python/) for working with rclone in python.
123+
124+
To configure new remotes for use with the application use environment variables. The names of the environment variables are on the documentation page for a given remote. We use environment variables because it so all of the configuration happens in `.env` instead of in multiple places.
125+
126+
If you want to quickly add a remote to try something out, you can use `rclone configure` in the container terminal. The config file is ignored.
127+
123128
## Tests
124129
125130
To run tests:

β€Žaim/cli/digifeeds.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,6 @@ def generate_barcodes_in_s3_report():
171171
"""
172172
Generates a report of barcodes that have been moved to the google pickup
173173
location in the last two weeks. It is based on the files in the processed
174-
location in the s3 bucket. This report is sent to a dropbox folder.
174+
location in the s3 bucket. This report is sent to a folder on Mayhem.
175175
"""
176176
functions.generate_barcodes_added_in_last_two_weeks_report()

β€Žaim/digifeeds/functions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def generate_barcodes_added_in_last_two_weeks_report():
6161
write_barcodes_added_in_last_two_weeks_report(rf)
6262

6363
today = datetime.today().strftime("%Y-%m-%d")
64-
S.logger.info("writing report to dropbox")
64+
S.logger.info("writing delivery report")
6565
rclone.copyto(
6666
in_path=report_file.name,
67-
out_path=f"{S.digifeeds_reports_rclone_remote}:{today}_barcodes_in_s3_processed.tsv",
67+
out_path=f"{S.digifeeds_delivery_reports_rclone_remote}:{today}_barcodes_in_s3_processed.tsv",
6868
)

β€Žaim/services.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ class Services:
8989
#: The name of the rclone remote for the place where google pickups up the digifeeds files
9090
digifeeds_pickup_rclone_remote: str
9191

92-
#: The name of the rclone remote where reports from digifeeds are sent
93-
digifeeds_reports_rclone_remote: str
92+
#: The name of the rclone remote where reports about what has been sent to google are sent
93+
digifeeds_delivery_reports_rclone_remote: str
9494

9595
#: file path to store of the hathi_file_list update items
9696
hathifiles_store_path: str
@@ -129,8 +129,10 @@ class Services:
129129
or "digifeeds_bucket",
130130
digifeeds_pickup_rclone_remote=os.getenv("DIGIFEEDS_PICKUP_RCLONE_REMOTE")
131131
or "digifeeds_pickup",
132-
digifeeds_reports_rclone_remote=os.getenv("DIGIFEEDS_REPORTS_RCLONE_REMOTE")
133-
or "digifeeds_reports",
132+
digifeeds_delivery_reports_rclone_remote=os.getenv(
133+
"DIGIFEEDS_DELIVERY_REPORTS_RCLONE_REMOTE"
134+
)
135+
or "digifeeds_delivery_reports",
134136
hathifiles_store_path=os.getenv("HATHIFILES_STORE_PATH")
135137
or "tmp/hathi_file_list_store.json",
136138
hathifiles_webhook_url=os.getenv("HATHIFILES_WEBHOOK_URL")

β€Ženv.example

+26
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,29 @@ UID=YOUR_UID
22
GID=YOUR_GID
33
POETRY_VERSION=1.5.1
44
DEV=true
5+
6+
RCLONE_CONFIG_CHAOS_TYPE=smb
7+
RCLONE_CONFIG_CHAOS_HOST=your_smb_host
8+
RCLONE_CONFIG_CHAOS_USER=your_smb_user
9+
RCLONE_CONFIG_CHAOS_PASS=your_smb_password
10+
RCLONE_CONFIG_CHAOS_DOMAIN=your_smb_domain
11+
12+
RCLONE_CONFIG_DIGIFEEDS_DELIVERY_REPORTS_TYPE=alias
13+
RCLONE_CONFIG_DIGIFEEDS_DELIVERY_REPORTS_REMOTE=chaos:your_reports_path
14+
15+
RCLONE_CONFIG_DIGIFEEDS_S3_TYPE=s3
16+
RCLONE_CONFIG_DIGIFEEDS_S3_PROVIDER=AWS
17+
RCLONE_CONFIG_DIGIFEEDS_S3_ACCESS_KEY_ID=your_s3_access_key_id
18+
RCLONE_CONFIG_DIGIFEEDS_S3_SECRET_ACCESS_KEY=your_s3_secret_access_key
19+
20+
RCLONE_CONFIG_DIGIFEEDS_BUCKET_TYPE=alias
21+
RCLONE_CONFIG_DIGIFEEDS_BUCKET_REMOTE=digifeeds_s3:your_bucket_name
22+
23+
RCLONE_CONFIG_DIGIFEEDS_PICKUP_TYPE=sftp
24+
RCLONE_CONFIG_DIGIFEEDS_PICKUP_HOST=your_sftp_host
25+
RCLONE_CONFIG_DIGIFEEDS_PICKUP_USER=your_sftp_user
26+
RCLONE_CONFIG_DIGIFEEDS_PICKUP_PORT=your_sftp_port
27+
RCLONE_CONFIG_DIGIFEEDS_PICKUP_PASS=your_sftp_password_hash
28+
RCLONE_CONFIG_DIGIFEEDS_PICKUP_SHELL_TYPE=cmd
29+
RCLONE_CONFIG_DIGIFEEDS_MD5SUM_COMMAND=none
30+
RCLONE_CONFIG_DIGIFEEDS_SHA1SUM_COMMAND=none

β€Žinit.sh

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
#!/usr/bin/env bash
22

33
if [ -f ".env" ]; then
4-
echo "🌎 .env exists. Leaving alone"
4+
echo "🌎 .env exists. Leaving alone"
55
else
6-
echo "🌎 .env does not exist. Copying .env-example to .env"
7-
cp env.example .env
8-
YOUR_UID=$(id -u)
9-
YOUR_GID=$(id -g)
10-
echo "πŸ™‚ Setting your UID (${YOUR_UID}) and GID (${YOUR_UID}) in .env"
11-
docker run --rm -v ./.env:/.env alpine echo "$(sed s/YOUR_UID/${YOUR_UID}/ .env)" >.env
12-
docker run --rm -v ./.env:/.env alpine echo "$(sed s/YOUR_GID/${YOUR_GID}/ .env)" >.env
13-
fi
14-
15-
if [ -f ".config/rclone/rclone.conf" ]; then
16-
echo "πŸ“‹ .config/rclone/rclone.conf exists. Leaving alone"
17-
else
18-
echo "πŸ“‹ .config/rclone/rclone.conf does not exist. Copying .config/rclone/rclone.conf.example to rclone_config"
19-
cp .config/rclone/rclone.conf.example .config/rclone/rclone.conf
6+
echo "🌎 .env does not exist. Copying .env-example to .env"
7+
cp env.example .env
8+
YOUR_UID=$(id -u)
9+
YOUR_GID=$(id -g)
10+
echo "πŸ™‚ Setting your UID (${YOUR_UID}) and GID (${YOUR_UID}) in .env"
11+
docker run --rm -v ./.env:/.env alpine echo "$(sed s/YOUR_UID/${YOUR_UID}/ .env)" >.env
12+
docker run --rm -v ./.env:/.env alpine echo "$(sed s/YOUR_GID/${YOUR_GID}/ .env)" >.env
2013
fi
2114

2215
echo "🚒 Build docker images"

0 commit comments

Comments
Β (0)