<s> import time <EOL> from . . azurectl_exceptions import ( <EOL> AzureRequestStatusError , <EOL> AzureRequestTimeout , <EOL> AzureRequestError <EOL> ) <EOL> class RequestResult ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , request_id ) : <EOL> self . request_id = request_id <EOL> self . request_timeout_count = <NUM_LIT> <EOL> self . request_timeout = <NUM_LIT:5> <EOL> def status ( self , service ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return service . get_operation_status ( self . request_id ) <EOL> except Exception as e : <EOL> raise AzureRequestStatusError ( <EOL> '<STR_LIT>' % ( type ( e ) . __name__ , format ( e ) ) <EOL> ) <EOL> def wait_for_request_completion ( self , service ) : <EOL> """<STR_LIT>""" <EOL> count = <NUM_LIT:0> <EOL> result = self . status ( service ) <EOL> while result . status == '<STR_LIT>' : <EOL> count = count + <NUM_LIT:1> <EOL> if count > self . request_timeout_count : <EOL> raise AzureRequestTimeout ( <EOL> '<STR_LIT>' % self . request_id <EOL> ) <EOL> time . sleep ( self . request_timeout ) <EOL> result = self . status ( service ) <EOL> if result . status != '<STR_LIT>' : <EOL> raise AzureRequestError ( <EOL> '<STR_LIT>' % ( <EOL> self . request_id , <EOL> format ( result . error . message ) , <EOL> format ( result . error . code ) <EOL> ) <EOL> ) </s>
