コード例 #1
0
    def download_incoming_files(self):
        logging.info("Started thread: listening for incoming files")
        msg = self.s.recv(files.BUFFER_SIZE)
        filename, file_size, bytesread, file_part = Message.decode(msg)
        other_filename = filename
        downloaded_bytes = 0

        while file_part:
            file_save_location = files.get_save_location(other_filename, self.backup_directory)
            files.make_dirs(file_save_location)
            file = open(file_save_location, "wb")
            progress = tqdm.tqdm(range(file_size), f"Receiving {filename}", unit="B", unit_scale=True,
                                 unit_divisor=1024)
            while filename == other_filename:
                downloaded_bytes += bytesread
                file.write(file_part)
                msg = self.s.recv(files.BUFFER_SIZE)
                if len(msg) > Message.id_msg_length:
                    other_filename, file_size, bytesread, file_part = Message.decode(msg)
                    progress.update(len(file_part))
                else:
                    file_part = 0
                    break
            progress.close()
            file.close()
            filename = other_filename
            downloaded_bytes = 0
        logging.info("All files have been received")
コード例 #2
0
ファイル: test_trash_empty.py プロジェクト: ahua/python
 def test_it_removes_trashinfos_from_method_1_dir(self):
     require_empty_dir(".fake_root")
     make_dirs(".fake_root/media/external-disk/.Trash/")
     set_sticky_bit(".fake_root/media/external-disk/.Trash/")
     having_file(".fake_root/media/external-disk/.Trash/123/info/foo.trashinfo")
     empty = EmptyCmd(
         out=StringIO(),
         err=StringIO(),
         environ={},
         getuid=lambda: 123,
         list_volumes=lambda: [".fake_root/media/external-disk"],
     )
     empty.run("trash-empty")
     assert not os.path.exists(".fake_root/media/external-disk/.Trash/123/info/foo.trashinfo")
コード例 #3
0
ファイル: test_trash_empty.py プロジェクト: dlancer/trash-cli
 def make_proper_top_trash_dir(self, path):
     make_dirs(path)
     set_sticky_bit(path)
コード例 #4
0
 def make_proper_top_trash_dir(self, path):
     make_dirs(path)
     set_sticky_bit(path)