Пример #1
0
 def test_encrypt_in_place(self):
     s3.cp(self.local_file,
           self.remote_file("to_encrypt.txt"),
           encrypt=False)  # just make sure there's something to copy
     self.assertFalse(
         s3.info(self.remote_file("to_encrypt.txt"))['encrypted'])
     s3.encrypt_at_rest(self.remote_file("to_encrypt.txt"))
     self.assertTrue(
         s3.info(self.remote_file("to_encrypt.txt"))['encrypted'])
Пример #2
0
 def test_s3_cp_content_encoding(self):
     s3.cp(self.local_file, self.remote_file("encoded.md"), encoding='gzip')
     self.assertEqual(s3.info(self.remote_file("encoded.md"))['content_encoding'], 'gzip')
     s3.cp(self.local_file, self.remote_file("notencoded.md")) # just make sure gzip isn't the default ;)
     self.assertNotEqual(s3.info(self.remote_file("notencoded.md"))['content_encoding'], 'gzip')
     s3.cp(self.remote_file("encoded.md"), self.remote_file("still_encoded.md"))
     self.assertEqual(s3.info(self.remote_file("still_encoded.md"))['content_encoding'], 'gzip')
     s3.cp(self.remote_file("notencoded.md"), self.remote_file("now_encoded.md"), encoding='gzip')
     self.assertEqual(s3.info(self.remote_file("now_encoded.md"))['content_encoding'], 'gzip')
Пример #3
0
 def test_s3_cp_gzip(self):
     s3.cp(self.local_file, self.remote_file("big.md"))
     s3.cp(self.local_file, self.remote_file("small.md"), gzip=True)
     self.assertNotEqual(
         s3.info(self.remote_file("big.md"))['content_encoding'], 'gzip')
     self.assertEqual(
         s3.info(self.remote_file("small.md"))['content_encoding'], 'gzip')
     self.assertLess(
         s3.info(self.remote_file("small.md"))['size'],
         s3.info(self.remote_file("big.md"))['size'])
Пример #4
0
 def test_upload(self):
     s3.cp(self.local_file,
           self.remote_file("unencrypted.txt"),
           encrypt=False)
     self.assertFalse(
         s3.info(self.remote_file("unencrypted.txt"))['encrypted'])
     s3.cp(self.local_file,
           self.remote_file("encrypted.txt"))  # default now to encrypt
     self.assertTrue(
         s3.info(self.remote_file("encrypted.txt"))['encrypted'])
Пример #5
0
 def test_copy(self):
     s3.cp(self.local_file,
           self.remote_file("unencrypted.txt"),
           encrypt=False)  # just make sure there's something to copy
     self.assertFalse(
         s3.info(self.remote_file("unencrypted.txt"))['encrypted'])
     s3.cp(self.remote_file("unencrypted.txt"),
           self.remote_file("encrypted.txt"))
     self.assertTrue(
         s3.info(self.remote_file("encrypted.txt"))['encrypted'])
Пример #6
0
    def test_s3_cp_content_type(self):
        s3.cp(self.local_file, self.remote_file("typed.md"), content_type='text/html')
        self.assertEqual(s3.info(self.remote_file("typed.md"))['content_type'], 'text/html')

        s3.cp(self.local_file, self.remote_file("nottyped.md")) # default is
        self.assertEqual(s3.info(self.remote_file("nottyped.md"))['content_type'], 'application/octet-stream')

        s3.cp(self.remote_file("typed.md"), self.remote_file("still_typed.md"))
        self.assertEqual(s3.info(self.remote_file("still_typed.md"))['content_type'], 'text/html')
        s3.cp(self.remote_file("nottyped.md"), self.remote_file("now_typed.md"), content_type='text/html')
        self.assertEqual(s3.info(self.remote_file("now_typed.md"))['content_type'], 'text/html')
Пример #7
0
 def test_s3_cp_download_versioned_success_with_valid_version_id(self):
     version_id = s3.info(self.existing_versioned_remote_file)['version_id']
     s3.cp(self.existing_versioned_remote_file,
           os.path.join(self.tmp_dir, 'DL', 'TEST.foo'),
           version_id=version_id)
     self.assertTrue(
         os.path.exists(os.path.join(self.tmp_dir, 'DL', 'TEST.foo')))
Пример #8
0
    def test_s3_open_read_versioned_remote_file(self):
        remote_file_name = self.existing_versioned_remote_file
        version_id = s3.info(remote_file_name)['version_id']

        with s3.open(remote_file_name, 'r', version_id=version_id) as f:
            tempname = f.name

        self.assertFalse(os.path.exists(tempname))
Пример #9
0
    def test_s3_open_read_versioned_remote_file(self):
        remote_file_name = self.existing_versioned_remote_file
        version_id = s3.info(remote_file_name)['version_id']

        with s3.open(remote_file_name, 'r', version_id=version_id) as f:
            tempname = f.name

        self.assertFalse(os.path.exists(tempname))
Пример #10
0
 def test_s3_cp_content_encoding(self):
     s3.cp(self.local_file, self.remote_file("encoded.md"), encoding='gzip')
     self.assertEqual(
         s3.info(self.remote_file("encoded.md"))['content_encoding'],
         'gzip')
     s3.cp(self.local_file, self.remote_file(
         "notencoded.md"))  # just make sure gzip isn't the default ;)
     self.assertNotEqual(
         s3.info(self.remote_file("notencoded.md"))['content_encoding'],
         'gzip')
     s3.cp(self.remote_file("encoded.md"),
           self.remote_file("still_encoded.md"))
     self.assertEqual(
         s3.info(self.remote_file("still_encoded.md"))['content_encoding'],
         'gzip')
     s3.cp(self.remote_file("notencoded.md"),
           self.remote_file("now_encoded.md"),
           encoding='gzip')
     self.assertEqual(
         s3.info(self.remote_file("now_encoded.md"))['content_encoding'],
         'gzip')
Пример #11
0
    def test_s3_cp_content_type(self):
        s3.cp(self.local_file,
              self.remote_file("typed.md"),
              content_type='text/html')
        self.assertEqual(
            s3.info(self.remote_file("typed.md"))['content_type'], 'text/html')

        s3.cp(self.local_file, self.remote_file("nottyped.md"))  # default is
        self.assertEqual(
            s3.info(self.remote_file("nottyped.md"))['content_type'],
            'application/octet-stream')

        s3.cp(self.remote_file("typed.md"), self.remote_file("still_typed.md"))
        self.assertEqual(
            s3.info(self.remote_file("still_typed.md"))['content_type'],
            'text/html')
        s3.cp(self.remote_file("nottyped.md"),
              self.remote_file("now_typed.md"),
              content_type='text/html')
        self.assertEqual(
            s3.info(self.remote_file("now_typed.md"))['content_type'],
            'text/html')
Пример #12
0
 def main(self, key):
     if self.uri:
         print "-B and --uri are deprecated options"
     try:
         keys = s3.ls(key, return_full_urls=True, require_s3_scheme=True, shallow=self.shallow, list_versions=self.list_versions)
         if self.detail:
             from baiji.util.console import sizeof_format_human_readable
             for key in keys:
                 info = s3.info(key)
                 enc = " enc" if info['encrypted'] else "    "
                 print "%s\t%s%s\t%s\t%s" % (sizeof_format_human_readable(info['size']), info['last_modified'], enc, key.encode('utf-8'), info['version_id'])
         else:
             print u"\n".join(keys).encode('utf-8')
     except s3.InvalidSchemeException as e:
         print e
         return 1
Пример #13
0
 def main(self, key):
     if self.uri:
         print "-B and --uri are deprecated options"
     try:
         keys = s3.ls(key,
                      return_full_urls=True,
                      require_s3_scheme=True,
                      shallow=self.shallow,
                      list_versions=self.list_versions)
         if self.detail:
             from baiji.util.console import sizeof_format_human_readable
             for key in keys:
                 info = s3.info(key)
                 enc = " enc" if info['encrypted'] else "    "
                 print "%s\t%s%s\t%s\t%s" % (sizeof_format_human_readable(
                     info['size']), info['last_modified'], enc,
                                             key.encode('utf-8'),
                                             info['version_id'])
         else:
             print u"\n".join(keys).encode('utf-8')
     except s3.InvalidSchemeException as e:
         print e
         return 1
Пример #14
0
 def test_s3_cp_gzip(self):
     s3.cp(self.local_file, self.remote_file("big.md"))
     s3.cp(self.local_file, self.remote_file("small.md"), gzip=True)
     self.assertNotEqual(s3.info(self.remote_file("big.md"))['content_encoding'], 'gzip')
     self.assertEqual(s3.info(self.remote_file("small.md"))['content_encoding'], 'gzip')
     self.assertLess(s3.info(self.remote_file("small.md"))['size'], s3.info(self.remote_file("big.md"))['size'])
Пример #15
0
 def test_s3_cp_download_versioned_success_with_valid_version_id(self):
     version_id = s3.info(self.existing_versioned_remote_file)['version_id']
     s3.cp(self.existing_versioned_remote_file, os.path.join(self.tmp_dir, 'DL', 'TEST.foo'), version_id=version_id)
     self.assertTrue(os.path.exists(os.path.join(self.tmp_dir, 'DL', 'TEST.foo')))
Пример #16
0
 def test_encrypt_in_place(self):
     s3.cp(self.local_file, self.remote_file("to_encrypt.txt"), encrypt=False) # just make sure there's something to copy
     self.assertFalse(s3.info(self.remote_file("to_encrypt.txt"))['encrypted'])
     s3.encrypt_at_rest(self.remote_file("to_encrypt.txt"))
     self.assertTrue(s3.info(self.remote_file("to_encrypt.txt"))['encrypted'])
Пример #17
0
 def test_upload(self):
     s3.cp(self.local_file, self.remote_file("unencrypted.txt"), encrypt=False)
     self.assertFalse(s3.info(self.remote_file("unencrypted.txt"))['encrypted'])
     s3.cp(self.local_file, self.remote_file("encrypted.txt")) # default now to encrypt
     self.assertTrue(s3.info(self.remote_file("encrypted.txt"))['encrypted'])
Пример #18
0
 def test_copy(self):
     s3.cp(self.local_file, self.remote_file("unencrypted.txt"), encrypt=False) # just make sure there's something to copy
     self.assertFalse(s3.info(self.remote_file("unencrypted.txt"))['encrypted'])
     s3.cp(self.remote_file("unencrypted.txt"), self.remote_file("encrypted.txt"))
     self.assertTrue(s3.info(self.remote_file("encrypted.txt"))['encrypted'])
Пример #19
0
 def main(self, key):
     for k, v in sorted(s3.info(key).items(), key=lambda x: x[0]):
         print "%s: %s" % (k, v)
Пример #20
0
 def main(self, key):
     for k, v in sorted(s3.info(key).items(), key=lambda x: x[0]):
         print "%s: %s" % (k, v)