Ejemplo n.º 1
0
    def _download(self, manager, bucket, key):
        """
        Download the specified object and print it to stdout.

        :type manager: s3transfer.manager.TransferManager
        :param manager: The transfer manager to use for the download.

        :type bucket: str
        :param bucket: The bucket to download the object from.

        :type key: str
        :param key: The name of the key to download.

        :return: A CommandResult representing the download status.
        """
        params = {}
        # `download` performs the head_object as well, but the params are
        # the same for both operations, so there's nothing missing here.
        RequestParamsMapper.map_get_object_params(params, self.params)

        with manager:
            future = manager.download(fileobj=StdoutBytesWriter(),
                                      bucket=bucket,
                                      key=key,
                                      extra_args=params)

            return self._process_transfer(future)
Ejemplo n.º 2
0
 def test_stdout_wrapper(self):
     wrapper = StdoutBytesWriter(self.stdout)
     wrapper.write(b"foo")
     self.assertTrue(self.stdout.write.called)
     self.assertEqual(self.stdout.write.call_args[0][0], b"foo")
 def test_stdout_wrapper(self):
     wrapper = StdoutBytesWriter(self.stdout)
     wrapper.write(b'foo')
     self.assertTrue(self.stdout.write.called)
     self.assertEqual(self.stdout.write.call_args[0][0], b'foo')
Ejemplo n.º 4
0
 def _get_fileout(self, fileinfo):
     return StdoutBytesWriter()