Skip to content

Output a dot every 1MB of FTP transfer #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion reports/src/boost_wide_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,25 @@ def update( self ):
utils.log( ' Skipping "%s" due to errors (%s)' % ( self.source_, msg ) )


class FtpFileProgress( object ):
def __init__(self, filename, mode='wb'):
self.f = open( filename, mode )
self.bytes_processed = 0
self.last_output = 0
self.output_size = 1000000

def write(self, file_bytes):
self.f.write(file_bytes)
self.bytes_processed += len(file_bytes)

if self.bytes_processed > self.last_output + self.output_size:
sys.stdout.write('.')
self.last_output += self.output_size

def close(self):
self.f.close()


def ftp_task( site, site_path , destination, filter_runners = None ):
__log__ = 1
utils.log( '' )
Expand All @@ -303,7 +322,7 @@ def ftp_task( site, site_path , destination, filter_runners = None ):
def synchronize():
for source in d[0]:
utils.log( 'Copying "%s"' % source )
result = open( os.path.join( destination, source ), 'wb' )
result = FtpFileProgress( os.path.join( destination, source ), 'wb')
f.retrbinary( 'RETR %s' % source, result.write )
result.close()
mod_date = find_by_name( source_content, source ).date
Expand Down