#NEWLINE# def export( container , path ) : #NEWLINE# #INDENT# "\n    Export a container to a file\n\n    container\n        container id\n    path\n        path to which file is to be exported\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' docker.export <container id>\n    " #NEWLINE# try : #NEWLINE# #INDENT# ppath = os . path . abspath ( path ) #NEWLINE# with salt . utils . fopen ( ppath , 'w' ) as fic : #NEWLINE# #INDENT# status = base_status . copy ( ) #NEWLINE# client = _get_client ( ) #NEWLINE# response = client . export ( _get_container_infos ( container ) [ 'Id' ] ) #NEWLINE# byte = response . read ( 4096 ) #NEWLINE# fic . write ( byte ) #NEWLINE# while ( byte != '' ) : #NEWLINE# #INDENT# byte = response . read ( 4096 ) #NEWLINE# fic . write ( byte ) #NEWLINE# #UNINDENT# fic . flush ( ) #NEWLINE# #UNINDENT# _valid ( status , id_ = container , out = ppath , comment = 'Exported to {0}' . format ( ppath ) ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# _invalid ( status , id_ = container , out = traceback . format_exc ( ) ) #NEWLINE# #UNINDENT# return status