gazu 0.10.16__py2.py3-none-any.whl → 0.10.17__py2.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.
gazu/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.10.16"
1
+ __version__ = "0.10.17"
gazu/client.py CHANGED
@@ -303,6 +303,32 @@ def delete(path, params=None, client=default_client):
303
303
  return response.text
304
304
 
305
305
 
306
+ def get_message_from_response(
307
+ response, default_message="No additional information"
308
+ ):
309
+ """
310
+ A utility function that handles Zou's inconsistent message keys.
311
+ For a given request, checks if any error messages or regular messages were given and returns their value.
312
+ If no messages are found, returns a default message.
313
+
314
+ Args:
315
+ response: requests.Request - A response to check.
316
+ default_message: str - An optional default value to revert to if no message is detected.
317
+
318
+ Returns:
319
+ The message of a given response, or a default message - if any.
320
+ """
321
+ message = default_message
322
+ message_json = response.json()
323
+
324
+ for key in ["error", "message"]:
325
+ if message_json.get(key):
326
+ message = message_json[key]
327
+ break
328
+
329
+ return message
330
+
331
+
306
332
  def check_status(request, path, client=None):
307
333
  """
308
334
  Raise an exception related to status code, if the status code does not
@@ -329,8 +355,7 @@ def check_status(request, path, client=None):
329
355
  elif status_code == 403:
330
356
  raise NotAllowedException(path)
331
357
  elif status_code == 400:
332
- text = request.json().get("message", "No additional information")
333
- raise ParameterException(path, text)
358
+ raise ParameterException(path, get_message_from_response(request))
334
359
  elif status_code == 405:
335
360
  raise MethodNotAllowedException(path)
336
361
  elif status_code == 413:
@@ -359,14 +384,15 @@ def check_status(request, path, client=None):
359
384
  raise
360
385
  elif status_code in [500, 502]:
361
386
  try:
387
+ print("A server error occured!\n")
362
388
  stacktrace = request.json().get(
363
389
  "stacktrace", "No stacktrace sent by the server"
364
390
  )
365
- message = request.json().get(
366
- "message", "No message sent by the server"
367
- )
368
- print("A server error occured!\n")
369
391
  print("Server stacktrace:\n%s" % stacktrace)
392
+ message = get_message_from_response(
393
+ response=request,
394
+ default_message="No message sent by the server",
395
+ )
370
396
  print("Error message:\n%s\n" % message)
371
397
  except Exception:
372
398
  print(request.text)
@@ -474,8 +500,11 @@ def upload(path, file_path, data={}, extra_files=[], client=default_client):
474
500
  except JSONDecodeError:
475
501
  print(response.text)
476
502
  raise
477
- if "message" in result:
478
- raise UploadFailedException(result["message"])
503
+
504
+ result_message = get_message_from_response(response, default_message="")
505
+ if result_message:
506
+ raise UploadFailedException(result_message)
507
+
479
508
  return result
480
509
 
481
510
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gazu
3
- Version: 0.10.16
3
+ Version: 0.10.17
4
4
  Summary: Gazu is a client for Zou, the API to store the data of your CG production.
5
5
  Home-page: https://gazu.cg-wire.com/
6
6
  Author: CG Wire
@@ -1,9 +1,9 @@
1
1
  gazu/__init__.py,sha256=gVhtpZsvDiPuqvsEbCrgm6fKw8hluUhqspmlgGNIAvQ,3020
2
- gazu/__version__.py,sha256=42JGoIUYC3OTcHv48Vyebrqa1zvt0Ul05GgS6njtjLQ,24
2
+ gazu/__version__.py,sha256=S5Wijq3rq4_r-gYF455YCj2KcVfNM-QJlkM_f8Ti4x0,24
3
3
  gazu/asset.py,sha256=GWwam0yqHna_b9_5g5r0-O2zhMb7KlhfbIC17IOXKkY,14488
4
4
  gazu/cache.py,sha256=MnxrnfYN7wHNTTL7qzkEpYCYzWcolT56fqQ0_RegMbE,5879
5
5
  gazu/casting.py,sha256=0LTdsHaCTHSKEflBWFeuraSaYNYetGkMHAIdg6Lv81U,5059
6
- gazu/client.py,sha256=YRIxX7u095XTe28JM0tMZ05WoTcYexJGS2jrxXSAQvs,14640
6
+ gazu/client.py,sha256=1Ak9gXp-3tTAHgXYzY_y5CVt1vQjocvtkOGgOrEe_PY,15527
7
7
  gazu/concept.py,sha256=GcOPEmkbtZcSwlX8tnUj9Q5DTPBprSxtmXhlq7ioPwk,3727
8
8
  gazu/context.py,sha256=iUyug8EUz3kkF-kmYlH5JuLp66TUqR3uhAq7CouVd_U,4349
9
9
  gazu/edit.py,sha256=sPSsnzykGr1Htl6ceKulUSVHGhoQLGLeWDni3Pul7BE,4609
@@ -22,8 +22,8 @@ gazu/sorting.py,sha256=qSIO0pOHkj0Tl4gm9BJrYrcifWGGGmsW68Pl86zB_bg,266
22
22
  gazu/sync.py,sha256=0ZJ5Z7Nuh5Kj4cswZCXLpXTLf8zQRcXsBLnurMw-i_E,21627
23
23
  gazu/task.py,sha256=rnOKunR-vXLQPkD5nOufPhppYLLkgAWZS9tYlutCMp0,36412
24
24
  gazu/user.py,sha256=GyJf6mrynHvLllw3Hsiv-6wjaYTHO_PBNkJzyJjJA1A,9556
25
- gazu-0.10.16.dist-info/LICENSE,sha256=2n6rt7r999OuXp8iOqW9we7ORaxWncIbOwN1ILRGR2g,7651
26
- gazu-0.10.16.dist-info/METADATA,sha256=izhNmWl2_06y8RzzDu1iLROBuFhKJU3R8_HJX0Rb3-Y,5264
27
- gazu-0.10.16.dist-info/WHEEL,sha256=AHX6tWk3qWuce7vKLrj7lnulVHEdWoltgauo8bgCXgU,109
28
- gazu-0.10.16.dist-info/top_level.txt,sha256=nv7fRIVpYYyIlk_66hBmMyvWcSC7UU-r-GE8uC1u1Go,5
29
- gazu-0.10.16.dist-info/RECORD,,
25
+ gazu-0.10.17.dist-info/LICENSE,sha256=2n6rt7r999OuXp8iOqW9we7ORaxWncIbOwN1ILRGR2g,7651
26
+ gazu-0.10.17.dist-info/METADATA,sha256=Gt-aWHEx66R7KrBHVndGK13GTa-xLnSV-WQsjFTvaKE,5264
27
+ gazu-0.10.17.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
28
+ gazu-0.10.17.dist-info/top_level.txt,sha256=nv7fRIVpYYyIlk_66hBmMyvWcSC7UU-r-GE8uC1u1Go,5
29
+ gazu-0.10.17.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.5.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any