#NEWLINE# def download( self , remote_path , local_path ) : #NEWLINE# #INDENT# if self . use_chroot : #NEWLINE# #INDENT# remote_path = join_root ( PosixPath ( '/experimentroot' ) , remote_path ) #NEWLINE# #UNINDENT# temp = make_unique_name ( b'reprozip_output_' ) #NEWLINE# rtemp = ( PosixPath ( '/vagrant' ) / temp ) #NEWLINE# ltemp = ( self . target / temp ) #NEWLINE# logging . info ( 'Copying file to shared folder...' ) #NEWLINE# chan = self . ssh . get_transport ( ) . open_session ( ) #NEWLINE# cp_cmd = ( '/bin/cp %s %s' % ( shell_escape ( remote_path . path ) , shell_escape ( rtemp . path ) ) ) #NEWLINE# chown_cmd = ( '/bin/chown vagrant %s' % shell_escape ( rtemp . path ) ) #NEWLINE# chmod_cmd = ( '/bin/chmod 644 %s' % shell_escape ( rtemp . path ) ) #NEWLINE# chan . exec_command ( ( '/usr/bin/sudo /bin/sh -c %s' % shell_escape ( ' && ' . join ( ( cp_cmd , chown_cmd , chmod_cmd ) ) ) ) ) #NEWLINE# if ( chan . recv_exit_status ( ) != 0 ) : #NEWLINE# #INDENT# logging . critical ( "Couldn't copy file in virtual machine" ) #NEWLINE# try : #NEWLINE# #INDENT# ltemp . remove ( ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# ltemp . rename ( local_path ) #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# logging . critical ( "Couldn't download output file: %s\n%s" , remote_path , str ( e ) ) #NEWLINE# ltemp . remove ( ) #NEWLINE# return False #NEWLINE# #UNINDENT# return True