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']
|
||||
|
||||
jobs:
|
||||
Package-Container:
|
||||
uses: jmaa/workflows/.gitea/workflows/container.yaml@v6.21
|
||||
with:
|
||||
REGISTRY_DOMAIN: gitfub.space
|
||||
REGISTRY_ORGANIZATION: jmaa
|
||||
secrets:
|
||||
DOCKER_USERNAME: ${{ secrets.PIPY_REPO_USER }}
|
||||
DOCKER_PASSWORD: ${{ secrets.PIPY_REPO_PASS }}
|
||||
PIPELINE_WORKER_SSH_KEY: ${{ secrets.PIPELINE_WORKER_SSH_KEY }}
|
||||
PIPELINE_WORKER_KNOWN_HOSTS: ${{ secrets.PIPELINE_WORKER_KNOWN_HOSTS }}
|
||||
release-image:
|
||||
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:
|
||||
key: ${{ secrets.PIPELINE_WORKER_SSH_KEY }}
|
||||
name: id_rsa
|
||||
known_hosts: ${{ secrets.PIPELINE_WORKER_KNOWN_HOSTS }}
|
||||
config: |
|
||||
Host gitfub
|
||||
HostName gitfub.space
|
||||
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']
|
||||
|
||||
jobs:
|
||||
Package:
|
||||
uses: jmaa/workflows/.gitea/workflows/python-package.yaml@v6.21
|
||||
with:
|
||||
REGISTRY_DOMAIN: gitfub.space
|
||||
REGISTRY_ORGANIZATION: jmaa
|
||||
secrets:
|
||||
PIPY_REPO_USER: ${{ secrets.PIPY_REPO_USER }}
|
||||
PIPY_REPO_PASS: ${{ secrets.PIPY_REPO_PASS }}
|
||||
Package-Python-And-Publish:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: node:21-bookworm
|
||||
steps:
|
||||
- name: Setting up Python ${{ env.PYTHON_VERSION }} for ${{runner.arch}} ${{runner.os}}
|
||||
run: |
|
||||
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! -->
|
||||
<!-- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! -->
|
||||
|
||||
|
||||
# Package-tracking
|
||||
|
||||

|
||||
|
@ -33,11 +34,14 @@ Full list of requirements:
|
|||
- [bottle](https://pypi.org/project/bottle/)
|
||||
- [requests](https://pypi.org/project/requests/)
|
||||
- [secret_loader](https://gitfub.space/Jmaa/secret_loader)
|
||||
- [clients](https://gitfub.space/Jmaa/clients)
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Feel free to submit pull requests. Please follow the [Code Conventions](CONVENTIONS.md) when doing so.
|
||||
|
||||
|
||||
### Testing
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
```
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import logging
|
||||
|
||||
import requests
|
||||
from . import http, secrets
|
||||
from clients.parcelsapp import ParcelsAppClient
|
||||
|
||||
from . import http, secrets
|
||||
|
||||
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:
|
||||
FILEPATH.parent.mkdir(exist_ok=True,parents=True)
|
||||
FILEPATH.parent.mkdir(exist_ok=True, parents=True)
|
||||
with open(FILEPATH, 'a') as f:
|
||||
f.write(tracking_number.number)
|
||||
f.write(' ')
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import bottle
|
||||
|
||||
import datetime
|
||||
from . import database
|
||||
from clients.parcelsapp import ParcelsAppClient
|
||||
|
||||
import bottle
|
||||
from clients.common import ApiError
|
||||
from clients.parcelsapp import ParcelsAppClient
|
||||
|
||||
from . import database
|
||||
|
||||
PARCELSAPP_CLIENT: ParcelsAppClient | None = None
|
||||
|
||||
|
@ -144,6 +145,7 @@ footer {
|
|||
|
||||
TODAY = datetime.datetime.now(tz=datetime.UTC).date()
|
||||
|
||||
|
||||
def get_packages_from_parcels():
|
||||
tracking_entries = database.get_tracking_numbers()
|
||||
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):
|
||||
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)
|
||||
return bottle.template(TEMPLATE, error_message=error_message, tracking_results=tracking_results_with_name, with_form=with_form)
|
||||
tracking_results_with_name.sort(
|
||||
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('/')
|
||||
def index():
|
||||
return render_tracking(with_form=True)
|
||||
|
||||
|
||||
@bottle.route('/noninteraction')
|
||||
def inner():
|
||||
return render_tracking(with_form=False)
|
||||
|
||||
|
||||
|
||||
@bottle.route('/add', method='POST')
|
||||
def add_tracking_number():
|
||||
number: str = bottle.request.forms.get('tracking-number')
|
||||
name: str = bottle.request.forms.get('name')
|
||||
if number is None or name is None:
|
||||
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('/')
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
bottle
|
||||
requests
|
||||
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 = """
|
||||
Small alternative frontend for tracking packages and parcels.""".strip()
|
||||
|
||||
|
||||
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:
|
||||
msg = 'Malformed _version.py file!'
|
||||
raise Exception(msg)
|
||||
return match.group(2)
|
||||
|
||||
|
||||
with open(PACKAGE_NAME + '/_version.py') as f:
|
||||
version = parse_version_file(f.read())
|
||||
|
||||
|
||||
REQUIREMENTS_MAIN = [
|
||||
'bottle',
|
||||
'requests',
|
||||
'secret_loader @ git+https://gitfub.space/Jmaa/secret_loader',
|
||||
'clients @ git+https://gitfub.space/Jmaa/clients',
|
||||
]
|
||||
REQUIREMENTS_TEST = []
|
||||
|
||||
|
||||
setup(
|
||||
name=PACKAGE_NAME,
|
||||
version=version,
|
||||
|
@ -54,7 +60,6 @@ setup(
|
|||
author='Jon Michael Aanes',
|
||||
author_email='jonjmaa@gmail.com',
|
||||
url='https://gitfub.space/Jmaa/' + PACKAGE_NAME,
|
||||
packages=[PACKAGE_NAME],
|
||||
install_requires=REQUIREMENTS_MAIN,
|
||||
extras_require={
|
||||
'test': REQUIREMENTS_TEST,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
def test_import_modules():
|
||||
import package_tracking # noqa
|
||||
import package_tracking.database # noqa
|
||||
import package_tracking.http # noqa
|
||||
import package_tracking # noqa
|
||||
import package_tracking.database # noqa
|
||||
import package_tracking.http # noqa
|
||||
|
|
Loading…
Reference in New Issue
Block a user