<s> class B2Error ( Exception ) : <EOL> def should_retry_http ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def should_retry_upload ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> class AlreadyFailed ( B2Error ) : <EOL> def __init__ ( self , message ) : <EOL> self . message = message <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . message , ) <EOL> class BadJson ( B2Error ) : <EOL> def __init__ ( self , message ) : <EOL> self . message = message <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . message , ) <EOL> class BadFileInfo ( B2Error ) : <EOL> def __init__ ( self , data ) : <EOL> self . data = data <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . data , ) <EOL> class BadUploadUrl ( B2Error ) : <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . message , ) <EOL> class BrokenPipe ( B2Error ) : <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' <EOL> def should_retry_upload ( self ) : <EOL> return True <EOL> class ChecksumMismatch ( B2Error ) : <EOL> def __init__ ( self , checksum_type , expected , actual ) : <EOL> self . checksum_type = checksum_type <EOL> self . expected = expected <EOL> self . actual = actual <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . checksum_type , ) <EOL> class CommandError ( B2Error ) : <EOL> def __init__ ( self , message ) : <EOL> self . message = message <EOL> def __str__ ( self ) : <EOL> return self . message <EOL> class CorruptAccountInfo ( B2Error ) : <EOL> def __init__ ( self , file_name ) : <EOL> self . file_name = file_name <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( <EOL> self . file_name , <EOL> ) <EOL> class ConnectionError ( B2Error ) : <EOL> def __init__ ( self , message ) : <EOL> self . message = message <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . message , ) <EOL> def should_retry_http ( self ) : <EOL> return True <EOL> def should_retry_upload ( self ) : <EOL> return True <EOL> class DestFileNewer ( B2Error ) : <EOL> def __init__ ( self , file_name ) : <EOL> self . file_name = file_name <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . file_name , ) <EOL> def should_retry_http ( self ) : <EOL> return True <EOL> class DuplicateBucketName ( B2Error ) : <EOL> def __init__ ( self , bucket_name ) : <EOL> self . bucket_name = bucket_name <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . bucket_name , ) <EOL> class FileAlreadyHidden ( B2Error ) : <EOL> def __init__ ( self , file_name ) : <EOL> self . file_name = file_name <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . file_name , ) <EOL> class FileNotPresent ( B2Error ) : <EOL> def __init__ ( self , file_name ) : <EOL> self . file_name = file_name <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . file_name , ) <EOL> class InvalidAuthToken ( B2Error ) : <EOL> def __init__ ( self , message , _type ) : <EOL> self . message = message <EOL> self . _type = _type <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . message , self . _type ) <EOL> def should_retry_upload ( self ) : <EOL> return True <EOL> class MaxFileSizeExceeded ( B2Error ) : <EOL> def __init__ ( self , size , max_allowed_size ) : <EOL> self . size = size <EOL> self . max_allowed_size = max_allowed_size <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . size , self . max_allowed_size , ) <EOL> class MaxRetriesExceeded ( B2Error ) : <EOL> def __init__ ( self , limit , exception_info_list ) : <EOL> self . limit = limit <EOL> self . exception_info_list = exception_info_list <EOL> def __str__ ( self ) : <EOL> exceptions = '<STR_LIT:\n>' . join ( str ( wrapped_error ) for wrapped_error in self . exception_info_list ) <EOL> return '<STR_LIT>' % ( <EOL> self . limit , <EOL> exceptions , <EOL> ) <EOL> class MissingAccountData ( B2Error ) : <EOL> def __init__ ( self , key ) : <EOL> self . key = key <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . key , ) <EOL> class MissingPart ( B2Error ) : <EOL> def __init__ ( self , key ) : <EOL> self . key = key <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . key , ) <EOL> class NonExistentBucket ( B2Error ) : <EOL> def __init__ ( self , bucket_name_or_id ) : <EOL> self . bucket_name_or_id = bucket_name_or_id <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . bucket_name_or_id , ) <EOL> class PartSha1Mismatch ( B2Error ) : <EOL> def __init__ ( self , key ) : <EOL> self . key = key <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . key , ) <EOL> class ServiceError ( B2Error ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , message ) : <EOL> self . message = message <EOL> def __str__ ( self ) : <EOL> return self . message <EOL> def should_retry_http ( self ) : <EOL> return True <EOL> def should_retry_upload ( self ) : <EOL> return True <EOL> class StorageCapExceeded ( B2Error ) : <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' <EOL> class TooManyRequests ( B2Error ) : <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' <EOL> def should_retry_http ( self ) : <EOL> return True <EOL> class TruncatedOutput ( B2Error ) : <EOL> def __init__ ( self , bytes_read , file_size ) : <EOL> self . bytes_read = bytes_read <EOL> self . file_size = file_size <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . bytes_read , self . file_size , ) <EOL> class UnknownError ( B2Error ) : <EOL> def __init__ ( self , message ) : <EOL> self . message = message <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . message , ) <EOL> class UnknownHost ( B2Error ) : <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' <EOL> class UnrecognizedBucketType ( B2Error ) : <EOL> def __init__ ( self , type_ ) : <EOL> self . type_ = type_ <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . type_ , ) <EOL> def interpret_b2_error ( status , code , message , post_params = None ) : <EOL> post_params = post_params or { } <EOL> if status == <NUM_LIT> and code == "<STR_LIT>" : <EOL> return FileAlreadyHidden ( post_params [ '<STR_LIT>' ] ) <EOL> elif status == <NUM_LIT> and code == '<STR_LIT>' : <EOL> return BadJson ( message ) <EOL> elif status == <NUM_LIT> and code in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> return FileNotPresent ( post_params [ '<STR_LIT>' ] ) <EOL> elif status == <NUM_LIT> and code == "<STR_LIT>" : <EOL> return DuplicateBucketName ( post_params [ '<STR_LIT>' ] ) <EOL> elif status == <NUM_LIT> and code == "<STR_LIT>" : <EOL> return MissingPart ( post_params [ '<STR_LIT>' ] ) <EOL> elif status == <NUM_LIT> and code == "<STR_LIT>" : <EOL> return PartSha1Mismatch ( post_params [ '<STR_LIT>' ] ) <EOL> elif status == <NUM_LIT> and code in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> return InvalidAuthToken ( message , code ) <EOL> elif status == <NUM_LIT> and code == "<STR_LIT>" : <EOL> return StorageCapExceeded ( ) <EOL> elif status == <NUM_LIT> : <EOL> return TooManyRequests ( ) <EOL> elif <NUM_LIT> <= status and status < <NUM_LIT> : <EOL> return ServiceError ( '<STR_LIT>' % ( status , code , message ) ) <EOL> else : <EOL> return UnknownError ( '<STR_LIT>' % ( status , code , message ) ) </s>
