1515from Crypto .Cipher import AES
1616from Crypto import Random
1717
18+ from exception import BridgeError , FarmerError , SuppliedTokenNotAcceptedError
1819from http import Client
19- from . import exception
2020
2121
2222class Uploader :
2323 """
2424
2525 Attributes:
26- client (): .
26+ client (:py:class:`storj.http.Client`): the Storj HTTP client .
2727 shared_already_uploaded (int): number of shards already uploaded.
2828 max_retries_contract_negotiation (int): maximum number of contract negotiation retries (default=10).
2929 max_retries_upload_same_farmer (int): maximum number of uploads retries to the same farmer (default=3).
@@ -199,9 +199,9 @@ def upload_shard(self, shard, chapters, frame, file_name_ready_to_shard_upload):
199199 j = json .loads (str (response .content ))
200200
201201 if j .get ('result' ) == 'The supplied token is not accepted' :
202- raise exception . SuppliedTokenNotAcceptedError ()
202+ raise SuppliedTokenNotAcceptedError ()
203203
204- except exception . FarmerError as e :
204+ except FarmerError as e :
205205 self .__logger .error (e )
206206 continue
207207
@@ -232,9 +232,9 @@ def upload_shard(self, shard, chapters, frame, file_name_ready_to_shard_upload):
232232
233233 j = json .loads (str (response .content ))
234234 if j .get ('result' ) == 'The supplied token is not accepted' :
235- raise exception . SuppliedTokenNotAcceptedError ()
235+ raise SuppliedTokenNotAcceptedError ()
236236
237- except exception . APIError as e :
237+ except BridgeError as e :
238238 self .__logger .error (e )
239239
240240 # upload failed due to Storj Bridge failure
@@ -335,7 +335,7 @@ def file_upload(self):
335335 push_token = None
336336 try :
337337 push_token = self .client .token_create (bucket_id , 'PUSH' )
338- except exception . APIError as e :
338+ except BridgeError as e :
339339 self .__logger .error (e )
340340 self .__logger .debug ('PUSH token create exception' )
341341
@@ -346,7 +346,7 @@ def file_upload(self):
346346
347347 try :
348348 frame = self .client .frame_create ()
349- except exception . APIError as e :
349+ except BridgeError as e :
350350 self .__logger .error (e )
351351 self .__logger .debug ('Unhandled exception while creating file staging frame' )
352352
@@ -409,7 +409,7 @@ def file_upload(self):
409409 )
410410 success = True
411411
412- except exception . APIError as e :
412+ except BridgeError as e :
413413 self .__logger .error (e )
414414 self .__logger .debug ('Unhandled bridge exception' )
415415
0 commit comments