'DoUpload helper to upload files that need to be uploaded.
Args:
missing_files: List of files that need to be uploaded. Begin returns such
a list. Design note: we don\'t call Begin here, because we want DoUpload
to call it directly so that Begin/Commit are more clearly paired.
openfunc: Function that takes a path relative to the app\'s base path, and
returns a file-like object.'

def _UploadMissingFiles(self, missing_files, openfunc):

    if (not missing_files):
        return
    StatusUpdate(('Uploading    %d    files    and    blobs.' % len(missing_files)), self.error_fh)
    num_files = 0
    for missing_file in missing_files:
        file_handle = openfunc(missing_file)
        try:
            self.UploadFile(missing_file, file_handle)
        finally:
            file_handle.close()
        num_files += 1
        if ((num_files % 500) == 0):
            StatusUpdate(('Processed    %d    out    of    %s.' % (num_files, len(missing_files))), self.error_fh)
    self.file_batcher.Flush()
    self.blob_batcher.Flush()
    self.errorblob_batcher.Flush()
    StatusUpdate(('Uploaded    %d    files    and    blobs.' % num_files), self.error_fh)
