anatools 5.1.27__py3-none-any.whl → 6.0.0__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.
@@ -274,8 +274,8 @@ def download_volume_data(self, volumeId, files=[], localDir=None, recursive=True
274
274
  if self.interactive:
275
275
  print(f"\x1b[1K\rdownload: {response[index]['key']} to {filename}", flush=True)
276
276
  except:
277
- traceback.print_exc()
278
- print(f"\x1b[1K\rdownload: failed to download {response[index]['key']}", flush=True)
277
+ if self.verbose: traceback.print_exc()
278
+ if self.interactive: print(f"\x1b[1K\rdownload: failed to download {response[index]['key']}", flush=True)
279
279
  return
280
280
 
281
281
 
@@ -330,7 +330,8 @@ def upload_volume_data(self, volumeId, files=None, localDir=None, destinationDir
330
330
  if sync == True:
331
331
  file_hash = generate_etag(filepath)
332
332
  source_hashes.append(file + file_hash)
333
- else: print(f"Could not find {filepath}.")
333
+ else:
334
+ if self.interactive: print(f"Could not find {filepath}.")
334
335
  else:
335
336
  for root, dirs, files in os.walk(localDir):
336
337
  for file in files:
@@ -371,37 +372,37 @@ def upload_volume_data(self, volumeId, files=None, localDir=None, destinationDir
371
372
  delete_files.append(destination_file)
372
373
 
373
374
  if (len(delete_files)):
374
- print(f"The following files will be deleted:", end='\n', flush=True)
375
- for file in delete_files:
376
- print(f" {file}", end='\n', flush=True)
377
- answer = input("Delete these files [Y/n]: ")
378
- if answer.lower() == "y":
379
- self.refresh_token()
380
- self.ana_api.deleteVolumeData(volumeId=volumeId, keys=delete_files)
375
+ if self.interactive:
376
+ print(f"The following files will be deleted:", end='\n', flush=True)
377
+ for file in delete_files:
378
+ print(f" {file}", end='\n', flush=True)
379
+ answer = input("Delete these files [Y/n]: ")
380
+ if answer.lower() == "y":
381
+ self.refresh_token()
382
+ self.ana_api.deleteVolumeData(volumeId=volumeId, keys=delete_files)
381
383
 
382
384
  for index, file in enumerate(source_files):
383
385
  destination_key = (destinationDir or '') + file
384
- print(f"\x1b[1K\rUploading {file} to the volume [{index+1} / {len(source_files)}]", end='\n' if self.verbose else '', flush=True)
386
+ if self.interactive: print(f"\x1b[1K\rUploading {file} to the volume [{index+1} / {len(source_files)}]", end='\n' if self.verbose else '', flush=True)
385
387
  if (sync == True and (source_hashes[index] in destination_hashes)):
386
- print(f"\x1b[1K\rsync: {file}'s hash exists", end='\n' if self.verbose else '', flush=True)
388
+ if self.interactive: print(f"\x1b[1K\rsync: {file}'s hash exists", end='\n' if self.verbose else '', flush=True)
387
389
  elif sync == False or (source_hashes[index] not in destination_hashes):
388
390
  try:
389
391
  self.refresh_token()
390
392
  filepath = os.path.join(localDir, file)
391
393
  filesize = os.path.getsize(filepath)
392
394
  fileinfo = self.ana_api.uploadVolumeData(volumeId=volumeId, key=destination_key, size=filesize)
393
- # print(f"\x1b[1K\rupload: {file} to the volume. [{index+1} / {len(source_files)}]", end='\n' if self.verbose else '', flush=True)
394
- parts = multipart_upload_file(filepath, int(fileinfo["partSize"]), fileinfo["urls"], f"Uploading {file} to the volume [{index+1} / {len(source_files)}]")
395
+ parts = multipart_upload_file(filepath, int(fileinfo["partSize"]), fileinfo["urls"], f"Uploading {file} to the volume [{index+1} / {len(source_files)}]", interactive=self.interactive)
395
396
  self.refresh_token()
396
397
  finalize_success = self.ana_api.uploadVolumeDataFinalizer(uploadId=fileinfo['uploadId'], key=fileinfo['key'], parts=parts)
397
398
  if not finalize_success:
398
399
  faileduploads.append(file)
399
400
  except:
400
- traceback.print_exc()
401
+ if self.verbose: traceback.print_exc()
401
402
  faileduploads.append(file)
402
- print(f"\x1b[1K\rupload: {file} failed", end='\n' if self.verbose else '', flush=True)
403
- print("\x1b[1K\rUploading files completed.", flush=True)
404
- if len(faileduploads): print('The following files failed to upload:', faileduploads, flush=True)
403
+ if self.interactive: print(f"\x1b[1K\rupload: {file} failed", end='\n' if self.verbose else '', flush=True)
404
+ if self.interactive: print("\x1b[1K\rUploading files completed.", flush=True)
405
+ if len(faileduploads) and self.interactive: print('The following files failed to upload:', faileduploads, flush=True)
405
406
  return
406
407
 
407
408
 
@@ -332,6 +332,7 @@ try:
332
332
  while resp not in [str(i) for i in range(len(channels)+1)]:
333
333
  resp = input(f'Invalid input, please enter a number between 0 and {len(channels)}: ')
334
334
  remotechannel = channels[int(resp)-1]
335
+ print_color(f"Selected channel: {remotechannel['name']}", color='brand')
335
336
  if volumes != remotechannel['volumes']:
336
337
  client.edit_channel(channelId=remotechannel['channelId'], volumes=volumes)
337
338
  remotechannel = client.get_channels(channelId=remotechannel['channelId'])[0]
@@ -493,6 +494,7 @@ try:
493
494
  while resp not in [str(i) for i in range(len(services)+1)]:
494
495
  resp = input(f'Invalid input, please enter a number between 0 and {len(services)}: ')
495
496
  remoteservice = services[int(resp)-1]
497
+ print_color(f"Selected service: {remoteservice['name']}", color='brand')
496
498
  if volumes != remoteservice['volumes']:
497
499
  client.edit_service(serviceId=remoteservice['serviceId'], volumes=volumes)
498
500
  remoteservice = client.get_services(serviceId=remoteservice['serviceId'])[0]