@@ -437,7 +437,8 @@ def get_output(self,
437
437
job_id = None ,
438
438
otype = 'output' ,
439
439
url = None ,
440
- callback = None ):
440
+ callback = None ,
441
+ block = 1024 ):
441
442
"""
442
443
Gets the content of the job output or its thumbnail.
443
444
Either ``url``, or both ``job_id`` and ``otype`` must be set.
@@ -461,8 +462,10 @@ def get_output(self,
461
462
supplied, ``job_id`` and ``otype`` will not be used.
462
463
The default is None.
463
464
- callback (func): A function to be called to report download progress.
464
- The function takes a single parameter, the percent downloaded as a
465
- float.
465
+ The function takes three parameters: the percent downloaded (float), the
466
+ bytes downloaded (float), and the total bytes to be downloaded (float).
467
+ - block (int): The amount of data downloaded in each block - determines
468
+ the frequency with which the callback is called. Default is 1024.
466
469
467
470
:Returns:
468
471
- :class:`.Response` with the GET response, however this is not
@@ -474,14 +477,15 @@ def get_output(self,
474
477
"""
475
478
self ._log .debug (
476
479
"get_output, download_dir={dd}, size={sz}, fname={fn}, "
477
- "overwrite={ow}, job_id={ji}, url={ur}, otype={ot}" .format (
480
+ "overwrite={ow}, job_id={ji}, url={ur}, otype={ot}, block={bl} " .format (
478
481
dd = download_dir ,
479
482
sz = size ,
480
483
fn = fname ,
481
484
ow = overwrite ,
482
485
ji = job_id ,
483
486
ur = url ,
484
- ot = otype ))
487
+ ot = otype ,
488
+ bl = block ))
485
489
486
490
if not url and job_id :
487
491
if otype .lower () not in ['output' , 'preview' ]:
@@ -510,6 +514,7 @@ def get_output(self,
510
514
size ,
511
515
overwrite ,
512
516
f_name = fname ,
517
+ block_size = block ,
513
518
callback = callback )
514
519
515
520
except RestCallException as exp :
@@ -621,7 +626,8 @@ def get_output_file(self,
621
626
job_id = None ,
622
627
fname = None ,
623
628
url = None ,
624
- callback = None ):
629
+ callback = None ,
630
+ block = 1024 ):
625
631
"""
626
632
Gets the content of a file created in a job.
627
633
Either ``url``, or both ``job_id`` and ``fname`` must be set.
@@ -642,8 +648,10 @@ def get_output_file(self,
642
648
- url (str): The URL directly to the file to be downloaded.
643
649
The default is None.
644
650
- callback (func): A function to be called to report download progress.
645
- The function takes a single parameter, the percent downloaded as a
646
- float.
651
+ The function takes three parameters: the percent downloaded (float), the
652
+ bytes downloaded (float), and the total bytes to be downloaded (float).
653
+ - block (int): The amount of data downloaded in each block - determines
654
+ the frequency with which the callback is called. Default is 1024.
647
655
648
656
:Returns:
649
657
- :class:`.Response` with the GET response, however this is not
@@ -655,12 +663,13 @@ def get_output_file(self,
655
663
"""
656
664
self ._log .debug ("get_output_file, download_dir={dd}, size={sz}, "
657
665
"overwrite={ow}, job_id={ji}, fname={fn}, "
658
- "url={ur}" .format (dd = download_dir ,
666
+ "url={ur}, block={bl} " .format (dd = download_dir ,
659
667
sz = size ,
660
668
ow = overwrite ,
661
669
ji = job_id ,
662
670
fn = fname ,
663
- ur = url ))
671
+ ur = url ,
672
+ bl = block ))
664
673
665
674
name = fname if fname else None
666
675
@@ -683,6 +692,7 @@ def get_output_file(self,
683
692
download_dir ,
684
693
size , overwrite ,
685
694
f_name = name ,
695
+ block_size = block ,
686
696
callback = callback )
687
697
688
698
except RestCallException as exp :
@@ -1013,7 +1023,8 @@ def query_missing_files(self, files):
1013
1023
return Response (True , resp ['files' ])
1014
1024
1015
1025
1016
- def get_file (self , userfile , size , download_dir , overwrite = False , callback = None ):
1026
+ def get_file (self , userfile , size , download_dir , overwrite = False ,
1027
+ callback = None , block = 1024 ):
1017
1028
"""Gets the content of a file previously uploaded by the user.
1018
1029
1019
1030
:Args:
@@ -1029,8 +1040,10 @@ def get_file(self, userfile, size, download_dir, overwrite=False, callback=None)
1029
1040
- overwrite (bool): Whether to overwrite a destination file if it
1030
1041
already exists. The default is ``False``.
1031
1042
- callback (func): A function to be called to report download progress.
1032
- The function takes a single parameter, the percent downloaded as a
1033
- float.
1043
+ The function takes three parameters: the percent downloaded (float), the
1044
+ bytes downloaded (float), and the total bytes to be downloaded (float).
1045
+ - block (int): The amount of data downloaded in each block - determines
1046
+ the frequency with which the callback is called. Default is 1024.
1034
1047
1035
1048
:Returns:
1036
1049
- :class:`.Response` with the GET response, however this is not
@@ -1044,10 +1057,11 @@ def get_file(self, userfile, size, download_dir, overwrite=False, callback=None)
1044
1057
None ))
1045
1058
1046
1059
self ._log .debug ("get_file, file={0}, size={1}, "
1047
- "download_dir={2}, overwrite={3}" .format (userfile ,
1048
- size ,
1049
- download_dir ,
1050
- overwrite ))
1060
+ "download_dir={2}, overwrite={3}, block={4}" .format (userfile ,
1061
+ size ,
1062
+ download_dir ,
1063
+ overwrite ,
1064
+ block ))
1051
1065
url = userfile .url
1052
1066
self ._log .debug ("Get file url: {0}" .format (url ))
1053
1067
try :
@@ -1057,6 +1071,7 @@ def get_file(self, userfile, size, download_dir, overwrite=False, callback=None)
1057
1071
download_dir ,
1058
1072
size ,
1059
1073
overwrite = overwrite ,
1074
+ block_size = block ,
1060
1075
callback = callback )
1061
1076
1062
1077
except RestCallException as exp :
@@ -1098,7 +1113,7 @@ def props_file(self, userfile):
1098
1113
else :
1099
1114
return Response (True , head_resp )
1100
1115
1101
- def send_file (self , userfile , callback = None ):
1116
+ def send_file (self , userfile , callback = None , block = 1024 ):
1102
1117
"""Uploads a user file for use in a job.
1103
1118
1104
1119
:Args:
@@ -1108,8 +1123,10 @@ def send_file(self, userfile, callback=None):
1108
1123
1109
1124
:Kwargs:
1110
1125
- callback (func): A function to be called to report upload progress.
1111
- The function takes a single parameter, the percent uploaded as a
1112
- float.
1126
+ The function takes three parameters: the percent uploaded (float), the
1127
+ bytes uploaded (float), and the total bytes to be uploaded (float).
1128
+ - block (int): The amount of data uploaded in each block - determines
1129
+ the frequency with which the callback is called. Default is 1024.
1113
1130
1114
1131
:Returns:
1115
1132
- :class:`.Response` with the PUT response, however this is not
@@ -1140,6 +1157,7 @@ def send_file(self, userfile, callback=None):
1140
1157
self .headers ,
1141
1158
userfile ,
1142
1159
params ,
1160
+ block_size = block ,
1143
1161
callback = callback )
1144
1162
1145
1163
except (RestCallException , FileMissingException ) as exp :
0 commit comments