|
6 | 6 | import datetime |
7 | 7 | import os |
8 | 8 | import sys |
9 | | -import tempfile |
10 | 9 | import textwrap |
11 | 10 | from pathlib import Path |
12 | 11 | from typing import TYPE_CHECKING |
|
33 | 32 | reraise=True, |
34 | 33 | ) |
35 | 34 |
|
36 | | -VUMARK_TEMPLATE_SVG = textwrap.dedent( |
37 | | - text="""\ |
38 | | - <svg xmlns="http://www.w3.org/2000/svg" width="512" height="512"> |
39 | | - <rect x="0" y="0" width="512" height="512" fill="#ffffff" /> |
40 | | - <circle cx="256" cy="256" r="144" fill="#000000" /> |
41 | | - </svg> |
42 | | - """, |
43 | | -) |
| 35 | +VUMARK_TEMPLATE_SVG_FILE_PATH = Path(__file__).with_name("vumark_template.svg") |
44 | 36 |
|
45 | 37 |
|
46 | 38 | def _create_and_get_database_details( |
@@ -128,19 +120,13 @@ def _create_and_get_vumark_target_id( |
128 | 120 | vumark_template_name: str, |
129 | 121 | ) -> str: |
130 | 122 | """Upload a VuMark template and get its target ID.""" |
131 | | - with tempfile.TemporaryDirectory() as temporary_directory: |
132 | | - svg_file_path = Path(temporary_directory) / "template.svg" |
133 | | - svg_file_path.write_text( |
134 | | - data=VUMARK_TEMPLATE_SVG, |
135 | | - encoding="utf-8", |
136 | | - ) |
137 | | - upload_result = RETRY_ON_TIMEOUT(vws_web_tools.upload_vumark_template)( |
138 | | - driver=driver, |
139 | | - database_name=vumark_database_name, |
140 | | - svg_file_path=svg_file_path, |
141 | | - template_name=vumark_template_name, |
142 | | - width=100.0, |
143 | | - ) |
| 123 | + upload_result = RETRY_ON_TIMEOUT(vws_web_tools.upload_vumark_template)( |
| 124 | + driver=driver, |
| 125 | + database_name=vumark_database_name, |
| 126 | + svg_file_path=VUMARK_TEMPLATE_SVG_FILE_PATH, |
| 127 | + template_name=vumark_template_name, |
| 128 | + width=100.0, |
| 129 | + ) |
144 | 130 |
|
145 | 131 | if isinstance(upload_result, str): |
146 | 132 | return upload_result |
|
0 commit comments