zebra-day 1.0.2__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.
Files changed (174) hide show
  1. zebra_day/__init__.py +7 -2
  2. zebra_day/_version.py +1 -0
  3. zebra_day/cli/__init__.py +80 -30
  4. zebra_day/cli/cognito.py +15 -9
  5. zebra_day/cli/gui.py +101 -13
  6. zebra_day/cli/printer.py +34 -27
  7. zebra_day/cli/template.py +19 -15
  8. zebra_day/cmd_mgr.py +3 -6
  9. zebra_day/docs/gx420d-gx430d-ug-en.pdf +0 -0
  10. zebra_day/docs/hardware_config_guide.md +149 -0
  11. zebra_day/docs/programatic_guide.md +181 -0
  12. zebra_day/docs/qln420_zebra_manual.pdf +0 -0
  13. zebra_day/docs/uid_screed_light.md +38 -0
  14. zebra_day/docs/zd620-zd420-ug-en.pdf +0 -0
  15. zebra_day/docs/zebra_day_ui_guide.md +194 -0
  16. zebra_day/etc/printer_config.json +5 -11
  17. zebra_day/etc/printer_config.template.json +5 -11
  18. zebra_day/etc/tmp_printers120.json +10 -0
  19. zebra_day/etc/tmp_printers139.json +10 -0
  20. zebra_day/etc/tmp_printers145.json +10 -0
  21. zebra_day/etc/tmp_printers147.json +10 -0
  22. zebra_day/etc/tmp_printers207.json +10 -0
  23. zebra_day/etc/tmp_printers34.json +10 -0
  24. zebra_day/etc/tmp_printers389.json +10 -0
  25. zebra_day/etc/tmp_printers398.json +10 -0
  26. zebra_day/etc/tmp_printers437.json +10 -0
  27. zebra_day/etc/tmp_printers439.json +10 -0
  28. zebra_day/etc/tmp_printers440.json +10 -0
  29. zebra_day/etc/tmp_printers469.json +10 -0
  30. zebra_day/etc/tmp_printers485.json +10 -0
  31. zebra_day/etc/tmp_printers508.json +10 -0
  32. zebra_day/etc/tmp_printers531.json +10 -0
  33. zebra_day/etc/tmp_printers540.json +10 -0
  34. zebra_day/etc/tmp_printers542.json +10 -0
  35. zebra_day/etc/tmp_printers543.json +10 -0
  36. zebra_day/etc/tmp_printers552.json +10 -0
  37. zebra_day/etc/tmp_printers715.json +10 -0
  38. zebra_day/etc/tmp_printers835.json +10 -0
  39. zebra_day/etc/tmp_printers842.json +10 -0
  40. zebra_day/etc/tmp_printers931.json +10 -0
  41. zebra_day/etc/tmp_printers969.json +10 -0
  42. zebra_day/etc/tmp_printers972.json +10 -0
  43. zebra_day/exceptions.py +1 -1
  44. zebra_day/files/blank_preview.png +0 -0
  45. zebra_day/files/corners_20cmX30cm_preview.png +0 -0
  46. zebra_day/files/corners_smallTube_preview.png +0 -0
  47. zebra_day/files/generic_2inX1in_preview.png +0 -0
  48. zebra_day/files/test_png_12020.png +0 -0
  49. zebra_day/files/test_png_12352.png +0 -0
  50. zebra_day/files/test_png_15472.png +0 -0
  51. zebra_day/files/test_png_24493.png +0 -0
  52. zebra_day/files/test_png_2897.png +0 -0
  53. zebra_day/files/test_png_30069.png +0 -0
  54. zebra_day/files/test_png_31690.png +0 -0
  55. zebra_day/files/test_png_33804.png +0 -0
  56. zebra_day/files/test_png_34737.png +0 -0
  57. zebra_day/files/test_png_4161.png +0 -0
  58. zebra_day/files/test_png_44748.png +0 -0
  59. zebra_day/files/test_png_4635.png +0 -0
  60. zebra_day/files/test_png_47791.png +0 -0
  61. zebra_day/files/test_png_47799.png +0 -0
  62. zebra_day/files/test_png_55588.png +0 -0
  63. zebra_day/files/test_png_56349.png +0 -0
  64. zebra_day/files/test_png_58809.png +0 -0
  65. zebra_day/files/test_png_5936.png +0 -0
  66. zebra_day/files/test_png_64110.png +0 -0
  67. zebra_day/files/test_png_64891.png +0 -0
  68. zebra_day/files/test_png_67242.png +0 -0
  69. zebra_day/files/test_png_69002.png +0 -0
  70. zebra_day/files/test_png_70065.png +0 -0
  71. zebra_day/files/test_png_72366.png +0 -0
  72. zebra_day/files/test_png_77793.png +0 -0
  73. zebra_day/files/test_png_89893.png +0 -0
  74. zebra_day/files/test_png_9572.png +0 -0
  75. zebra_day/files/tube_20mmX30mmA_preview.png +0 -0
  76. zebra_day/imgs/.hold +0 -0
  77. zebra_day/imgs/bar_ltpurp.png +0 -0
  78. zebra_day/imgs/bar_purp.png +0 -0
  79. zebra_day/imgs/bar_purp3.png +0 -0
  80. zebra_day/imgs/bar_red.png +0 -0
  81. zebra_day/imgs/legacy/UBC_gantt_chart.png +0 -0
  82. zebra_day/imgs/legacy/gx420d_network_config.png +0 -0
  83. zebra_day/imgs/legacy/gx420d_printer_config.png +0 -0
  84. zebra_day/imgs/legacy/ngrok.png +0 -0
  85. zebra_day/imgs/legacy/printer_details.png +0 -0
  86. zebra_day/imgs/legacy/quick_start_test_label.png +0 -0
  87. zebra_day/imgs/legacy/quick_start_test_label2.png +0 -0
  88. zebra_day/imgs/legacy/zd620_network_config.png +0 -0
  89. zebra_day/imgs/legacy/zd620_printer_config.png +0 -0
  90. zebra_day/imgs/legacy/zday_quick_gui.png +0 -0
  91. zebra_day/imgs/legacy/zebra_day_alt_css_dog.png +0 -0
  92. zebra_day/imgs/legacy/zebra_day_alt_css_flower.png +0 -0
  93. zebra_day/imgs/legacy/zebra_day_alt_css_main.png +0 -0
  94. zebra_day/imgs/legacy/zebra_day_available_zpl_templates.png +0 -0
  95. zebra_day/imgs/legacy/zebra_day_bkup_pconfig.png +0 -0
  96. zebra_day/imgs/legacy/zebra_day_home.png +0 -0
  97. zebra_day/imgs/legacy/zebra_day_manual_print.png +0 -0
  98. zebra_day/imgs/legacy/zebra_day_printer_fleet_json.png +0 -0
  99. zebra_day/imgs/legacy/zebra_day_quick_ex.png +0 -0
  100. zebra_day/imgs/legacy/zebra_day_zpl_template_IRLa.png +0 -0
  101. zebra_day/imgs/legacy/zebra_day_zpl_template_IRLb.png +0 -0
  102. zebra_day/imgs/ui_api_docs.png +0 -0
  103. zebra_day/imgs/ui_config.png +0 -0
  104. zebra_day/imgs/ui_dashboard.png +0 -0
  105. zebra_day/imgs/ui_print_request.png +0 -0
  106. zebra_day/imgs/ui_printers.png +0 -0
  107. zebra_day/imgs/ui_templates.png +0 -0
  108. zebra_day/logging_config.py +4 -9
  109. zebra_day/mkcert.py +157 -0
  110. zebra_day/paths.py +1 -2
  111. zebra_day/print_mgr.py +261 -185
  112. zebra_day/templates/modern/config.html +7 -0
  113. zebra_day/templates/modern/config_backups.html +59 -0
  114. zebra_day/templates/modern/config_editor.html +95 -0
  115. zebra_day/templates/modern/config_new.html +93 -0
  116. zebra_day/templates/modern/print_request.html +70 -8
  117. zebra_day/templates/modern/printer_detail.html +161 -34
  118. zebra_day/templates/modern/printers.html +17 -6
  119. zebra_day/templates/modern/template_editor.html +7 -4
  120. zebra_day/web/__init__.py +1 -1
  121. zebra_day/web/app.py +99 -17
  122. zebra_day/web/auth.py +17 -15
  123. zebra_day/web/middleware.py +8 -5
  124. zebra_day/web/routers/__init__.py +0 -1
  125. zebra_day/web/routers/api.py +330 -31
  126. zebra_day/web/routers/ui.py +174 -591
  127. zebra_day/zpl_renderer.py +45 -34
  128. {zebra_day-1.0.2.dist-info → zebra_day-2.1.4.dist-info}/METADATA +144 -74
  129. zebra_day-2.1.4.dist-info/RECORD +240 -0
  130. zebra_day/bin/fetch_zebra_config.py +0 -15
  131. zebra_day/bin/generate_coord_grid_zpl.py +0 -50
  132. zebra_day/bin/print_zpl_from_file.py +0 -21
  133. zebra_day/bin/probe_new_label_dimensions.py +0 -75
  134. zebra_day/bin/scan_for_networed_zebra_printers.py +0 -23
  135. zebra_day/bin/scan_for_networed_zebra_printers_arp_scan.sh +0 -1
  136. zebra_day/bin/scan_for_networed_zebra_printers_curl.sh +0 -30
  137. zebra_day/bin/zserve.py +0 -1062
  138. zebra_day/templates/base.html +0 -36
  139. zebra_day/templates/bpr.html +0 -72
  140. zebra_day/templates/build_new_config.html +0 -36
  141. zebra_day/templates/build_print_request.html +0 -32
  142. zebra_day/templates/chg_ui_style.html +0 -19
  143. zebra_day/templates/edit_template.html +0 -128
  144. zebra_day/templates/edit_zpl.html +0 -37
  145. zebra_day/templates/index.html +0 -82
  146. zebra_day/templates/legacy/base.html +0 -37
  147. zebra_day/templates/legacy/bpr.html +0 -72
  148. zebra_day/templates/legacy/build_new_config.html +0 -36
  149. zebra_day/templates/legacy/build_print_request.html +0 -32
  150. zebra_day/templates/legacy/chg_ui_style.html +0 -19
  151. zebra_day/templates/legacy/edit_template.html +0 -128
  152. zebra_day/templates/legacy/edit_zpl.html +0 -37
  153. zebra_day/templates/legacy/index.html +0 -82
  154. zebra_day/templates/legacy/list_prior_configs.html +0 -24
  155. zebra_day/templates/legacy/print_result.html +0 -30
  156. zebra_day/templates/legacy/printer_details.html +0 -25
  157. zebra_day/templates/legacy/printer_status.html +0 -70
  158. zebra_day/templates/legacy/save_result.html +0 -17
  159. zebra_day/templates/legacy/send_print_request.html +0 -34
  160. zebra_day/templates/legacy/simple_print.html +0 -94
  161. zebra_day/templates/legacy/view_pstation_json.html +0 -29
  162. zebra_day/templates/list_prior_configs.html +0 -24
  163. zebra_day/templates/print_result.html +0 -30
  164. zebra_day/templates/printer_details.html +0 -25
  165. zebra_day/templates/printer_status.html +0 -70
  166. zebra_day/templates/save_result.html +0 -17
  167. zebra_day/templates/send_print_request.html +0 -34
  168. zebra_day/templates/simple_print.html +0 -94
  169. zebra_day/templates/view_pstation_json.html +0 -29
  170. zebra_day-1.0.2.dist-info/RECORD +0 -179
  171. {zebra_day-1.0.2.dist-info → zebra_day-2.1.4.dist-info}/WHEEL +0 -0
  172. {zebra_day-1.0.2.dist-info → zebra_day-2.1.4.dist-info}/entry_points.txt +0 -0
  173. {zebra_day-1.0.2.dist-info → zebra_day-2.1.4.dist-info}/licenses/LICENSE +0 -0
  174. {zebra_day-1.0.2.dist-info → zebra_day-2.1.4.dist-info}/top_level.txt +0 -0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -3,12 +3,12 @@ Logging configuration for zebra_day.
3
3
 
4
4
  Provides structured logging with configurable levels and formats.
5
5
  """
6
+
6
7
  from __future__ import annotations
7
8
 
8
9
  import logging
9
10
  import sys
10
11
  from pathlib import Path
11
- from typing import Optional
12
12
 
13
13
 
14
14
  def get_logger(name: str) -> logging.Logger:
@@ -27,8 +27,8 @@ def get_logger(name: str) -> logging.Logger:
27
27
 
28
28
  def configure_logging(
29
29
  level: int = logging.INFO,
30
- log_file: Optional[Path] = None,
31
- format_string: Optional[str] = None,
30
+ log_file: Path | None = None,
31
+ format_string: str | None = None,
32
32
  ) -> None:
33
33
  """Configure zebra_day logging.
34
34
 
@@ -38,11 +38,7 @@ def configure_logging(
38
38
  format_string: Optional custom format string
39
39
  """
40
40
  if format_string is None:
41
- format_string = (
42
- "\033[1m%(asctime)s\033[0m "
43
- "[%(levelname)s] "
44
- "%(name)s: %(message)s"
45
- )
41
+ format_string = "\033[1m%(asctime)s\033[0m [%(levelname)s] %(name)s: %(message)s"
46
42
 
47
43
  formatter = logging.Formatter(format_string, datefmt="%Y-%m-%d %H:%M:%S")
48
44
 
@@ -71,4 +67,3 @@ def configure_logging(
71
67
  )
72
68
  )
73
69
  logger.addHandler(file_handler)
74
-
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
-