#NEWLINE# def test_utils_sftp_upload_and_download( ) : #NEWLINE# #INDENT# 'Tries to upload a file to an sftp file ' #NEWLINE# serverURL = ( 'sftp://ec2-54-212-85-156.us-west-2.compute.amazonaws.com/public/' + str ( uuid . uuid1 ( ) ) ) #NEWLINE# filepath = utils . make_bogus_binary_file ( ( ( 1 * MB ) - 777771 ) ) #NEWLINE# tempdir = tempfile . mkdtemp ( ) #NEWLINE# try : #NEWLINE# #INDENT# print ( '\n\tMade bogus file: ' , filepath ) #NEWLINE# url = syn . _sftpUploadFile ( filepath , url = serverURL ) #NEWLINE# print ( '\tStored URL:' , url ) #NEWLINE# print ( '\tDownloading' ) #NEWLINE# junk = syn . _sftpDownloadFile ( url , tempdir ) #NEWLINE# print ( '\tComparing:' , junk , filepath ) #NEWLINE# filecmp . cmp ( filepath , junk ) #NEWLINE# print ( '\tDownloading' ) #NEWLINE# junk2 = syn . _sftpDownloadFile ( url ) #NEWLINE# print ( '\tComparing:' , junk2 , filepath ) #NEWLINE# filecmp . cmp ( filepath , junk2 ) #NEWLINE# print ( '\tDownloading' ) #NEWLINE# junk3 = syn . _sftpDownloadFile ( url , os . path . join ( tempdir , 'bar.dat' ) ) #NEWLINE# print ( '\tComparing:' , junk3 , filepath ) #NEWLINE# filecmp . cmp ( filepath , junk3 ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( 'junk' in locals ( ) ) : #NEWLINE# #INDENT# os . remove ( junk ) #NEWLINE# #UNINDENT# if ( 'junk2' in locals ( ) ) : #NEWLINE# #INDENT# os . remove ( junk2 ) #NEWLINE# #UNINDENT# if ( 'junk3' in locals ( ) ) : #NEWLINE# #INDENT# os . remove ( junk3 ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# print ( traceback . format_exc ( ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# os . remove ( filepath ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# print ( traceback . format_exc ( ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# shutil . rmtree ( tempdir ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# print ( traceback . format_exc ( ) )