Skip to content

Commit b49d75a

Browse files
committed
Update dependencies, add Makefile.
1 parent e890a97 commit b49d75a

File tree

18 files changed

+877
-355
lines changed

18 files changed

+877
-355
lines changed

β€ŽMakefile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
SRCPATH := $(shell pwd)
2+
PROJECTNAME := $(shell basename $CURDIR)
3+
4+
define HELP
5+
Manage $(PROJECTNAME). Usage:
6+
7+
make run - Run $(PROJECTNAME).
8+
make deploy - Pull latest build and deploy to production.
9+
make update - Update pip dependencies via Python Poetry.
10+
make format - Format code with Python's `Black` library.
11+
make lint - Check code formatting with flake8
12+
make clean - Remove cached files and lock files.
13+
endef
14+
export HELP
15+
16+
17+
.PHONY: run restart deploy update format lint clean help
18+
19+
requirements: .requirements.txt
20+
env: ./.venv/bin/activate
21+
22+
23+
.requirements.txt: requirements.txt
24+
$(shell . .venv/bin/activate && pip install -r requirements.txt)
25+
26+
27+
all help:
28+
@echo "$$HELP"
29+
30+
31+
.PHONY: run
32+
run: env
33+
python main.py
34+
35+
36+
.PHONY: deploy
37+
deploy:
38+
$(shell . ./deploy.sh)
39+
40+
41+
.PHONY: update
42+
update: env
43+
.venv/bin/python3 -m pip install --upgrade pip setuptools wheel
44+
poetry update
45+
poetry export -f requirements.txt --output requirements.txt --without-hashes
46+
47+
48+
.PHONY: format
49+
format: env
50+
isort -rc --multi-line=3 .
51+
black .
52+
53+
54+
.PHONY: lint
55+
lint:
56+
flake8 . --count \
57+
--select=E9,F63,F7,F82 \
58+
--exclude .git,.github,__pycache__,.pytest_cache,.venv,logs,creds,.venv,docs,logs \
59+
--show-source \
60+
--statistics
61+
62+
63+
.PHONY: clean
64+
clean:
65+
find . -name '*.pyc' -delete
66+
find . -name '__pycache__' -delete
67+
find . -name 'poetry.lock' -delete
68+
find . -name 'Pipefile.lock' -delete
69+
find . -name '*.log' -delete
70+
find . -wholename 'logs/*.json' -delete
71+
find . -wholename '.pytest_cache' -delete
72+
find . -wholename '*/.pytest_cache' -delete
73+
find . -wholename '*/logs/*.json' -delete
74+
find . -wholename '.webassets-cache/*' -delete

β€ŽPipfile

Lines changed: 0 additions & 16 deletions
This file was deleted.

β€ŽPipfile.lock

Lines changed: 0 additions & 234 deletions
This file was deleted.

β€Žconfig.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
"""Remote host configuration."""
2-
from os import environ, path
2+
from os import getenv, path
3+
34
from dotenv import load_dotenv
5+
from log import LOGGER
46

57
# Load environment variables from .env
68
basedir = path.abspath(path.dirname(__file__))
7-
load_dotenv(path.join(basedir, '.env'))
9+
load_dotenv(path.join(basedir, ".env"))
810

911
# Read environment variables
10-
host = environ.get('REMOTE_HOST')
11-
user = environ.get('REMOTE_USERNAME')
12-
ssh_key_filepath = environ.get('SSH_KEY')
13-
remote_path = environ.get('REMOTE_PATH')
12+
host = getenv("REMOTE_HOST")
13+
user = getenv("REMOTE_USERNAME")
14+
ssh_key_filepath = getenv("SSH_KEY")
15+
remote_path = getenv("REMOTE_PATH")
16+
config_values = [
17+
{"host": host},
18+
{"user": user},
19+
{"ssh": ssh_key_filepath},
20+
{"path": remote_path},
21+
]
22+
23+
24+
for config in config_values:
25+
if None in config.values():
26+
LOGGER.warning(f"Config value not set: {config.popitem()}")
27+
raise Exception("Set your environment variables via a .env file.")
28+
1429

15-
local_file_directory = 'transfer'
30+
local_file_directory = "files"

β€Ždeploy.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
#!/bin/bash
3+
4+
if [ -d ".venv" ]
5+
then
6+
. .venv/bin/activate
7+
pip install -r requirements.txt
8+
else
9+
python3 -m venv .venv
10+
. .venv/bin/activate
11+
python3 -m pip install --upgrade pip
12+
pip install -r requirements.txt
13+
fi
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
Β (0)