@@ -77,13 +77,6 @@ def _first_true(iterable, default=None, pred=None):
77
77
return next (filter (pred , iterable ), default )
78
78
79
79
80
- def _hour_to_millisecond (hour : Optional [float ]) -> Optional [int ]:
81
- return int (hour * 3600_000 ) if hour is not None else None
82
-
83
-
84
- _ORGANIZATION_ID_FOR_AVAILABILITY = "___plannedWorktime___"
85
- """予定稼働時間用の組織ID"""
86
-
87
80
_JOB_CONCURRENCY_LIMIT = {
88
81
ProjectJobType .COPY_PROJECT : {
89
82
ProjectJobType .GEN_INPUTS ,
@@ -205,16 +198,49 @@ def _get_all_objects(func_get_list: Callable, limit: int, **kwargs_for_func_get_
205
198
206
199
return all_objects
207
200
208
- def _download (self , url : str , dest_path : Union [str , Path ]) -> requests .Response :
201
+ def execute_http_get (self , url : str ) -> requests .Response :
202
+ """
203
+ 指定したURLに対してHTTP GETを実行します。
204
+
205
+ 塗りつぶし画像など外部リソースのURLを指定することを想定しています。
206
+
207
+ Args:
208
+ url: HTTP GETでアクセスするURL
209
+
210
+ Returns:
211
+ URLにアクセスしたときの ``requests.Response`` 情報
212
+
213
+ Note:
214
+ ``requests.get`` でアクセスすることとの違いは以下の通りです。
215
+
216
+ * ``requests.Session`` 情報を使ってTCPコネクションを再利用しているため、``requests.get`` を使ってダウンロードするよりも、パフォーマンスが向上する可能性があります。
217
+ * 必要に応じてリトライします
218
+ * HTTPステータスコードが4XX,5XXならば、HTTPErrorがスローされます
219
+
220
+
221
+ """
222
+ return self .api ._execute_http_request (http_method = "get" , url = url )
223
+
224
+ def download (self , url : str , dest_path : Union [str , Path ]) -> requests .Response :
209
225
"""
210
226
指定したURLからファイルをダウンロードします。
211
227
228
+ ``getAnnotation`` などダウンロード用のURLを指定することを想定しています。
229
+
230
+
212
231
Args:
213
232
url: ダウンロード対象のURL
214
233
dest_path: 保存先ファイルのパス
215
234
216
235
Returns:
217
- URLにアクセスしたときのResponse情報
236
+ URLにアクセスしたときの ``requests.Response`` 情報
237
+
238
+ Note:
239
+ ``requests.get`` でアクセスすることとの違いは以下の通りです。
240
+
241
+ * ``requests.Session`` 情報を使ってTCPコネクションを再利用しているため、``requests.get`` を使ってダウンロードするよりも、パフォーマンスが向上する可能性があります。
242
+ * 必要に応じてリトライします
243
+ * HTTPステータスコードが4XX,5XXならば、HTTPErrorがスローされます
218
244
219
245
"""
220
246
response = self .api ._execute_http_request (http_method = "get" , url = url )
@@ -269,7 +295,7 @@ def download_annotation_archive(self, project_id: str, dest_path: Union[str, Pat
269
295
# 2022/01時点でレスポンスのcontent-typeが"text/plain"なので、contentの型がdictにならない。したがって、Locationヘッダを参照する。
270
296
_ , response = self .api .get_annotation_archive (project_id )
271
297
url = response .headers ["Location" ]
272
- response2 = self ._download (url , dest_path )
298
+ response2 = self .download (url , dest_path )
273
299
logger .info (
274
300
"SimpleアノテーションZIPファイルをダウンロードしました。 :: project_id='%s', Last-Modified='%s', file='%s'" ,
275
301
project_id ,
@@ -300,7 +326,7 @@ def download_full_annotation_archive(self, project_id: str, dest_path: Union[str
300
326
# 2022/01時点でレスポンスのcontent-typeが"text/plain"なので、contentの型がdictにならない。したがって、Locationヘッダを参照する。
301
327
_ , response = self .api .get_archive_full_with_pro_id (project_id )
302
328
url = response .headers ["Location" ]
303
- response2 = self ._download (url , dest_path )
329
+ response2 = self .download (url , dest_path )
304
330
logger .info (
305
331
"FullアノテーションZIPファイルをダウンロードしました。 :: project_id='%s', Last-Modified='%s', file='%s'" ,
306
332
project_id ,
@@ -1578,7 +1604,7 @@ def download_project_inputs_url(self, project_id: str, dest_path: Union[str, Pat
1578
1604
"""
1579
1605
content , _ = self .api .get_project_inputs_url (project_id )
1580
1606
url = content ["url" ]
1581
- response2 = self ._download (url , dest_path )
1607
+ response2 = self .download (url , dest_path )
1582
1608
logger .info (
1583
1609
"入力データ全件ファイルをダウンロードしました。 :: project_id='%s', Last-Modified='%s', file='%s'" ,
1584
1610
project_id ,
@@ -1603,7 +1629,7 @@ def download_project_tasks_url(self, project_id: str, dest_path: Union[str, Path
1603
1629
1604
1630
content , _ = self .api .get_project_tasks_url (project_id )
1605
1631
url = content ["url" ]
1606
- response2 = self ._download (url , dest_path )
1632
+ response2 = self .download (url , dest_path )
1607
1633
logger .info (
1608
1634
"タスク全件ファイルをダウンロードしました。 :: project_id='%s', Last-Modified='%s', file='%s'" ,
1609
1635
project_id ,
@@ -1635,7 +1661,7 @@ def download_project_inspections_url(self, project_id: str, dest_path: Union[str
1635
1661
1636
1662
content , _ = self .api .get_project_inspections_url (project_id )
1637
1663
url = content ["url" ]
1638
- response2 = self ._download (url , dest_path )
1664
+ response2 = self .download (url , dest_path )
1639
1665
logger .info (
1640
1666
"検査コメント全件ファイルをダウンロードしました。 :: project_id='%s', Last-Modified='%s', file='%s'" ,
1641
1667
project_id ,
@@ -1659,7 +1685,7 @@ def download_project_comments_url(self, project_id: str, dest_path: Union[str, P
1659
1685
1660
1686
content , _ = self .api .get_project_comments_url (project_id )
1661
1687
url = content ["url" ]
1662
- response = self ._download (url , dest_path )
1688
+ response = self .download (url , dest_path )
1663
1689
logger .info (
1664
1690
"コメント全件ファイルをダウンロードしました。 :: project_id='%s', Last-Modified='%s', file='%s'" ,
1665
1691
project_id ,
@@ -1684,7 +1710,7 @@ def download_project_task_history_events_url(self, project_id: str, dest_path: U
1684
1710
1685
1711
content , _ = self .api .get_project_task_history_events_url (project_id )
1686
1712
url = content ["url" ]
1687
- response2 = self ._download (url , dest_path )
1713
+ response2 = self .download (url , dest_path )
1688
1714
logger .info (
1689
1715
"タスク履歴イベント全件ファイルをダウンロードしました。 :: project_id='%s', Last-Modified='%s', file='%s'" ,
1690
1716
project_id ,
@@ -1709,7 +1735,7 @@ def download_project_task_histories_url(self, project_id: str, dest_path: Union[
1709
1735
1710
1736
content , _ = self .api .get_project_task_histories_url (project_id )
1711
1737
url = content ["url" ]
1712
- response2 = self ._download (url , dest_path )
1738
+ response2 = self .download (url , dest_path )
1713
1739
logger .info (
1714
1740
"タスク履歴全件ファイルをダウンロードしました。 :: project_id='%s', Last-Modified='%s', file='%s'" ,
1715
1741
project_id ,
0 commit comments