Lokalen Rechnungsassistenten mit Vorlagen und PDF-Vorschau ergänzen
This commit is contained in:
1 parent
f447603af4
commit
b9f307fc81
15 files changed
+1423
-26
No files matched your search
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Install per-user launchers without sudo or changing shell configuration."""
|
||||
"""Starter im Benutzer-Suchpfad ohne sudo oder Änderungen an der Shell einrichten."""
|
||||
import argparse
|
||||
from datetime import datetime, timezone
|
||||
import os
|
||||
@@ -15,7 +15,7 @@ def install(bin_dir: Path) -> None:
|
||||
bin_dir.mkdir(parents=True, exist_ok=True)
|
||||
changed = []
|
||||
try:
|
||||
for name in ('einvoice', 'jr-einvoice'):
|
||||
for name in ('einvoice', 'jr-einvoice', 'einvoice-ui'):
|
||||
source = root / 'bin' / name
|
||||
target = bin_dir / name
|
||||
if target.is_symlink() and target.resolve() == source:
|
||||
@@ -41,7 +41,7 @@ def install(bin_dir: Path) -> None:
|
||||
temporary.unlink(missing_ok=True)
|
||||
changed.append((target, backup))
|
||||
print(f'Eingerichtet: {target} -> {source}', flush=True)
|
||||
# A different cwd verifies that symlinks resolve to the checkout correctly.
|
||||
# Aus fremdem Verzeichnis die Auflösung der Konsolenstarter prüfen.
|
||||
for name in ('einvoice', 'jr-einvoice'):
|
||||
subprocess.run([str(bin_dir / name), '--help'], cwd=bin_dir,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True)
|
||||
@@ -56,16 +56,30 @@ def install(bin_dir: Path) -> None:
|
||||
if str(bin_dir) not in os.environ.get('PATH', '').split(os.pathsep):
|
||||
import shlex
|
||||
print(f'Für diese Shell ausführen: export PATH={shlex.quote(str(bin_dir))}:"$PATH"')
|
||||
print('Ab jetzt: einvoice --help | einvoice --update --status | jr-einvoice --help')
|
||||
print('Ab jetzt: einvoice --help | einvoice-ui | einvoice --update --status | jr-einvoice --help')
|
||||
print('Falls die Shell noch den alten Pfad merkt: rehash (zsh) bzw. hash -r (bash).')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='einvoice und jr-einvoice im Benutzer-Suchpfad einrichten.')
|
||||
parser.add_argument('--bin-dir', type=Path, default=Path.home() / '.local/bin')
|
||||
parser.add_argument('--desktop', action='store_true', help='Zusätzlich einen Eintrag im Anwendungsmenü installieren')
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
install(args.bin_dir)
|
||||
if args.desktop:
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
applications = Path(os.environ.get('XDG_DATA_HOME', Path.home() / '.local/share')) / 'applications'
|
||||
applications.mkdir(parents=True, exist_ok=True)
|
||||
launcher = str(root / 'bin/einvoice-ui').replace('%', '%%')
|
||||
for char in ('\\', '"', '`', '$'):
|
||||
launcher = launcher.replace(char, '\\' + char)
|
||||
entry = applications / 'de.jr-it-services.einvoice.desktop'
|
||||
entry.write_text('[Desktop Entry]\nType=Application\nName=JR eInvoice\n'
|
||||
'Comment=E-Rechnungen erstellen und als PDF ansehen\n'
|
||||
f'Exec="{launcher}"\nIcon={root / "assets/logo.svg"}\n'
|
||||
'Terminal=false\nCategories=Office;Finance;\nStartupNotify=true\n', encoding='utf-8')
|
||||
print(f'Anwendungsmenü eingerichtet: {entry}')
|
||||
except (Exception, KeyboardInterrupt) as exc:
|
||||
print(f'FEHLER: {exc}; geänderte Befehle wurden zurückgesetzt.', file=sys.stderr)
|
||||
if isinstance(exc, subprocess.CalledProcessError) and exc.stderr:
|
||||
|
||||
Reference in new issue
Block a user