18
18
19
19
from vws .exceptions .custom_exceptions import (
20
20
OopsAnErrorOccurredPossiblyBadName ,
21
+ ServerError ,
21
22
TargetProcessingTimeout ,
23
+ TooManyRequests ,
22
24
)
23
25
from vws .exceptions .vws_exceptions import (
24
26
AuthenticationFailure ,
36
38
TargetQuotaReached ,
37
39
TargetStatusNotSuccess ,
38
40
TargetStatusProcessing ,
39
- TooManyRequests ,
40
41
UnknownTarget ,
41
42
)
42
43
from vws .reports import (
@@ -166,6 +167,10 @@ def _make_request(
166
167
an HTML page with the text "Oops, an error occurred". This has
167
168
been seen to happen when the given name includes a bad
168
169
character.
170
+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
171
+ with Vuforia's servers.
172
+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
173
+ limiting access.
169
174
json.decoder.JSONDecodeError: The server did not respond with valid
170
175
JSON. This may happen if the server address is not a valid
171
176
Vuforia server.
@@ -188,6 +193,11 @@ def _make_request(
188
193
# The Vuforia API returns a 429 response with no JSON body.
189
194
raise TooManyRequests (response = response )
190
195
196
+ if (
197
+ response .status_code >= HTTPStatus .INTERNAL_SERVER_ERROR
198
+ ): # pragma: no cover
199
+ raise ServerError (response = response )
200
+
191
201
result_code = response .json ()["result_code" ]
192
202
193
203
if result_code == expected_result_code :
@@ -268,6 +278,10 @@ def add_target(
268
278
Vuforia returns an HTML page with the text "Oops, an error
269
279
occurred". This has been seen to happen when the given name
270
280
includes a bad character.
281
+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
282
+ with Vuforia's servers.
283
+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
284
+ limiting access.
271
285
"""
272
286
image_data = _get_image_data (image = image )
273
287
image_data_encoded = base64 .b64encode (image_data ).decode ("ascii" )
@@ -314,6 +328,10 @@ def get_target_record(self, target_id: str) -> TargetStatusAndRecord:
314
328
does not match a target in the database.
315
329
~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
316
330
error with the time sent to Vuforia.
331
+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
332
+ with Vuforia's servers.
333
+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
334
+ limiting access.
317
335
"""
318
336
response = self ._make_request (
319
337
method = "GET" ,
@@ -371,6 +389,10 @@ def wait_for_target_processed(
371
389
does not match a target in the database.
372
390
~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
373
391
error with the time sent to Vuforia.
392
+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
393
+ with Vuforia's servers.
394
+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
395
+ limiting access.
374
396
"""
375
397
start_time = time .monotonic ()
376
398
while True :
@@ -402,6 +424,10 @@ def list_targets(self) -> list[str]:
402
424
known database.
403
425
~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
404
426
error with the time sent to Vuforia.
427
+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
428
+ with Vuforia's servers.
429
+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
430
+ limiting access.
405
431
"""
406
432
response = self ._make_request (
407
433
method = "GET" ,
@@ -435,6 +461,10 @@ def get_target_summary_report(self, target_id: str) -> TargetSummaryReport:
435
461
does not match a target in the database.
436
462
~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
437
463
error with the time sent to Vuforia.
464
+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
465
+ with Vuforia's servers.
466
+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
467
+ limiting access.
438
468
"""
439
469
response = self ._make_request (
440
470
method = "GET" ,
@@ -474,6 +504,10 @@ def get_database_summary_report(self) -> DatabaseSummaryReport:
474
504
known database.
475
505
~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
476
506
error with the time sent to Vuforia.
507
+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
508
+ with Vuforia's servers.
509
+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
510
+ limiting access.
477
511
"""
478
512
response = self ._make_request (
479
513
method = "GET" ,
@@ -520,6 +554,10 @@ def delete_target(self, target_id: str) -> None:
520
554
target is in the processing state.
521
555
~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
522
556
error with the time sent to Vuforia.
557
+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
558
+ with Vuforia's servers.
559
+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
560
+ limiting access.
523
561
"""
524
562
self ._make_request (
525
563
method = "DELETE" ,
@@ -553,6 +591,10 @@ def get_duplicate_targets(self, target_id: str) -> list[str]:
553
591
inactive.
554
592
~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
555
593
error with the time sent to Vuforia.
594
+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
595
+ with Vuforia's servers.
596
+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
597
+ limiting access.
556
598
"""
557
599
response = self ._make_request (
558
600
method = "GET" ,
@@ -612,6 +654,10 @@ def update_target(
612
654
inactive.
613
655
~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
614
656
error with the time sent to Vuforia.
657
+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
658
+ with Vuforia's servers.
659
+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
660
+ limiting access.
615
661
"""
616
662
data : dict [str , str | bool | float | int ] = {}
617
663
0 commit comments