zebra-day 1.0.2__py3-none-any.whl → 2.0.0__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.
Files changed (86) hide show
  1. zebra_day/cli/gui.py +89 -6
  2. zebra_day/etc/printer_config.json +2 -14
  3. zebra_day/etc/printer_config.template.json +17 -9
  4. zebra_day/etc/tmp_printers120.json +10 -0
  5. zebra_day/etc/tmp_printers145.json +10 -0
  6. zebra_day/etc/tmp_printers207.json +10 -0
  7. zebra_day/etc/tmp_printers469.json +10 -0
  8. zebra_day/etc/tmp_printers485.json +10 -0
  9. zebra_day/etc/tmp_printers531.json +10 -0
  10. zebra_day/etc/tmp_printers540.json +10 -0
  11. zebra_day/etc/tmp_printers542.json +10 -0
  12. zebra_day/etc/tmp_printers552.json +10 -0
  13. zebra_day/etc/tmp_printers715.json +10 -0
  14. zebra_day/etc/tmp_printers972.json +10 -0
  15. zebra_day/files/blank_preview.png +0 -0
  16. zebra_day/files/corners_20cmX30cm_preview.png +0 -0
  17. zebra_day/files/generic_2inX1in_preview.png +0 -0
  18. zebra_day/files/test_png_12020.png +0 -0
  19. zebra_day/files/test_png_12352.png +0 -0
  20. zebra_day/files/test_png_15472.png +0 -0
  21. zebra_day/files/test_png_24493.png +0 -0
  22. zebra_day/files/test_png_30069.png +0 -0
  23. zebra_day/files/test_png_47791.png +0 -0
  24. zebra_day/files/test_png_47799.png +0 -0
  25. zebra_day/files/test_png_55588.png +0 -0
  26. zebra_day/files/test_png_58809.png +0 -0
  27. zebra_day/files/test_png_67242.png +0 -0
  28. zebra_day/files/test_png_89893.png +0 -0
  29. zebra_day/files/tube_20mmX30mmA_preview.png +0 -0
  30. zebra_day/print_mgr.py +136 -80
  31. zebra_day/templates/modern/config_backups.html +59 -0
  32. zebra_day/templates/modern/config_editor.html +95 -0
  33. zebra_day/templates/modern/config_new.html +93 -0
  34. zebra_day/templates/modern/print_request.html +9 -5
  35. zebra_day/templates/modern/printer_detail.html +161 -34
  36. zebra_day/templates/modern/printers.html +17 -6
  37. zebra_day/templates/modern/template_editor.html +7 -4
  38. zebra_day/web/app.py +84 -7
  39. zebra_day/web/routers/api.py +155 -5
  40. zebra_day/web/routers/ui.py +155 -570
  41. {zebra_day-1.0.2.dist-info → zebra_day-2.0.0.dist-info}/METADATA +74 -13
  42. {zebra_day-1.0.2.dist-info → zebra_day-2.0.0.dist-info}/RECORD +46 -57
  43. zebra_day/bin/fetch_zebra_config.py +0 -15
  44. zebra_day/bin/generate_coord_grid_zpl.py +0 -50
  45. zebra_day/bin/print_zpl_from_file.py +0 -21
  46. zebra_day/bin/probe_new_label_dimensions.py +0 -75
  47. zebra_day/bin/scan_for_networed_zebra_printers.py +0 -23
  48. zebra_day/bin/scan_for_networed_zebra_printers_arp_scan.sh +0 -1
  49. zebra_day/bin/scan_for_networed_zebra_printers_curl.sh +0 -30
  50. zebra_day/bin/zserve.py +0 -1062
  51. zebra_day/templates/base.html +0 -36
  52. zebra_day/templates/bpr.html +0 -72
  53. zebra_day/templates/build_new_config.html +0 -36
  54. zebra_day/templates/build_print_request.html +0 -32
  55. zebra_day/templates/chg_ui_style.html +0 -19
  56. zebra_day/templates/edit_template.html +0 -128
  57. zebra_day/templates/edit_zpl.html +0 -37
  58. zebra_day/templates/index.html +0 -82
  59. zebra_day/templates/legacy/base.html +0 -37
  60. zebra_day/templates/legacy/bpr.html +0 -72
  61. zebra_day/templates/legacy/build_new_config.html +0 -36
  62. zebra_day/templates/legacy/build_print_request.html +0 -32
  63. zebra_day/templates/legacy/chg_ui_style.html +0 -19
  64. zebra_day/templates/legacy/edit_template.html +0 -128
  65. zebra_day/templates/legacy/edit_zpl.html +0 -37
  66. zebra_day/templates/legacy/index.html +0 -82
  67. zebra_day/templates/legacy/list_prior_configs.html +0 -24
  68. zebra_day/templates/legacy/print_result.html +0 -30
  69. zebra_day/templates/legacy/printer_details.html +0 -25
  70. zebra_day/templates/legacy/printer_status.html +0 -70
  71. zebra_day/templates/legacy/save_result.html +0 -17
  72. zebra_day/templates/legacy/send_print_request.html +0 -34
  73. zebra_day/templates/legacy/simple_print.html +0 -94
  74. zebra_day/templates/legacy/view_pstation_json.html +0 -29
  75. zebra_day/templates/list_prior_configs.html +0 -24
  76. zebra_day/templates/print_result.html +0 -30
  77. zebra_day/templates/printer_details.html +0 -25
  78. zebra_day/templates/printer_status.html +0 -70
  79. zebra_day/templates/save_result.html +0 -17
  80. zebra_day/templates/send_print_request.html +0 -34
  81. zebra_day/templates/simple_print.html +0 -94
  82. zebra_day/templates/view_pstation_json.html +0 -29
  83. {zebra_day-1.0.2.dist-info → zebra_day-2.0.0.dist-info}/WHEEL +0 -0
  84. {zebra_day-1.0.2.dist-info → zebra_day-2.0.0.dist-info}/entry_points.txt +0 -0
  85. {zebra_day-1.0.2.dist-info → zebra_day-2.0.0.dist-info}/licenses/LICENSE +0 -0
  86. {zebra_day-1.0.2.dist-info → zebra_day-2.0.0.dist-info}/top_level.txt +0 -0
zebra_day/cli/gui.py CHANGED
@@ -20,7 +20,11 @@ console = Console()
20
20
  # PID and log file locations
21
21
  STATE_DIR = xdg.get_state_dir()
22
22
  LOG_DIR = xdg.get_logs_dir()
23
+ CONFIG_DIR = xdg.get_config_dir()
23
24
  PID_FILE = STATE_DIR / "gui.pid"
25
+ DEFAULT_CERT_DIR = CONFIG_DIR / "certs"
26
+ DEFAULT_CERT_FILE = DEFAULT_CERT_DIR / "server.crt"
27
+ DEFAULT_KEY_FILE = DEFAULT_CERT_DIR / "server.key"
24
28
 
25
29
 
26
30
  def _ensure_dirs():
@@ -62,6 +66,43 @@ def _check_auth_dependencies() -> bool:
62
66
  return False
63
67
 
64
68
 
69
+ def _resolve_ssl_paths(
70
+ cert: Optional[str], key: Optional[str]
71
+ ) -> tuple[Optional[str], Optional[str], bool]:
72
+ """
73
+ Resolve SSL certificate and key paths.
74
+
75
+ Priority:
76
+ 1. Explicit --cert/--key arguments
77
+ 2. SSL_CERT_PATH/SSL_KEY_PATH environment variables
78
+ 3. Default paths in ~/.config/zebra_day/certs/
79
+
80
+ Returns:
81
+ Tuple of (cert_path, key_path, use_https)
82
+ """
83
+ cert_path = cert
84
+ key_path = key
85
+
86
+ # Check environment variables
87
+ if not cert_path:
88
+ cert_path = os.environ.get("SSL_CERT_PATH")
89
+ if not key_path:
90
+ key_path = os.environ.get("SSL_KEY_PATH")
91
+
92
+ # Check default paths
93
+ if not cert_path and DEFAULT_CERT_FILE.exists():
94
+ cert_path = str(DEFAULT_CERT_FILE)
95
+ if not key_path and DEFAULT_KEY_FILE.exists():
96
+ key_path = str(DEFAULT_KEY_FILE)
97
+
98
+ # Validate both exist
99
+ if cert_path and key_path:
100
+ if Path(cert_path).exists() and Path(key_path).exists():
101
+ return cert_path, key_path, True
102
+
103
+ return None, None, False
104
+
105
+
65
106
  @gui_app.command("start")
66
107
  def start(
67
108
  port: int = typer.Option(8118, "--port", "-p", help="Port to run the server on"),
@@ -69,8 +110,19 @@ def start(
69
110
  auth: str = typer.Option("none", "--auth", "-a", help="Authentication mode: none or cognito"),
70
111
  reload: bool = typer.Option(False, "--reload", "-r", help="Enable auto-reload (foreground)"),
71
112
  background: bool = typer.Option(True, "--background/--foreground", "-b/-f", help="Run in background"),
113
+ cert: Optional[str] = typer.Option(None, "--cert", help="Path to SSL certificate file"),
114
+ key: Optional[str] = typer.Option(None, "--key", help="Path to SSL private key file"),
115
+ no_https: bool = typer.Option(False, "--no-https", help="Disable HTTPS even if certificates are available"),
72
116
  ):
73
- """Start the zebra_day web UI server."""
117
+ """Start the zebra_day web UI server.
118
+
119
+ By default, HTTPS is enabled if certificates are found in:
120
+ - Explicit --cert/--key arguments
121
+ - SSL_CERT_PATH/SSL_KEY_PATH environment variables
122
+ - ~/.config/zebra_day/certs/server.crt and server.key
123
+
124
+ Use --no-https to force HTTP mode.
125
+ """
74
126
  _ensure_dirs()
75
127
 
76
128
  # Validate auth option
@@ -105,17 +157,45 @@ def start(
105
157
  raise typer.Exit(1)
106
158
  console.print("[green]✓[/green] Cognito authentication enabled")
107
159
 
108
- # Build command
160
+ # Resolve SSL paths
161
+ cert_path, key_path, use_https = _resolve_ssl_paths(cert, key)
162
+
163
+ if no_https:
164
+ use_https = False
165
+ cert_path = None
166
+ key_path = None
167
+
168
+ protocol = "https" if use_https else "http"
169
+
170
+ if use_https:
171
+ console.print(f"[green]✓[/green] HTTPS enabled")
172
+ console.print(f" Certificate: [dim]{cert_path}[/dim]")
173
+ console.print(f" Private key: [dim]{key_path}[/dim]")
174
+ else:
175
+ console.print("[yellow]⚠[/yellow] Running in HTTP mode (insecure)")
176
+ console.print(" For HTTPS, generate certificates with mkcert:")
177
+ console.print(f" [dim]mkdir -p {DEFAULT_CERT_DIR}[/dim]")
178
+ console.print(f" [dim]mkcert -cert-file {DEFAULT_CERT_FILE} -key-file {DEFAULT_KEY_FILE} localhost 127.0.0.1 ::1[/dim]")
179
+
180
+ # Build command with SSL parameters
181
+ ssl_args = ""
182
+ if use_https and cert_path and key_path:
183
+ ssl_args = f", ssl_certfile='{cert_path}', ssl_keyfile='{key_path}'"
184
+
109
185
  cmd = [
110
186
  sys.executable,
111
187
  "-c",
112
- f"from zebra_day.web.app import run_server; run_server(host='{host}', port={port}, reload={reload}, auth='{auth}')",
188
+ f"from zebra_day.web.app import run_server; run_server(host='{host}', port={port}, reload={reload}, auth='{auth}'{ssl_args})",
113
189
  ]
114
190
 
115
191
  # Set up environment
116
192
  env = os.environ.copy()
117
193
  env["PYTHONUNBUFFERED"] = "1"
118
194
  env["ZEBRA_DAY_AUTH_MODE"] = auth
195
+ if cert_path:
196
+ env["SSL_CERT_PATH"] = cert_path
197
+ if key_path:
198
+ env["SSL_KEY_PATH"] = key_path
119
199
 
120
200
  if reload:
121
201
  background = False
@@ -149,10 +229,10 @@ def start(
149
229
 
150
230
  PID_FILE.write_text(str(proc.pid))
151
231
  console.print(f"[green]✓[/green] Server started (PID {proc.pid})")
152
- console.print(f" URL: [cyan]http://{host}:{port}[/cyan]")
232
+ console.print(f" URL: [cyan]{protocol}://{host}:{port}[/cyan]")
153
233
  console.print(f" Logs: [dim]{log_file}[/dim]")
154
234
  else:
155
- console.print(f"[green]✓[/green] Starting server on [cyan]http://{host}:{port}[/cyan]")
235
+ console.print(f"[green]✓[/green] Starting server on [cyan]{protocol}://{host}:{port}[/cyan]")
156
236
  console.print(" Press Ctrl+C to stop\n")
157
237
  try:
158
238
  result = subprocess.run(cmd, cwd=Path.cwd(), env=env)
@@ -197,8 +277,11 @@ def status():
197
277
  pid = _get_pid()
198
278
  if pid:
199
279
  log_file = _get_latest_log()
280
+ # Check if HTTPS is likely enabled based on cert availability
281
+ _, _, use_https = _resolve_ssl_paths(None, None)
282
+ protocol = "https" if use_https else "http"
200
283
  console.print(f"[green]●[/green] Server is [green]running[/green] (PID {pid})")
201
- console.print(f" URL: [cyan]http://0.0.0.0:8118[/cyan]")
284
+ console.print(f" URL: [cyan]{protocol}://0.0.0.0:8118[/cyan]")
202
285
  if log_file:
203
286
  console.print(f" Logs: [dim]{log_file}[/dim]")
204
287
  else:
@@ -1,16 +1,4 @@
1
1
  {
2
- "labs": {
3
- "scan-results": {
4
- "Download-Label-png": {
5
- "ip_address": "dl_png",
6
- "label_zpl_styles": [
7
- "tube_2inX1in"
8
- ],
9
- "print_method": "generate png",
10
- "model": "na",
11
- "serial": "na",
12
- "arp_data": "na"
13
- }
14
- }
15
- }
2
+ "schema_version": "2.0.0",
3
+ "labs": {}
16
4
  }
@@ -1,15 +1,23 @@
1
1
  {
2
+ "schema_version": "2.0.0",
2
3
  "labs": {
3
4
  "scan-results": {
4
- "Download-Label-png": {
5
- "ip_address": "dl_png",
6
- "label_zpl_styles": [
7
- "tube_2inX1in"
8
- ],
9
- "print_method": "generate png",
10
- "model": "na",
11
- "serial": "na",
12
- "arp_data": "na"
5
+ "lab_name": "Scan Results",
6
+ "available_locations": [],
7
+ "printers": {
8
+ "Download-Label-png": {
9
+ "ip_address": "dl_png",
10
+ "printer_name": "Download Label as PNG",
11
+ "lab_location": null,
12
+ "manufacturer": "virtual",
13
+ "model": "na",
14
+ "serial": "na",
15
+ "label_zpl_styles": ["tube_2inX1in"],
16
+ "default_label_style": "tube_2inX1in",
17
+ "print_method": "generate png",
18
+ "arp_data": "na",
19
+ "notes": ""
20
+ }
13
21
  }
14
22
  }
15
23
  }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schema_version": "2.0.0",
3
+ "labs": {
4
+ "test": {
5
+ "lab_name": "Test Lab",
6
+ "available_locations": [],
7
+ "printers": {}
8
+ }
9
+ }
10
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file