As @AlexChamberlain says, the best way you have to do what you want is to patch the mega library so you can use its output and make good use of it, you can change the code easily as follows:
in the file mega/mega.py you change the download_file method so it calls a callback on all results instead of printing them:
def download_file(self, file_handle, file_key, dest_path=None, dest_filename=None, is_public=False, file=None, callback=None):
Then you use that callback at line 496. Instead of that line:
print('{0} of {1} downloaded'.format(file_info.st_size, file_size))
you add:
if callback:
callback(file_info.st_size, file_size)
else:
print('{0} of {1} downloaded'.format(file_info.st_size, file_size))
And then you have to change the prototypes of all functions that call download_file(), e.g. for download():
def download(self, file, dest_path=None, dest_filename=None, callback=None):
"""
Download a file by it's file object
"""
self.download_file(None, None, file=file[1], dest_path=dest_path, dest_filename=dest_filename, is_public=False, callback=callback)
And finally you can use download as follows:
def myupdater(current, total):
print "downloaded {0}/{1} so far".format(current, total)
mega.download('xxx', '/tmp', 'foo', callback=myupdater)
of course my answer is not complete (you'll have to do it for download_url and find if you shall apply the same pattern for other features, like upload). But I hope you get the idea, so you can be proud of committing a patch to an opensource project!
N.B.: to create a patch, you shall look at this document at github's.
HTH
diffcommand to submit it to the author(s) of the module. As for how to modify the module, I'd start off with adding a function parameter that contains a callback which is invoked instead of the print() output.