qmenta-client 0.11.dev1158__py3-none-any.whl → 0.11.dev1173__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.
qmenta/client/Account.py CHANGED
@@ -4,6 +4,7 @@ import logging
4
4
  from urllib3.exceptions import HTTPError
5
5
 
6
6
  from qmenta.core import platform
7
+ from qmenta.core import errors
7
8
 
8
9
  from .Project import Project
9
10
  from .utils import load_json
@@ -67,7 +68,7 @@ class Account:
67
68
  auth = platform.Auth.login(
68
69
  self.username, self.password, base_url=self.baseurl
69
70
  )
70
- except platform.PlatformError as e:
71
+ except errors.PlatformError as e:
71
72
  logger.error('Failed to log in: {}'.format(e))
72
73
  self.auth = None
73
74
  raise
@@ -81,14 +82,14 @@ class Account:
81
82
 
82
83
  Raises
83
84
  ------
84
- qmenta.core.platform.PlatformError
85
+ qmenta.core.errors.PlatformError
85
86
  When the logout was not successful
86
87
  """
87
88
 
88
89
  logger = logging.getLogger(logger_name)
89
90
  try:
90
91
  platform.parse_response(platform.post(self.auth, 'logout'))
91
- except platform.PlatformError as e:
92
+ except errors.PlatformError as e:
92
93
  logger.error('Logout was unsuccessful: {}'.format(e))
93
94
  raise
94
95
 
@@ -137,7 +138,7 @@ class Account:
137
138
  data = platform.parse_response(platform.post(
138
139
  self.auth, 'projectset_manager/get_projectset_list'
139
140
  ))
140
- except platform.PlatformError as e:
141
+ except errors.PlatformError as e:
141
142
  logger.error('Failed to get project list: {}'.format(e))
142
143
  raise
143
144
 
@@ -189,7 +190,7 @@ class Account:
189
190
  "users": "|".join(users)
190
191
  }
191
192
  ))
192
- except platform.PlatformError as e:
193
+ except errors.PlatformError as e:
193
194
  logger.error(e)
194
195
  return False
195
196
 
qmenta/client/Project.py CHANGED
@@ -10,6 +10,7 @@ import logging
10
10
  from enum import Enum
11
11
 
12
12
  from qmenta.core import platform
13
+ from qmenta.core import errors
13
14
 
14
15
  from .Subject import Subject
15
16
 
@@ -138,7 +139,7 @@ class Project:
138
139
  'projectset_manager/activate_project',
139
140
  data={"project_id": int(project_id)}
140
141
  ))
141
- except platform.PlatformError:
142
+ except errors.PlatformError:
142
143
  logger.error('Unable to activate the project.')
143
144
  return False
144
145
 
@@ -236,7 +237,7 @@ class Project:
236
237
  data = platform.parse_response(platform.post(
237
238
  self._account.auth, 'patient_manager/module_config'
238
239
  ))
239
- except platform.PlatformError:
240
+ except errors.PlatformError:
240
241
  logger.error("Could not retrieve metadata parameters.")
241
242
  return None
242
243
  return data['fields']
@@ -280,7 +281,7 @@ class Project:
280
281
  'patient_manager/save_metadata_changes',
281
282
  data=post_data
282
283
  ))
283
- except platform.PlatformError:
284
+ except errors.PlatformError:
284
285
  answer = {}
285
286
 
286
287
  if title not in answer:
@@ -432,7 +433,7 @@ class Project:
432
433
  self._account.auth, 'file_manager/get_container_files',
433
434
  data={'container_id': container_id}
434
435
  ))
435
- except platform.PlatformError as e:
436
+ except errors.PlatformError as e:
436
437
  logging.getLogger(logger_name).error(e)
437
438
  return False
438
439
 
@@ -462,7 +463,7 @@ class Project:
462
463
  self._account.auth, 'file_manager/get_container_files',
463
464
  data={"container_id": container_id}
464
465
  ))
465
- except platform.PlatformError as e:
466
+ except errors.PlatformError as e:
466
467
  logging.getLogger(logger_name).error(e)
467
468
  return False
468
469
 
@@ -577,6 +578,7 @@ class Project:
577
578
  zip_name : str
578
579
  Name of the zip where the downloaded files are stored.
579
580
  """
581
+ logger = logging.getLogger(logger_name)
580
582
 
581
583
  files_in_container = self.list_container_files(container_id)
582
584
  files_not_in_container = filter(lambda f: f not in files_in_container,
@@ -586,11 +588,21 @@ class Project:
586
588
  if files_not_in_container:
587
589
  msg = "The following files are missing in container {}: {}".format(
588
590
  container_id, ", ".join(files_not_in_container))
589
- logging.getLogger(logger_name).error(msg)
591
+ logger.error(msg)
590
592
  return False
591
593
 
592
- return self.download_file(container_id, ";".join(filenames),
593
- zip_name, overwrite)
594
+ params = {"container_id": container_id, "files": ";".join(filenames)}
595
+ with platform.post(self._account.auth, 'file_manager/download_file',
596
+ data=params, stream=True) as response, \
597
+ open(zip_name, "wb") as f:
598
+
599
+ for chunk in response.iter_content(chunk_size=2**9*1024):
600
+ f.write(chunk)
601
+ f.flush()
602
+
603
+ logger.info("Files from container {} saved to {}".format(
604
+ container_id, zip_name))
605
+ return True
594
606
 
595
607
  def get_subject_id(self, subject_name, cache=False):
596
608
  """
@@ -664,7 +676,7 @@ class Project:
664
676
  self._account.auth, 'patient_manager/upsert_patient',
665
677
  data={"secret_name": subject.name}
666
678
  ))
667
- except platform.PlatformError:
679
+ except errors.PlatformError:
668
680
  logger.error(
669
681
  "Subject {} could not be created.".format(subject.name))
670
682
  return False
@@ -726,7 +738,7 @@ class Project:
726
738
  "patient_id": str(int(session['_id'])), "delete_files": 1
727
739
  }
728
740
  ))
729
- except platform.PlatformError:
741
+ except errors.PlatformError:
730
742
  logger.error("Session '{}/{}' could not be deleted.".format(
731
743
  subject_name, session['ssid']
732
744
  ))
@@ -981,7 +993,7 @@ class Project:
981
993
 
982
994
  try:
983
995
  platform.parse_response(response)
984
- except platform.PlatformError as error:
996
+ except errors.PlatformError as error:
985
997
  logger.error(error)
986
998
  return False
987
999
 
@@ -1090,7 +1102,7 @@ class Project:
1090
1102
  'file_manager/copy_container_to_another_project',
1091
1103
  data=data
1092
1104
  ))
1093
- except platform.PlatformError as e:
1105
+ except errors.PlatformError as e:
1094
1106
  logging.getLogger(logger_name).error(
1095
1107
  'Couldn not copy container: {}'.format(e)
1096
1108
  )
@@ -1201,7 +1213,7 @@ class Project:
1201
1213
  endpoint='analysis_manager/delete_analysis',
1202
1214
  data={'project_id': analysis_id}
1203
1215
  ))
1204
- except platform.PlatformError as error:
1216
+ except errors.PlatformError as error:
1205
1217
  logger.error('Could not delete analysis: {}'.format(error))
1206
1218
  return False
1207
1219
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qmenta-client
3
- Version: 0.11.dev1158
3
+ Version: 0.11.dev1173
4
4
  Summary: Python client lib to interact with the QMENTA platform.
5
5
  Home-page: https://www.qmenta.com/
6
6
  Author: QMENTA
@@ -14,4 +14,4 @@ Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Requires-Dist: future (>=0.18.2,<0.19.0)
17
- Requires-Dist: qmenta-core (>=1.0,<1.1)
17
+ Requires-Dist: qmenta-core (>=3.0.1,<3.1.0)
@@ -0,0 +1,9 @@
1
+ qmenta/__init__.py,sha256=jv2YF__bseklT3OWEzlqJ5qE24c4aWd5F4r0TTjOrWQ,65
2
+ qmenta/client/Account.py,sha256=J4NI9YxlhAvNkAQjdEegiQRrzZsOkGgXbaPG4qX_GI0,9511
3
+ qmenta/client/Project.py,sha256=3Jm_1BRXirqe-LKqugmbw6c519TMspnulwLZJjB13f4,43788
4
+ qmenta/client/Subject.py,sha256=azcLeYKO8KTLq-dn0CNvhD9XN1tGjAXZS3lFZcFHDuc,8713
5
+ qmenta/client/__init__.py,sha256=AjTojBhZeW5nl0i605KS8S1Gl5tPNc1hdzD47BGNfoI,147
6
+ qmenta/client/utils.py,sha256=er8BT64WBbNYj4FysI1Mx3ZqHkOGCZPIMGcZeFDysrA,487
7
+ qmenta_client-0.11.dev1173.dist-info/METADATA,sha256=jr7LNIsUO83K2nbvXTKW_NwvFKlaJIp1WepGyIDCJVQ,658
8
+ qmenta_client-0.11.dev1173.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
9
+ qmenta_client-0.11.dev1173.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- qmenta/__init__.py,sha256=jv2YF__bseklT3OWEzlqJ5qE24c4aWd5F4r0TTjOrWQ,65
2
- qmenta/client/Account.py,sha256=LhUqPcB_GNGNffPJeZ6QyfLlEmbVHts1JHxITLAwE1M,9490
3
- qmenta/client/Project.py,sha256=XvxFwPFPQZnqmQ6bbL_wvue9LmQ3iImxCuxWf-XOzHQ,43363
4
- qmenta/client/Subject.py,sha256=azcLeYKO8KTLq-dn0CNvhD9XN1tGjAXZS3lFZcFHDuc,8713
5
- qmenta/client/__init__.py,sha256=AjTojBhZeW5nl0i605KS8S1Gl5tPNc1hdzD47BGNfoI,147
6
- qmenta/client/utils.py,sha256=er8BT64WBbNYj4FysI1Mx3ZqHkOGCZPIMGcZeFDysrA,487
7
- qmenta_client-0.11.dev1158.dist-info/METADATA,sha256=7buIS8z0zp7b5Vx4KCx7aPlQ142G0MNH0oLpdEoes8M,654
8
- qmenta_client-0.11.dev1158.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
9
- qmenta_client-0.11.dev1158.dist-info/RECORD,,