Compare commits
8 Commits
66e3d5e8a7
...
7bc0d693a9
Author | SHA1 | Date | |
---|---|---|---|
7bc0d693a9 | |||
2c711cfee3 | |||
7842d4f9fe | |||
4280a7721e | |||
c18e29423a | |||
1b2d2d9b27 | |||
6e909f6b38 | |||
acb39e9c32 |
|
@ -10,13 +10,72 @@ on:
|
||||||
paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml']
|
paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml']
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Package-Container:
|
release-image:
|
||||||
uses: jmaa/workflows/.gitea/workflows/container.yaml@v6.21
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache
|
||||||
|
steps:
|
||||||
|
- run: apt-get update
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Setting up SSH
|
||||||
|
if: ${{ hashFiles('requirements_private.txt') != '' }}
|
||||||
|
uses: https://github.com/shimataro/ssh-key-action@v2.5.1
|
||||||
with:
|
with:
|
||||||
REGISTRY_DOMAIN: gitfub.space
|
key: ${{ secrets.PIPELINE_WORKER_SSH_KEY }}
|
||||||
REGISTRY_ORGANIZATION: jmaa
|
name: id_rsa
|
||||||
secrets:
|
known_hosts: ${{ secrets.PIPELINE_WORKER_KNOWN_HOSTS }}
|
||||||
DOCKER_USERNAME: ${{ secrets.PIPY_REPO_USER }}
|
config: |
|
||||||
DOCKER_PASSWORD: ${{ secrets.PIPY_REPO_PASS }}
|
Host gitfub
|
||||||
PIPELINE_WORKER_SSH_KEY: ${{ secrets.PIPELINE_WORKER_SSH_KEY }}
|
HostName gitfub.space
|
||||||
PIPELINE_WORKER_KNOWN_HOSTS: ${{ secrets.PIPELINE_WORKER_KNOWN_HOSTS }}
|
User ${{ secrets.PIPY_REPO_USER }}
|
||||||
|
|
||||||
|
- name: Download private dependencies
|
||||||
|
if: ${{ hashFiles('requirements_private.txt') != '' }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
mkdir -p private_deps
|
||||||
|
cd private_deps
|
||||||
|
while IFS=$" " read -r -a dependency_spec
|
||||||
|
do
|
||||||
|
if test -n "${dependency_spec[1]}"
|
||||||
|
then
|
||||||
|
git clone -v --single-branch --no-tags "${dependency_spec[0]}" --branch "${dependency_spec[1]}"
|
||||||
|
else
|
||||||
|
git clone -v --single-branch --no-tags "${dependency_spec[0]}"
|
||||||
|
fi
|
||||||
|
done < ../requirements_private.txt
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
|
- name: Set up Docker BuildX
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: gitfub.space
|
||||||
|
username: ${{ secrets.PIPY_REPO_USER }}
|
||||||
|
password: ${{ secrets.PIPY_REPO_PASS }}
|
||||||
|
|
||||||
|
- name: Get Meta
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
||||||
|
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: |
|
||||||
|
linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
gitfub.space/jmaa/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
|
||||||
|
gitfub.space/jmaa/${{ steps.meta.outputs.REPO_NAME }}:latest
|
||||||
|
|
|
@ -10,11 +10,24 @@ on:
|
||||||
paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml']
|
paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml']
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Package:
|
Package-Python-And-Publish:
|
||||||
uses: jmaa/workflows/.gitea/workflows/python-package.yaml@v6.21
|
runs-on: ubuntu-latest
|
||||||
with:
|
container:
|
||||||
REGISTRY_DOMAIN: gitfub.space
|
image: node:21-bookworm
|
||||||
REGISTRY_ORGANIZATION: jmaa
|
steps:
|
||||||
secrets:
|
- name: Setting up Python ${{ env.PYTHON_VERSION }} for ${{runner.arch}} ${{runner.os}}
|
||||||
PIPY_REPO_USER: ${{ secrets.PIPY_REPO_USER }}
|
run: |
|
||||||
PIPY_REPO_PASS: ${{ secrets.PIPY_REPO_PASS }}
|
apt-get update
|
||||||
|
apt-get install -y python3 python3-pip
|
||||||
|
- name: Check out repository code
|
||||||
|
if: success()
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Installing Python Dependencies
|
||||||
|
if: success()
|
||||||
|
run: python3 -m pip install --upgrade pip setuptools wheel build twine pytest --break-system-packages
|
||||||
|
- name: Build
|
||||||
|
if: success()
|
||||||
|
run: python3 -m build
|
||||||
|
- name: Publish
|
||||||
|
if: success()
|
||||||
|
run: python3 -m twine upload --repository-url "https://gitfub.space/api/packages/jmaa/pypi" -u ${{ secrets.PIPY_REPO_USER }} -p ${{ secrets.PIPY_REPO_PASS }} dist/*
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<!-- THIS IS AN AUTOGENERATED FILE! -->
|
<!-- THIS IS AN AUTOGENERATED FILE! -->
|
||||||
<!-- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! -->
|
<!-- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! -->
|
||||||
|
|
||||||
|
|
||||||
# Package-tracking
|
# Package-tracking
|
||||||
|
|
||||||

|

|
||||||
|
@ -33,11 +34,14 @@ Full list of requirements:
|
||||||
- [bottle](https://pypi.org/project/bottle/)
|
- [bottle](https://pypi.org/project/bottle/)
|
||||||
- [requests](https://pypi.org/project/requests/)
|
- [requests](https://pypi.org/project/requests/)
|
||||||
- [secret_loader](https://gitfub.space/Jmaa/secret_loader)
|
- [secret_loader](https://gitfub.space/Jmaa/secret_loader)
|
||||||
|
- [clients](https://gitfub.space/Jmaa/clients)
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Feel free to submit pull requests. Please follow the [Code Conventions](CONVENTIONS.md) when doing so.
|
Feel free to submit pull requests. Please follow the [Code Conventions](CONVENTIONS.md) when doing so.
|
||||||
|
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
Testing requires the [pytest](https://docs.pytest.org/en/stable/) library.
|
Testing requires the [pytest](https://docs.pytest.org/en/stable/) library.
|
||||||
|
@ -54,6 +58,7 @@ Test coverage can be run using the [`pytest-cov`](https://pypi.org/project/pytes
|
||||||
pytest --cov=package_tracking test
|
pytest --cov=package_tracking test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from . import http, secrets
|
|
||||||
from clients.parcelsapp import ParcelsAppClient
|
from clients.parcelsapp import ParcelsAppClient
|
||||||
|
|
||||||
|
from . import http, secrets
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = '0.1.12'
|
__version__ = '0.1.13'
|
||||||
|
|
|
@ -30,7 +30,7 @@ def get_tracking_numbers() -> list[TrackingNumberEntry]:
|
||||||
|
|
||||||
|
|
||||||
def add_tracking_number(tracking_number: TrackingNumberEntry) -> None:
|
def add_tracking_number(tracking_number: TrackingNumberEntry) -> None:
|
||||||
FILEPATH.parent.mkdir(exist_ok=True,parents=True)
|
FILEPATH.parent.mkdir(exist_ok=True, parents=True)
|
||||||
with open(FILEPATH, 'a') as f:
|
with open(FILEPATH, 'a') as f:
|
||||||
f.write(tracking_number.number)
|
f.write(tracking_number.number)
|
||||||
f.write(' ')
|
f.write(' ')
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import bottle
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from . import database
|
|
||||||
from clients.parcelsapp import ParcelsAppClient
|
import bottle
|
||||||
from clients.common import ApiError
|
from clients.common import ApiError
|
||||||
|
from clients.parcelsapp import ParcelsAppClient
|
||||||
|
|
||||||
|
from . import database
|
||||||
|
|
||||||
PARCELSAPP_CLIENT: ParcelsAppClient | None = None
|
PARCELSAPP_CLIENT: ParcelsAppClient | None = None
|
||||||
|
|
||||||
|
@ -144,6 +145,7 @@ footer {
|
||||||
|
|
||||||
TODAY = datetime.datetime.now(tz=datetime.UTC).date()
|
TODAY = datetime.datetime.now(tz=datetime.UTC).date()
|
||||||
|
|
||||||
|
|
||||||
def get_packages_from_parcels():
|
def get_packages_from_parcels():
|
||||||
tracking_entries = database.get_tracking_numbers()
|
tracking_entries = database.get_tracking_numbers()
|
||||||
tracking_numbers = [e.number for e in tracking_entries]
|
tracking_numbers = [e.number for e in tracking_entries]
|
||||||
|
@ -164,26 +166,36 @@ def get_packages_from_parcels():
|
||||||
|
|
||||||
def render_tracking(error_message: str | None = None, with_form: bool = False):
|
def render_tracking(error_message: str | None = None, with_form: bool = False):
|
||||||
tracking_results_with_name = get_packages_from_parcels()
|
tracking_results_with_name = get_packages_from_parcels()
|
||||||
tracking_results_with_name.sort(key=lambda x: x[1].latest_state().date if x[1] else TODAY, reverse=True)
|
tracking_results_with_name.sort(
|
||||||
return bottle.template(TEMPLATE, error_message=error_message, tracking_results=tracking_results_with_name, with_form=with_form)
|
key=lambda x: x[1].latest_state().date if x[1] else TODAY, reverse=True,
|
||||||
|
)
|
||||||
|
return bottle.template(
|
||||||
|
TEMPLATE,
|
||||||
|
error_message=error_message,
|
||||||
|
tracking_results=tracking_results_with_name,
|
||||||
|
with_form=with_form,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@bottle.route('/')
|
@bottle.route('/')
|
||||||
def index():
|
def index():
|
||||||
return render_tracking(with_form=True)
|
return render_tracking(with_form=True)
|
||||||
|
|
||||||
|
|
||||||
@bottle.route('/noninteraction')
|
@bottle.route('/noninteraction')
|
||||||
def inner():
|
def inner():
|
||||||
return render_tracking(with_form=False)
|
return render_tracking(with_form=False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@bottle.route('/add', method='POST')
|
@bottle.route('/add', method='POST')
|
||||||
def add_tracking_number():
|
def add_tracking_number():
|
||||||
number: str = bottle.request.forms.get('tracking-number')
|
number: str = bottle.request.forms.get('tracking-number')
|
||||||
name: str = bottle.request.forms.get('name')
|
name: str = bottle.request.forms.get('name')
|
||||||
if number is None or name is None:
|
if number is None or name is None:
|
||||||
bottle.abort(400)
|
bottle.abort(400)
|
||||||
database.add_tracking_number(database.TrackingNumberEntry(number.strip(), name.strip()))
|
database.add_tracking_number(
|
||||||
|
database.TrackingNumberEntry(number.strip(), name.strip()),
|
||||||
|
)
|
||||||
return bottle.redirect('/')
|
return bottle.redirect('/')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
bottle
|
bottle
|
||||||
requests
|
requests
|
||||||
secret_loader @ git+https://gitfub.space/Jmaa/secret_loader
|
secret_loader @ git+https://gitfub.space/Jmaa/secret_loader
|
||||||
|
clients @ git+https://gitfub.space/Jmaa/clients
|
||||||
|
|
9
setup.py
9
setup.py
|
@ -28,23 +28,29 @@ Once run, it exposes the following endpoints:
|
||||||
PACKAGE_DESCRIPTION_SHORT = """
|
PACKAGE_DESCRIPTION_SHORT = """
|
||||||
Small alternative frontend for tracking packages and parcels.""".strip()
|
Small alternative frontend for tracking packages and parcels.""".strip()
|
||||||
|
|
||||||
|
|
||||||
def parse_version_file(text: str) -> str:
|
def parse_version_file(text: str) -> str:
|
||||||
match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text)
|
text = re.sub('^#.*', '', text, flags=re.MULTILINE)
|
||||||
|
match = re.match(r'^\s*__version__\s*=\s*(["\'])([\d\.]+)\1$', text)
|
||||||
if match is None:
|
if match is None:
|
||||||
msg = 'Malformed _version.py file!'
|
msg = 'Malformed _version.py file!'
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
return match.group(2)
|
return match.group(2)
|
||||||
|
|
||||||
|
|
||||||
with open(PACKAGE_NAME + '/_version.py') as f:
|
with open(PACKAGE_NAME + '/_version.py') as f:
|
||||||
version = parse_version_file(f.read())
|
version = parse_version_file(f.read())
|
||||||
|
|
||||||
|
|
||||||
REQUIREMENTS_MAIN = [
|
REQUIREMENTS_MAIN = [
|
||||||
'bottle',
|
'bottle',
|
||||||
'requests',
|
'requests',
|
||||||
'secret_loader @ git+https://gitfub.space/Jmaa/secret_loader',
|
'secret_loader @ git+https://gitfub.space/Jmaa/secret_loader',
|
||||||
|
'clients @ git+https://gitfub.space/Jmaa/clients',
|
||||||
]
|
]
|
||||||
REQUIREMENTS_TEST = []
|
REQUIREMENTS_TEST = []
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=PACKAGE_NAME,
|
name=PACKAGE_NAME,
|
||||||
version=version,
|
version=version,
|
||||||
|
@ -54,7 +60,6 @@ setup(
|
||||||
author='Jon Michael Aanes',
|
author='Jon Michael Aanes',
|
||||||
author_email='jonjmaa@gmail.com',
|
author_email='jonjmaa@gmail.com',
|
||||||
url='https://gitfub.space/Jmaa/' + PACKAGE_NAME,
|
url='https://gitfub.space/Jmaa/' + PACKAGE_NAME,
|
||||||
packages=[PACKAGE_NAME],
|
|
||||||
install_requires=REQUIREMENTS_MAIN,
|
install_requires=REQUIREMENTS_MAIN,
|
||||||
extras_require={
|
extras_require={
|
||||||
'test': REQUIREMENTS_TEST,
|
'test': REQUIREMENTS_TEST,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
def test_import_modules():
|
def test_import_modules():
|
||||||
import package_tracking # noqa
|
import package_tracking # noqa
|
||||||
import package_tracking.database # noqa
|
import package_tracking.database # noqa
|
||||||
|
|
Loading…
Reference in New Issue
Block a user