zebra-day 2.0.0__py3-none-any.whl → 2.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zebra_day/__init__.py +7 -2
- zebra_day/_version.py +1 -0
- zebra_day/cli/__init__.py +80 -30
- zebra_day/cli/cognito.py +15 -9
- zebra_day/cli/gui.py +21 -16
- zebra_day/cli/printer.py +34 -27
- zebra_day/cli/template.py +19 -15
- zebra_day/cmd_mgr.py +3 -6
- zebra_day/docs/gx420d-gx430d-ug-en.pdf +0 -0
- zebra_day/docs/hardware_config_guide.md +149 -0
- zebra_day/docs/programatic_guide.md +181 -0
- zebra_day/docs/qln420_zebra_manual.pdf +0 -0
- zebra_day/docs/uid_screed_light.md +38 -0
- zebra_day/docs/zd620-zd420-ug-en.pdf +0 -0
- zebra_day/docs/zebra_day_ui_guide.md +194 -0
- zebra_day/etc/printer_config.json +7 -1
- zebra_day/etc/printer_config.template.json +3 -17
- zebra_day/etc/tmp_printers139.json +10 -0
- zebra_day/etc/tmp_printers147.json +10 -0
- zebra_day/etc/tmp_printers34.json +10 -0
- zebra_day/etc/tmp_printers389.json +10 -0
- zebra_day/etc/tmp_printers398.json +10 -0
- zebra_day/etc/tmp_printers437.json +10 -0
- zebra_day/etc/tmp_printers439.json +10 -0
- zebra_day/etc/tmp_printers440.json +10 -0
- zebra_day/etc/tmp_printers508.json +10 -0
- zebra_day/etc/tmp_printers543.json +10 -0
- zebra_day/etc/tmp_printers835.json +10 -0
- zebra_day/etc/tmp_printers842.json +10 -0
- zebra_day/etc/tmp_printers931.json +10 -0
- zebra_day/etc/tmp_printers969.json +10 -0
- zebra_day/exceptions.py +1 -1
- zebra_day/files/corners_smallTube_preview.png +0 -0
- zebra_day/files/test_png_2897.png +0 -0
- zebra_day/files/test_png_31690.png +0 -0
- zebra_day/files/test_png_33804.png +0 -0
- zebra_day/files/test_png_34737.png +0 -0
- zebra_day/files/test_png_4161.png +0 -0
- zebra_day/files/test_png_44748.png +0 -0
- zebra_day/files/test_png_4635.png +0 -0
- zebra_day/files/test_png_56349.png +0 -0
- zebra_day/files/test_png_5936.png +0 -0
- zebra_day/files/test_png_64110.png +0 -0
- zebra_day/files/test_png_64891.png +0 -0
- zebra_day/files/test_png_69002.png +0 -0
- zebra_day/files/test_png_70065.png +0 -0
- zebra_day/files/test_png_72366.png +0 -0
- zebra_day/files/test_png_77793.png +0 -0
- zebra_day/files/test_png_9572.png +0 -0
- zebra_day/imgs/.hold +0 -0
- zebra_day/imgs/bar_ltpurp.png +0 -0
- zebra_day/imgs/bar_purp.png +0 -0
- zebra_day/imgs/bar_purp3.png +0 -0
- zebra_day/imgs/bar_red.png +0 -0
- zebra_day/imgs/legacy/UBC_gantt_chart.png +0 -0
- zebra_day/imgs/legacy/gx420d_network_config.png +0 -0
- zebra_day/imgs/legacy/gx420d_printer_config.png +0 -0
- zebra_day/imgs/legacy/ngrok.png +0 -0
- zebra_day/imgs/legacy/printer_details.png +0 -0
- zebra_day/imgs/legacy/quick_start_test_label.png +0 -0
- zebra_day/imgs/legacy/quick_start_test_label2.png +0 -0
- zebra_day/imgs/legacy/zd620_network_config.png +0 -0
- zebra_day/imgs/legacy/zd620_printer_config.png +0 -0
- zebra_day/imgs/legacy/zday_quick_gui.png +0 -0
- zebra_day/imgs/legacy/zebra_day_alt_css_dog.png +0 -0
- zebra_day/imgs/legacy/zebra_day_alt_css_flower.png +0 -0
- zebra_day/imgs/legacy/zebra_day_alt_css_main.png +0 -0
- zebra_day/imgs/legacy/zebra_day_available_zpl_templates.png +0 -0
- zebra_day/imgs/legacy/zebra_day_bkup_pconfig.png +0 -0
- zebra_day/imgs/legacy/zebra_day_home.png +0 -0
- zebra_day/imgs/legacy/zebra_day_manual_print.png +0 -0
- zebra_day/imgs/legacy/zebra_day_printer_fleet_json.png +0 -0
- zebra_day/imgs/legacy/zebra_day_quick_ex.png +0 -0
- zebra_day/imgs/legacy/zebra_day_zpl_template_IRLa.png +0 -0
- zebra_day/imgs/legacy/zebra_day_zpl_template_IRLb.png +0 -0
- zebra_day/imgs/ui_api_docs.png +0 -0
- zebra_day/imgs/ui_config.png +0 -0
- zebra_day/imgs/ui_dashboard.png +0 -0
- zebra_day/imgs/ui_print_request.png +0 -0
- zebra_day/imgs/ui_printers.png +0 -0
- zebra_day/imgs/ui_templates.png +0 -0
- zebra_day/logging_config.py +4 -9
- zebra_day/mkcert.py +157 -0
- zebra_day/paths.py +1 -2
- zebra_day/print_mgr.py +165 -145
- zebra_day/templates/modern/config.html +7 -0
- zebra_day/templates/modern/print_request.html +61 -3
- zebra_day/web/__init__.py +1 -1
- zebra_day/web/app.py +21 -16
- zebra_day/web/auth.py +17 -15
- zebra_day/web/middleware.py +8 -5
- zebra_day/web/routers/__init__.py +0 -1
- zebra_day/web/routers/api.py +192 -43
- zebra_day/web/routers/ui.py +31 -33
- zebra_day/zpl_renderer.py +45 -34
- {zebra_day-2.0.0.dist-info → zebra_day-2.1.4.dist-info}/METADATA +76 -67
- {zebra_day-2.0.0.dist-info → zebra_day-2.1.4.dist-info}/RECORD +101 -29
- {zebra_day-2.0.0.dist-info → zebra_day-2.1.4.dist-info}/WHEEL +0 -0
- {zebra_day-2.0.0.dist-info → zebra_day-2.1.4.dist-info}/entry_points.txt +0 -0
- {zebra_day-2.0.0.dist-info → zebra_day-2.1.4.dist-info}/licenses/LICENSE +0 -0
- {zebra_day-2.0.0.dist-info → zebra_day-2.1.4.dist-info}/top_level.txt +0 -0
zebra_day/mkcert.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""
|
|
2
|
+
mkcert integration for zebra_day HTTPS certificate management.
|
|
3
|
+
|
|
4
|
+
This module provides utilities to:
|
|
5
|
+
- Check if mkcert is installed
|
|
6
|
+
- Check if the local CA is installed
|
|
7
|
+
- Generate locally-trusted certificates for the zebra_day server
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
import shutil
|
|
12
|
+
import subprocess
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
from zebra_day import paths as xdg
|
|
16
|
+
|
|
17
|
+
_log = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
# Default certificate locations
|
|
20
|
+
CERT_DIR = xdg.get_config_dir() / "certs"
|
|
21
|
+
CERT_FILE = CERT_DIR / "server.crt"
|
|
22
|
+
KEY_FILE = CERT_DIR / "server.key"
|
|
23
|
+
|
|
24
|
+
# Hostnames to include in the certificate
|
|
25
|
+
DEFAULT_HOSTNAMES = ["localhost", "127.0.0.1", "::1"]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def is_mkcert_installed() -> bool:
|
|
29
|
+
"""Check if mkcert is available in PATH."""
|
|
30
|
+
return shutil.which("mkcert") is not None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def is_ca_installed() -> bool:
|
|
34
|
+
"""Check if the mkcert local CA is installed.
|
|
35
|
+
|
|
36
|
+
Returns True if mkcert reports the CA is installed, False otherwise.
|
|
37
|
+
"""
|
|
38
|
+
if not is_mkcert_installed():
|
|
39
|
+
return False
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
result = subprocess.run(
|
|
43
|
+
["mkcert", "-CAROOT"],
|
|
44
|
+
capture_output=True,
|
|
45
|
+
text=True,
|
|
46
|
+
timeout=10,
|
|
47
|
+
)
|
|
48
|
+
if result.returncode == 0 and result.stdout.strip():
|
|
49
|
+
ca_root = Path(result.stdout.strip())
|
|
50
|
+
# Check if the CA files exist
|
|
51
|
+
return (ca_root / "rootCA.pem").exists()
|
|
52
|
+
except (subprocess.TimeoutExpired, OSError) as e:
|
|
53
|
+
_log.debug("Error checking CA status: %s", e)
|
|
54
|
+
|
|
55
|
+
return False
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def install_ca() -> bool:
|
|
59
|
+
"""Install the mkcert local CA (requires user interaction for password).
|
|
60
|
+
|
|
61
|
+
Returns True if successful, False otherwise.
|
|
62
|
+
"""
|
|
63
|
+
if not is_mkcert_installed():
|
|
64
|
+
_log.error("mkcert is not installed")
|
|
65
|
+
return False
|
|
66
|
+
|
|
67
|
+
try:
|
|
68
|
+
result = subprocess.run(
|
|
69
|
+
["mkcert", "-install"],
|
|
70
|
+
capture_output=True,
|
|
71
|
+
text=True,
|
|
72
|
+
timeout=60,
|
|
73
|
+
)
|
|
74
|
+
if result.returncode == 0:
|
|
75
|
+
_log.info("mkcert CA installed successfully")
|
|
76
|
+
return True
|
|
77
|
+
else:
|
|
78
|
+
_log.error("Failed to install CA: %s", result.stderr)
|
|
79
|
+
return False
|
|
80
|
+
except subprocess.TimeoutExpired:
|
|
81
|
+
_log.error("CA installation timed out")
|
|
82
|
+
return False
|
|
83
|
+
except OSError as e:
|
|
84
|
+
_log.error("Error installing CA: %s", e)
|
|
85
|
+
return False
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def certificates_exist() -> bool:
|
|
89
|
+
"""Check if certificates already exist."""
|
|
90
|
+
return CERT_FILE.exists() and KEY_FILE.exists()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def generate_certificates(
|
|
94
|
+
hostnames: list[str] | None = None,
|
|
95
|
+
cert_file: Path | None = None,
|
|
96
|
+
key_file: Path | None = None,
|
|
97
|
+
force: bool = False,
|
|
98
|
+
) -> bool:
|
|
99
|
+
"""Generate locally-trusted certificates using mkcert.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
hostnames: List of hostnames/IPs to include. Defaults to localhost, 127.0.0.1, ::1
|
|
103
|
+
cert_file: Path for certificate file. Defaults to ~/.config/zebra_day/certs/server.crt
|
|
104
|
+
key_file: Path for private key file. Defaults to ~/.config/zebra_day/certs/server.key
|
|
105
|
+
force: If True, regenerate even if certificates exist
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
True if certificates were generated successfully, False otherwise.
|
|
109
|
+
"""
|
|
110
|
+
if not is_mkcert_installed():
|
|
111
|
+
_log.error(
|
|
112
|
+
"mkcert is not installed. Install with: brew install mkcert (macOS) or apt install mkcert (Ubuntu)"
|
|
113
|
+
)
|
|
114
|
+
return False
|
|
115
|
+
|
|
116
|
+
cert_path = cert_file or CERT_FILE
|
|
117
|
+
key_path = key_file or KEY_FILE
|
|
118
|
+
hosts = hostnames or DEFAULT_HOSTNAMES
|
|
119
|
+
|
|
120
|
+
# Check if certificates already exist
|
|
121
|
+
if not force and cert_path.exists() and key_path.exists():
|
|
122
|
+
_log.info("Certificates already exist at %s", cert_path)
|
|
123
|
+
return True
|
|
124
|
+
|
|
125
|
+
# Ensure directory exists
|
|
126
|
+
cert_path.parent.mkdir(parents=True, exist_ok=True)
|
|
127
|
+
|
|
128
|
+
try:
|
|
129
|
+
cmd = [
|
|
130
|
+
"mkcert",
|
|
131
|
+
"-cert-file",
|
|
132
|
+
str(cert_path),
|
|
133
|
+
"-key-file",
|
|
134
|
+
str(key_path),
|
|
135
|
+
*hosts,
|
|
136
|
+
]
|
|
137
|
+
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
|
|
138
|
+
|
|
139
|
+
if result.returncode == 0:
|
|
140
|
+
_log.info("Certificates generated: %s", cert_path)
|
|
141
|
+
return True
|
|
142
|
+
else:
|
|
143
|
+
_log.error("Failed to generate certificates: %s", result.stderr)
|
|
144
|
+
return False
|
|
145
|
+
except subprocess.TimeoutExpired:
|
|
146
|
+
_log.error("Certificate generation timed out")
|
|
147
|
+
return False
|
|
148
|
+
except OSError as e:
|
|
149
|
+
_log.error("Error generating certificates: %s", e)
|
|
150
|
+
return False
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def get_cert_paths() -> tuple[Path | None, Path | None]:
|
|
154
|
+
"""Get certificate paths if they exist."""
|
|
155
|
+
if certificates_exist():
|
|
156
|
+
return CERT_FILE, KEY_FILE
|
|
157
|
+
return None, None
|
zebra_day/paths.py
CHANGED
|
@@ -13,12 +13,12 @@ XDG Base Directory Specification:
|
|
|
13
13
|
On macOS, we use ~/Library/Application Support for data and
|
|
14
14
|
~/Library/Preferences for config, but support XDG overrides.
|
|
15
15
|
"""
|
|
16
|
+
|
|
16
17
|
from __future__ import annotations
|
|
17
18
|
|
|
18
19
|
import os
|
|
19
20
|
import sys
|
|
20
21
|
from pathlib import Path
|
|
21
|
-
from typing import Optional
|
|
22
22
|
|
|
23
23
|
APP_NAME = "zebra_day"
|
|
24
24
|
|
|
@@ -140,4 +140,3 @@ def get_generated_files_dir() -> Path:
|
|
|
140
140
|
files_dir = get_cache_dir() / "generated"
|
|
141
141
|
files_dir.mkdir(parents=True, exist_ok=True)
|
|
142
142
|
return files_dir
|
|
143
|
-
|