snapcraft update

This commit is contained in:
alex
2024-10-16 13:45:10 +02:00
parent 375ae7fb99
commit e590e65a4b
2 changed files with 32 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
import os
import click import click
import qrcode import qrcode
from PIL import Image from PIL import Image
@@ -13,7 +15,7 @@ from qrcode.image.styles.moduledrawers.pil import RoundedModuleDrawer
help='Output file path (defaults to "./qrcode.png")', help='Output file path (defaults to "./qrcode.png")',
) )
@click.argument("url") @click.argument("url")
def generate(output_file, url): def create(output_file, url):
qr = qrcode.QRCode( qr = qrcode.QRCode(
version=1, version=1,
error_correction=qrcode.constants.ERROR_CORRECT_H, error_correction=qrcode.constants.ERROR_CORRECT_H,
@@ -29,11 +31,11 @@ def generate(output_file, url):
back_color=(255, 255, 255), front_color=(233, 84, 32) back_color=(255, 255, 255), front_color=(233, 84, 32)
), ),
module_drawer=RoundedModuleDrawer(), module_drawer=RoundedModuleDrawer(),
embeded_image_path="assets/canonical.png", embeded_image_path=f"{os.environ.get("SNAP")}/assets/canonical.png",
) )
qri.save(output_file) qri.save(output_file)
if __name__ == "__main__": if __name__ == "__main__":
generate() create()

27
snap/snapcraft.yaml Normal file
View File

@@ -0,0 +1,27 @@
name: cqrcode # you probably want to 'snapcraft register <name>'
base: core24 # the base snap is the execution environment for this snap
version: '1.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: Create QR codes flying Canonical colors. # 79 char long summary
description: |
TODO
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots
parts:
venv:
# See 'snapcraft plugins'
plugin: python
source-type: local
source: .
python-requirements:
- requirements.txt
source:
plugin: dump
source: .
apps:
create:
command: bin/python $SNAP/main.py
plugs:
- home