smartlab-studio-ctrl 0.2.9__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.
@@ -0,0 +1,59 @@
1
+ """Snipping Toolの確認済みUIA構造と撮影待機設定。"""
2
+
3
+ from dataclasses import dataclass, field
4
+ from math import isfinite
5
+ from pathlib import Path
6
+ from typing import Optional
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class SnippingConfig:
11
+ """Snipping Toolで確認したUIA構造と撮影時の設定を保持する。
12
+
13
+ SmartLabConfigと同じく、UIAインターフェースや実行時の要素参照は
14
+ 制御クラスが保持する。固定階層はSnipping Tool 11.2608.41.0の
15
+ RawViewで確認した。各段は0始まりの子位置、照合する属性、その値を持つ。
16
+
17
+ Args:
18
+ auto_save_directory: Snipping Toolの自動保存先。省略時はWindowsの
19
+ 「スクリーンショット」フォルダを使う。
20
+ timeout_sec: ウィンドウの起動、PNGの保存、ウィンドウの終了を
21
+ それぞれ待つ最大秒数。
22
+ poll_interval_sec: 待機中にファイルまたはウィンドウを再確認する間隔。
23
+ """
24
+
25
+ auto_save_directory: Optional[Path] = None
26
+ timeout_sec: float = 15.0
27
+ poll_interval_sec: float = 0.05
28
+ window_title: str = field(init=False, default="Snipping Tool")
29
+ window_class: str = field(init=False, default="XamlWindow")
30
+ launch_target: str = field(
31
+ init=False, default=r"shell:AppsFolder\Microsoft.ScreenSketch_8wekyb3d8bbwe!App",
32
+ )
33
+ # デスクトップ直下の対象ウィンドウから、ボタンとコンボボックスの共通親まで。
34
+ toolbar_path: tuple[tuple[int, str, str], ...] = field(
35
+ init=False,
36
+ default=(
37
+ (0, "ClassName", "Windows.UI.Composition.DesktopWindowContentBridge"),
38
+ (0, "ClassName", "Windows.UI.Input.InputSite.WindowClass"),
39
+ ),
40
+ )
41
+ mode_control: tuple[int, str, str] = field(
42
+ init=False, default=(2, "AutomationId", "SnippingModeComboBox"),
43
+ )
44
+ capture_control: tuple[int, str, str] = field(
45
+ init=False, default=(0, "AutomationId", "NewCaptureButton"),
46
+ )
47
+ # モード一覧の項目はAutomationIdが空なので、子位置と表示名を組み合わせる。
48
+ mode_names: tuple[str, ...] = field(
49
+ init=False, default=("四角形", "ウィンドウ", "全画面表示", "フリーフォーム"),
50
+ )
51
+ full_screen_name: str = field(init=False, default="全画面表示")
52
+ # 終了直後の画面再生成を見逃さないよう、ウィンドウがない状態を短時間確認する。
53
+ close_stable_sec: float = field(init=False, default=0.25)
54
+
55
+ def __post_init__(self) -> None:
56
+ """待機時間の設定を生成時に検証する。"""
57
+ for seconds in (self.timeout_sec, self.poll_interval_sec):
58
+ if not isfinite(seconds) or seconds <= 0:
59
+ raise ValueError("撮影待機時間と確認間隔には有限の正の秒数を指定してください")
@@ -0,0 +1,325 @@
1
+ """Windows Snipping Toolを固定UIAパスで操作し、保存されたPNGを取得する。"""
2
+
3
+ import logging
4
+ from pathlib import Path
5
+ from tempfile import TemporaryDirectory
6
+ from threading import Lock
7
+ import time
8
+ from typing import Any, Optional, Union
9
+
10
+ from pywinauto.uia_defines import IUIA
11
+ from comtypes import COMError
12
+ from comtypes.gen.UIAutomationClient import (
13
+ IUIAutomationExpandCollapsePattern,
14
+ IUIAutomationInvokePattern,
15
+ IUIAutomationSelectionItemPattern,
16
+ IUIAutomationSelectionPattern,
17
+ IUIAutomationWindowPattern,
18
+ )
19
+
20
+ from smartlab_studio_ctrl.snipping_config import SnippingConfig
21
+
22
+
23
+ class SnippingUIA:
24
+ """対話デスクトップのSnipping Toolを操作して全画面のPNGを取得する。
25
+
26
+ GUIの位置と識別子はSnippingConfigに置く。このクラスは、固定階層の
27
+ 照合、撮影モードの選択、撮影指示、保存完了の確認を担当する。
28
+ 取得した要素参照を同じ撮影の間で再利用し、操作後はウィンドウを閉じる。
29
+ 指定先への保存を含め、処理が終わるまで撮影を占有し、PNGを返す。
30
+
31
+ Notes:
32
+ Windowsの対話デスクトップとSnipping ToolのPNG自動保存を使用する。
33
+ 同じウィンドウで別の撮影が同時に行われた場合は結果を特定できない。
34
+ """
35
+
36
+ # 同じプロセス内の全インスタンスで、Snipping Toolの操作と保存を直列化する。
37
+ _capture_lock = Lock()
38
+
39
+ def __init__(
40
+ self,
41
+ config: Optional[SnippingConfig] = None,
42
+ logger: Optional[Any] = None,
43
+ log_level: Optional[str] = None,
44
+ ) -> None:
45
+ """設定とロガーを保持し、初回の撮影時にUIAへ接続する。
46
+
47
+ Args:
48
+ config: 構造と保存先の設定。省略時はSnippingConfigの既定値。
49
+ logger: 既存のロガー。省略時は標準loggingを使用する。
50
+ log_level: 標準ロガーを使う場合のログレベル。
51
+ """
52
+ if config is None:
53
+ config = SnippingConfig()
54
+ if logger is None:
55
+ logging.basicConfig(level=(log_level or "INFO").upper())
56
+ logger = logging.getLogger(__name__)
57
+ self._config = config
58
+ self._logger = logger
59
+ self._uia = None
60
+ self._window = None
61
+ self._mode = None
62
+ self._capture_button = None
63
+ self._phase = None
64
+
65
+ def get_state(self) -> str:
66
+ """現在の撮影段階またはSnipping Toolの開閉状態を返す。
67
+
68
+ Returns:
69
+ 起動準備中はSTARTING、自動保存を待つ間はCAPTURING、終了待ちは
70
+ CLOSING、指定先への書き込み中はSAVING。待機中はウィンドウの
71
+ 開閉に応じてREADYまたはCLOSEDを返す。
72
+ """
73
+ phase = self._phase
74
+ if phase is not None:
75
+ return phase
76
+ if self._window_handle():
77
+ return "READY"
78
+ return "CLOSED"
79
+
80
+ def capture_screenshot(
81
+ self,
82
+ output_directory: Optional[Union[str, Path]] = None,
83
+ ) -> bytes:
84
+ """全画面を撮影し、ウィンドウの終了と指定先への保存を待つ。
85
+
86
+ Args:
87
+ output_directory: PNGを保存する既存フォルダ。指定時は
88
+ screenshot_local.png を書き、同名ファイルを置き換える。
89
+
90
+ Returns:
91
+ PNG画像のバイト列。
92
+
93
+ Raises:
94
+ FileNotFoundError: 保存先または指定した自動保存フォルダがない場合。
95
+ TimeoutError: ウィンドウの起動、PNGの自動保存、またはウィンドウの
96
+ 終了が時間内に完了しない場合。
97
+ RuntimeError: 撮影・保存が進行中、固定UIAパスが一致しない、
98
+ または撮影結果が一意でない場合。
99
+ """
100
+ if not self._capture_lock.acquire(blocking=False):
101
+ raise RuntimeError("スクリーンショットの撮影または保存が進行中です")
102
+ try:
103
+ self._phase = "STARTING"
104
+ directory = None
105
+ if output_directory is not None:
106
+ directory = Path(output_directory).expanduser().resolve()
107
+ if not directory.is_dir():
108
+ raise FileNotFoundError(
109
+ f"スクリーンショットの保存先がありません: {directory}"
110
+ )
111
+
112
+ data = self._capture_screenshot_run()
113
+ if directory is not None:
114
+ self._phase = "SAVING"
115
+ target = directory / "screenshot_local.png"
116
+ # 完成したPNGだけを公開し、書き込み失敗時は既存ファイルを残す。
117
+ with TemporaryDirectory(dir=directory) as temporary:
118
+ pending = Path(temporary) / target.name
119
+ pending.write_bytes(data)
120
+ pending.replace(target)
121
+ self._logger.info(f"Screenshot saved: {target}")
122
+ return data
123
+ except Exception as exc:
124
+ self._logger.error(f"Snipping Tool capture failed: {exc}")
125
+ raise
126
+ finally:
127
+ self._phase = None
128
+ self._capture_lock.release()
129
+
130
+ def _capture_screenshot_run(self) -> bytes:
131
+ """撮影の開始から終了確認まで、一回分の状態遷移を管理する。"""
132
+ directory = self._capture_screenshot_directory()
133
+ self._logger.info(f"Capturing full screen with Snipping Tool: {directory}")
134
+ try:
135
+ self._bind_controls()
136
+ self._phase = "CAPTURING"
137
+ selection = self._pattern(
138
+ self._mode, "Selection", IUIAutomationSelectionPattern,
139
+ )
140
+ selected = selection.GetCurrentSelection().GetElement(0).CurrentName
141
+ full_screen = self._config.full_screen_name
142
+ if selected != full_screen:
143
+ self._select_mode(full_screen)
144
+ try:
145
+ # Invoke前の状態を保存し、前回までのPNGと今回の画像を区別する。
146
+ before = self._capture_screenshot_png_files(directory)
147
+ self._pattern(
148
+ self._capture_button, "Invoke", IUIAutomationInvokePattern,
149
+ ).Invoke()
150
+ data = self._capture_screenshot_wait(directory, before)
151
+ finally:
152
+ if selected != full_screen:
153
+ # 撮影後にXAMLの子要素が作り直されるため、同じ親子パスから取得し直す。
154
+ handle = self._window_handle()
155
+ if handle:
156
+ self._window = self._uia.iuia.ElementFromHandle(handle)
157
+ self._bind_toolbar()
158
+ self._select_mode(selected)
159
+ finally:
160
+ self._phase = "CLOSING"
161
+ self._close_window()
162
+ self._logger.info(f"Snipping Tool capture completed ({len(data)} bytes)")
163
+ return data
164
+
165
+ def _bind_controls(self) -> None:
166
+ """対象ウィンドウに接続し、記録済みの階層から操作要素を取得する。"""
167
+ import win32api
168
+ import win32con
169
+
170
+ self._uia = IUIA()
171
+ config = self._config
172
+ handle = self._window_handle()
173
+ if not handle:
174
+ win32api.ShellExecute(
175
+ 0, "open", "explorer.exe", config.launch_target,
176
+ None, win32con.SW_SHOWNORMAL,
177
+ )
178
+ deadline = time.monotonic() + config.timeout_sec
179
+ while not handle and time.monotonic() < deadline:
180
+ time.sleep(config.poll_interval_sec)
181
+ handle = self._window_handle()
182
+ if not handle:
183
+ raise TimeoutError("Snipping Toolのウィンドウが起動しませんでした")
184
+ self._window = self._uia.iuia.ElementFromHandle(handle)
185
+ self._bind_toolbar()
186
+
187
+ def _bind_toolbar(self) -> None:
188
+ """取得済みのウィンドウから固定位置の操作要素を取得する。"""
189
+ config = self._config
190
+ toolbar = self._window
191
+ for step in config.toolbar_path:
192
+ toolbar = self._child_at(toolbar, *step)
193
+ self._mode = self._child_at(toolbar, *config.mode_control)
194
+ self._capture_button = self._child_at(toolbar, *config.capture_control)
195
+
196
+ def _close_window(self) -> None:
197
+ """撮影前後で作り直されたウィンドウも含め、終了を確認する。"""
198
+ self._window = None
199
+ self._capture_button = None
200
+ self._mode = None
201
+ if self._uia is None:
202
+ return
203
+
204
+ deadline = time.monotonic() + self._config.timeout_sec
205
+ last_handle = 0
206
+ retry_at = 0.0
207
+ absent_since = None
208
+ while time.monotonic() < deadline:
209
+ now = time.monotonic()
210
+ handle = self._window_handle()
211
+ if handle:
212
+ absent_since = None
213
+ if handle != last_handle or now >= retry_at:
214
+ window = self._uia.iuia.ElementFromHandle(handle)
215
+ self._pattern(window, "Window", IUIAutomationWindowPattern).Close()
216
+ # PNGが保存済みでも、結果画面の更新中はCloseが受理されないことがある。
217
+ last_handle = handle
218
+ retry_at = now + self._config.close_stable_sec
219
+ elif absent_since is None:
220
+ # 古いハンドルの消滅直後に結果画面が作られる場合がある。
221
+ absent_since = now
222
+ elif now - absent_since >= self._config.close_stable_sec:
223
+ self._logger.debug("Snipping Tool window closed")
224
+ return
225
+ time.sleep(self._config.poll_interval_sec)
226
+ raise TimeoutError("Snipping Toolのウィンドウが閉じませんでした")
227
+
228
+ def _window_handle(self) -> int:
229
+ """クラス名とタイトルを完全一致させて既知のウィンドウを確認する。"""
230
+ from win32gui import FindWindow
231
+
232
+ return FindWindow(self._config.window_class, self._config.window_title)
233
+
234
+ def _child_at(self, parent, index: int, prop: str, value: str):
235
+ """設定したRawViewの子位置を辿り、その位置の要素を照合する。"""
236
+ walker = self._uia.iuia.RawViewWalker
237
+ child = walker.GetFirstChildElement(parent)
238
+ for _ in range(index):
239
+ if not child:
240
+ break
241
+ child = walker.GetNextSiblingElement(child)
242
+ if not child or getattr(child, f"Current{prop}") != value:
243
+ raise RuntimeError(
244
+ f"Snipping Toolの固定UIAパスが一致しません: child[{index}] {prop}={value}"
245
+ )
246
+ return child
247
+
248
+ def _pattern(self, element, name: str, interface):
249
+ pattern_id = getattr(self._uia.UIA_dll, f"UIA_{name}PatternId")
250
+ pattern = element.GetCurrentPattern(pattern_id)
251
+ if not pattern:
252
+ raise RuntimeError(f"Snipping Toolの{name}Patternを取得できません")
253
+ return pattern.QueryInterface(interface)
254
+
255
+ def _select_mode(self, name: str) -> None:
256
+ """コンボボックスを展開し、確認済みの位置のモードを選ぶ。"""
257
+ dropdown = self._pattern(
258
+ self._mode, "ExpandCollapse", IUIAutomationExpandCollapsePattern,
259
+ )
260
+ dropdown.Expand()
261
+ try:
262
+ index = self._config.mode_names.index(name)
263
+ item = self._child_at(self._mode, index, "Name", name)
264
+ self._pattern(item, "SelectionItem", IUIAutomationSelectionItemPattern).Select()
265
+ finally:
266
+ try:
267
+ dropdown.Collapse()
268
+ except COMError:
269
+ # 選択時にポップアップが閉じた場合、Collapseが失敗することがある。
270
+ self._logger.debug("Snipping Tool mode list is already closed")
271
+
272
+ def _capture_screenshot_directory(self) -> Path:
273
+ """明示設定またはWindowsの既知フォルダから自動保存先を決める。"""
274
+ directory = self._config.auto_save_directory
275
+ if directory is not None:
276
+ directory = Path(directory).expanduser().resolve()
277
+ if not directory.is_dir():
278
+ raise FileNotFoundError(f"Snipping Toolの自動保存フォルダがありません: {directory}")
279
+ return directory
280
+
281
+ from pywintypes import IID, com_error
282
+ from win32com.shell import shell, shellcon
283
+
284
+ try:
285
+ return Path(shell.SHGetKnownFolderPath(IID("{b7bede81-df94-4682-a7d8-57a52620b86f}")))
286
+ except com_error:
287
+ return Path(shell.SHGetFolderPath(0, shellcon.CSIDL_MYPICTURES, None, 0)) / "Screenshots"
288
+
289
+ @staticmethod
290
+ def _capture_screenshot_png_files(directory: Path) -> dict:
291
+ files = {}
292
+ for path in directory.glob("*.png"):
293
+ try:
294
+ stat = path.stat()
295
+ except FileNotFoundError:
296
+ continue
297
+ files[path] = (stat.st_mtime_ns, stat.st_size)
298
+ return files
299
+
300
+ def _capture_screenshot_wait(self, directory: Path, before: dict) -> bytes:
301
+ """今回の画像を一意に絞り、PNGが最後まで書き込まれるのを待つ。"""
302
+ deadline = time.monotonic() + self._config.timeout_sec
303
+ while time.monotonic() < deadline:
304
+ files = self._capture_screenshot_png_files(directory)
305
+ created = [path for path, stat in files.items() if before.get(path) != stat]
306
+ if len(created) > 1:
307
+ raise RuntimeError("同時に複数のPNGが作成され、撮影結果を特定できません")
308
+ if created:
309
+ path = created[0]
310
+ try:
311
+ data = path.read_bytes()
312
+ stat = path.stat()
313
+ except (FileNotFoundError, PermissionError):
314
+ time.sleep(self._config.poll_interval_sec)
315
+ continue
316
+ # 読み込み中に更新されず、PNGの終端チャンクまで書かれたことを確認する。
317
+ if (
318
+ (stat.st_mtime_ns, stat.st_size) == files[path]
319
+ and len(data) == stat.st_size
320
+ and data.startswith(b"\x89PNG\r\n\x1a\n")
321
+ and data.endswith(b"\x00\x00\x00\x00IEND\xaeB\x60\x82")
322
+ ):
323
+ return data
324
+ time.sleep(self._config.poll_interval_sec)
325
+ raise TimeoutError(f"Snipping ToolのPNG自動保存を確認できませんでした: {directory}")
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: smartlab-studio-ctrl
3
+ Version: 0.2.9
4
+ Summary: SmartLab Studio II device control using Windows UI Automation
5
+ Requires-Python: >=3.9
6
+ License-File: LICENSE
7
+ Requires-Dist: pywinauto
8
+ Requires-Dist: comtypes
9
+ Requires-Dist: grpc-frame>=0.5.20
10
+ Requires-Dist: Pillow>=6.2
11
+ Requires-Dist: windows-capture<3,>=2.0.1; sys_platform == "win32" and platform_machine == "AMD64"
12
+ Dynamic: license-file
@@ -0,0 +1,16 @@
1
+ smartlab_studio_ctrl/__init__.py,sha256=yc3YqMrjSSESsUe0c26rsBCtsTQ4e7NuFPLf9akmQw0,347
2
+ smartlab_studio_ctrl/config.py,sha256=4-EKtz1Em0nQiJX-gd5KJcd1Q3E3Ap16g-q9EXtixLc,1235
3
+ smartlab_studio_ctrl/desktop_capture.py,sha256=WremRufolxFEPusibDaiSZyo03nFJnF8_7bBwvn2ido,8666
4
+ smartlab_studio_ctrl/smartlab_config.py,sha256=yLGgJsxyhxDwSDYQpIC2h2DD8xbNs7JYlznv4lkpY-E,11103
5
+ smartlab_studio_ctrl/smartlab_ctrl.py,sha256=DEqcrk1_RgdgxreA8_zYntL6rrAFgKzXCFUGTOTbrH4,10619
6
+ smartlab_studio_ctrl/smartlab_uia.py,sha256=5viTJfduxCf9JkK55ADka7bDksr5-9DZC1W-ePZgcB8,56431
7
+ smartlab_studio_ctrl/snipping_config.py,sha256=uPYgURv5gKSrLiCG_yKnZYq7zokml-A0vjjMTdYheiw,2897
8
+ smartlab_studio_ctrl/snipping_uia.py,sha256=Vln7bT_smRzaPrV6IqVrxbtCf-Cx9qO1DfFTPVaGpdg,14692
9
+ smartlab_studio_ctrl/server_grpc/__init__.py,sha256=5q-0Oxxx7lCdhMY44c4vA9X8TRIrysic0K2z08VrDXI,64
10
+ smartlab_studio_ctrl/server_grpc/client.py,sha256=RFYaUxJCkjuXpJ0utWVKrEA3V3Sy5zpR7NrU7S8J0AA,10610
11
+ smartlab_studio_ctrl/server_grpc/server.py,sha256=IimtIVoR91v4JKRga3Y4NioIujbXA0poO_Vy9M-TaVc,10774
12
+ smartlab_studio_ctrl-0.2.9.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
13
+ smartlab_studio_ctrl-0.2.9.dist-info/METADATA,sha256=gVS36ebKM9T4Pm59zZiD7gAKyqFpjOk94TagZIew6O8,410
14
+ smartlab_studio_ctrl-0.2.9.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
15
+ smartlab_studio_ctrl-0.2.9.dist-info/top_level.txt,sha256=EwFFVjvN6JgeLwrXDglTDyyk6cvWYy8YD6EN_voig0w,21
16
+ smartlab_studio_ctrl-0.2.9.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ smartlab_studio_ctrl