Ejemplo n.º 1
0
 def stream_binary_file(self, filename, progress_bar=True):
     binary_file = file_(filename, "rb")
     file_size = os.path.getsize(filename)
     buffer = binary_file.read(self.BUFFER_SIZE)
     if progress_bar:
         self.ui.set_progress_range(file_size)
         self.ui.set_progress_update_interval(file_size / 50)
         self.ui.increase_progress(len(buffer))
     while buffer:
         yield buffer
         buffer = binary_file.read(self.BUFFER_SIZE)
         if progress_bar:
             self.ui.increase_progress(len(buffer))
     if progress_bar:
         self.ui.set_progress_value(file_size)
Ejemplo n.º 2
0
 def stream_binary_file(self, filename, progress_bar=True):
     binary_file = file_(filename, "rb")
     file_size = path_getsize(filename)
     buffer = binary_file.read(self.BUFFER_SIZE)
     if progress_bar:
         self.ui.set_progress_range(file_size)
         self.ui.set_progress_update_interval(file_size/50)
         self.ui.increase_progress(len(buffer))
     while buffer:
         yield buffer
         buffer = binary_file.read(self.BUFFER_SIZE)
         if progress_bar:
             self.ui.increase_progress(len(buffer))
     if progress_bar:
         self.ui.set_progress_value(file_size)
Ejemplo n.º 3
0
 def download_binary_file(self, stream, filename, file_size,
                          progress_bar=True):
     directory = os.path.dirname(filename)
     if not os.path.exists(directory):
         os.makedirs(directory)
     downloaded_file = file_(filename, "wb")
     if progress_bar:
         self.ui.set_progress_range(file_size)
         self.ui.set_progress_update_interval(file_size/50)
     buffer = stream.read(self.BUFFER_SIZE)
     while buffer:
         downloaded_file.write(buffer)
         if progress_bar:
             self.ui.increase_progress(len(buffer))
         buffer = stream.read(self.BUFFER_SIZE)
     if progress_bar:
         self.ui.set_progress_value(file_size)
     downloaded_file.close()
Ejemplo n.º 4
0
 def download_binary_file(self,
                          stream,
                          filename,
                          file_size,
                          progress_bar=True):
     directory = os.path.dirname(filename)
     if not os.path.exists(directory):
         os.makedirs(directory)
     downloaded_file = file_(filename, "wb")
     if progress_bar:
         self.ui.set_progress_range(file_size)
         self.ui.set_progress_update_interval(file_size / 50)
     buffer = stream.read(self.BUFFER_SIZE)
     while buffer:
         downloaded_file.write(buffer)
         if progress_bar:
             self.ui.increase_progress(len(buffer))
         buffer = stream.read(self.BUFFER_SIZE)
     if progress_bar:
         self.ui.set_progress_value(file_size)
     downloaded_file.close()