|
|
|
@ -1,46 +1,64 @@
|
|
|
|
|
_python_pkg = art_account
|
|
|
|
|
config_dir = $(HOME)/.config/art-account
|
|
|
|
|
cache_dir = $(HOME)/.cache/art-account
|
|
|
|
|
log_dir = .log
|
|
|
|
|
transactions_file = $(cache_dir)/transactions.json
|
|
|
|
|
transactions_file_test = $(cache_dir)/transactions_test.json
|
|
|
|
|
images_file = $(config_dir)/images.json
|
|
|
|
|
images_random_file = $(config_dir)/images_random.json
|
|
|
|
|
images_sorted_file = $(config_dir)/images_sorted.json
|
|
|
|
|
images_final_file = $(config_dir)/images_final.json
|
|
|
|
|
|
|
|
|
|
.PHONY: setup setup-dev test lint reformat clean clean-test backup spreadsheet spreadsheet-test spreadsheet-test-full deploy-upload deploy-cron checkargs-remote help
|
|
|
|
|
|
|
|
|
|
transactions: $(transactions_file)
|
|
|
|
|
|
|
|
|
|
transactions-test: $(transactions_file_test)
|
|
|
|
|
_python_pkg := art_account
|
|
|
|
|
_executable := art-account
|
|
|
|
|
|
|
|
|
|
config_dir ?= $(HOME)/.config/art-account
|
|
|
|
|
cache_dir ?= $(HOME)/.cache/art-account
|
|
|
|
|
log_dir ?= $(HOME)/.local/share/art-account/log
|
|
|
|
|
|
|
|
|
|
transactions_file := $(cache_dir)/transactions.json
|
|
|
|
|
transactions_file_test := $(cache_dir)/transactions_test.json
|
|
|
|
|
images_file := $(config_dir)/images.json
|
|
|
|
|
images_random_file := $(config_dir)/images_random.json
|
|
|
|
|
images_sorted_file := $(config_dir)/images_sorted.json
|
|
|
|
|
images_final_file := $(config_dir)/images_final.json
|
|
|
|
|
|
|
|
|
|
.PHONY: transactions
|
|
|
|
|
transactions: ## Retrieve transactions (accepts variable env=test)
|
|
|
|
|
ifeq ($(env), test)
|
|
|
|
|
$(MAKE) $(transactions_file_test)
|
|
|
|
|
else
|
|
|
|
|
$(MAKE) $(transactions_file)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
.PHONY: setup
|
|
|
|
|
setup: ## Create Pipenv virtual environment and install dependencies.
|
|
|
|
|
pipenv --three --site-packages
|
|
|
|
|
pipenv install
|
|
|
|
|
|
|
|
|
|
.PHONY: setup-dev
|
|
|
|
|
setup-dev: ## Install development dependencies
|
|
|
|
|
pipenv install --dev
|
|
|
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
|
test: ## Run unit tests
|
|
|
|
|
pipenv run python -m unittest
|
|
|
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
|
lint: ## Run linting
|
|
|
|
|
pipenv run flake8 $(_python_pkg)
|
|
|
|
|
pipenv run mypy $(_python_pkg) --ignore-missing-imports
|
|
|
|
|
pipenv run isort -c -rc $(_python_pkg)
|
|
|
|
|
|
|
|
|
|
.PHONY: reformat
|
|
|
|
|
reformat: ## Reformat Python code using Black
|
|
|
|
|
black -l 79 --skip-string-normalization $(_python_pkg)
|
|
|
|
|
pipenv run isort -rc $(_python_pkg)
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
|
-rm "$(transactions_file)"
|
|
|
|
|
|
|
|
|
|
clean-test:
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
clean: ## Clean transactions (accepts variable env=test)
|
|
|
|
|
ifeq ($(env), test)
|
|
|
|
|
-rm "$(transactions_file_test)"
|
|
|
|
|
else
|
|
|
|
|
-rm "$(transactions_file)"
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
backup:
|
|
|
|
|
.PHONY: backup
|
|
|
|
|
backup: ## Backup transactions (accepts variable env=test)
|
|
|
|
|
ifeq ($(env), test)
|
|
|
|
|
-cp -a "$(transactions_file_test)" "$(cache_dir)/transactions_test-$$(date +%s).json.bak"
|
|
|
|
|
else
|
|
|
|
|
-cp -a "$(transactions_file)" "$(cache_dir)/transactions-$$(date +%s).json.bak"
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
$(transactions_file):
|
|
|
|
|
account-statement \
|
|
|
|
@ -63,19 +81,23 @@ $(transactions_file_test):
|
|
|
|
|
$(log_dir):
|
|
|
|
|
mkdir -p "$@"
|
|
|
|
|
|
|
|
|
|
spreadsheet: $(transactions_file) $(images_final_file) | $(log_dir)
|
|
|
|
|
.PHONY: spreadsheet
|
|
|
|
|
spreadsheet: $(images_final_file) | $(log_dir) ## Update spreadsheet (accepts variable env=test or env=test-full)
|
|
|
|
|
ifeq ($(env),)
|
|
|
|
|
$(MAKE) $(transactions_file)
|
|
|
|
|
date +%s >> "$(log_dir)/spreadsheet.log"
|
|
|
|
|
./art-account --verbose spreadsheet \
|
|
|
|
|
"./$(_executable)" --verbose spreadsheet \
|
|
|
|
|
--config "$(config_dir)/spreadsheet.json" \
|
|
|
|
|
--client-secrets "$(config_dir)/client_secrets.json" \
|
|
|
|
|
--transactions "$(transactions_file)" \
|
|
|
|
|
--images "$(images_final_file)" \
|
|
|
|
|
--reset \
|
|
|
|
|
--noauth_local_webserver 2>&1 | tee -a "$(log_dir)/spreadsheet.log"
|
|
|
|
|
|
|
|
|
|
spreadsheet-test: $(transactions_file_test) $(images_final_file) | $(log_dir)
|
|
|
|
|
endif
|
|
|
|
|
ifeq ($(env), test)
|
|
|
|
|
$(MAKE) $(transactions_file_test)
|
|
|
|
|
date +%s >> "$(log_dir)/spreadsheet_test.log"
|
|
|
|
|
./art-account --verbose spreadsheet \
|
|
|
|
|
"./$(_executable)" --verbose spreadsheet \
|
|
|
|
|
--config "$(config_dir)/spreadsheet_test.json" \
|
|
|
|
|
--client-secrets "$(config_dir)/client_secrets.json" \
|
|
|
|
|
--transactions "$(transactions_file_test)" \
|
|
|
|
@ -83,16 +105,18 @@ spreadsheet-test: $(transactions_file_test) $(images_final_file) | $(log_dir)
|
|
|
|
|
--reset \
|
|
|
|
|
--limit=10 \
|
|
|
|
|
--noauth_local_webserver 2>&1 | tee -a "$(log_dir)/spreadsheet_test.log"
|
|
|
|
|
|
|
|
|
|
spreadsheet-test-full: $(transactions_file) $(images_final_file) | $(log_dir)
|
|
|
|
|
endif
|
|
|
|
|
ifeq ($(env), test-full)
|
|
|
|
|
$(MAKE) $(transactions_file)
|
|
|
|
|
date +%s >> "$(log_dir)/spreadsheet_test.log"
|
|
|
|
|
./art-account --verbose spreadsheet \
|
|
|
|
|
"./$(_executable)" --verbose spreadsheet \
|
|
|
|
|
--config "$(config_dir)/spreadsheet_test.json" \
|
|
|
|
|
--client-secrets "$(config_dir)/client_secrets.json" \
|
|
|
|
|
--transactions "$(transactions_file)" \
|
|
|
|
|
--images "$(images_final_file)" \
|
|
|
|
|
--reset \
|
|
|
|
|
--noauth_local_webserver 2>&1 | tee -a "$(log_dir)/spreadsheet_test.log"
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
$(images_file): $(config_dir)/images.csv $(config_dir)/key_flickr
|
|
|
|
|
use-free-images \
|
|
|
|
@ -102,37 +126,22 @@ $(images_file): $(config_dir)/images.csv $(config_dir)/key_flickr
|
|
|
|
|
--output "$(images_file)"
|
|
|
|
|
|
|
|
|
|
$(images_random_file): $(images_file)
|
|
|
|
|
./art-account --verbose shuffle-images \
|
|
|
|
|
"./$(_executable)" --verbose shuffle-images \
|
|
|
|
|
"$(images_file)" \
|
|
|
|
|
"$(images_random_file)"
|
|
|
|
|
|
|
|
|
|
$(images_sorted_file): $(images_random_file) $(config_dir)/images_priorities.csv
|
|
|
|
|
./art-account --verbose sort-images-by-priority \
|
|
|
|
|
"./$(_executable)" --verbose sort-images-by-priority \
|
|
|
|
|
"$(images_random_file)" \
|
|
|
|
|
"$(images_sorted_file)" \
|
|
|
|
|
--priorities "$(config_dir)/images_priorities.csv"
|
|
|
|
|
|
|
|
|
|
$(images_final_file): $(images_sorted_file) $(config_dir)/images_final.txt
|
|
|
|
|
./art-account --verbose sort-images-based-on-list \
|
|
|
|
|
"./$(_executable)" --verbose sort-images-based-on-list \
|
|
|
|
|
"$(images_sorted_file)" \
|
|
|
|
|
"$(images_final_file)" \
|
|
|
|
|
--urls "$(config_dir)/images_final.txt"
|
|
|
|
|
|
|
|
|
|
deploy-upload: $(transactions_file) | checkargs-remote
|
|
|
|
|
scp "$(transactions_file)" "$(REMOTE_HOST):$(REMOTE_PATH)/transactions.json"
|
|
|
|
|
|
|
|
|
|
deploy-cron: | checkargs-remote
|
|
|
|
|
ssh "$(REMOTE_HOST)" "cd $(REMOTE_PATH) && make spreadsheet"
|
|
|
|
|
|
|
|
|
|
checkargs-remote:
|
|
|
|
|
ifeq (,$(REMOTE_HOST))
|
|
|
|
|
@echo "You must set the REMOTE_HOST variable."
|
|
|
|
|
@exit 1
|
|
|
|
|
endif
|
|
|
|
|
ifeq (,$(REMOTE_PATH))
|
|
|
|
|
@echo "You must set the REMOTE_PATH variable."
|
|
|
|
|
@exit 1
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
|
help:
|
|
|
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'
|
|
|
|
|