Exemplo n.º 1
0
Arquivo: s3ci.py Projeto: mjs/juju
def fetch_juju_binary(bucket, revision_build, workspace):
    package_key, filename = find_package_key(bucket, revision_build)
    logging.info('Selected: %s', package_key.name)
    download_files([package_key], workspace)
    package_path = os.path.join(workspace, filename)
    logging.info('Extracting: %s', package_path)
    return acquire_binary(package_path, workspace)
Exemplo n.º 2
0
def fetch_juju_binary(bucket, revision_build, workspace):
    package_key, filename = find_package_key(bucket, revision_build)
    logging.info('Selected: %s', package_key.name)
    download_files([package_key], workspace)
    package_path = os.path.join(workspace, filename)
    logging.info('Extracting: %s', package_path)
    return acquire_binary(package_path, workspace)
Exemplo n.º 3
0
Arquivo: s3ci.py Projeto: mjs/juju
def fetch_files(bucket, revision_build, job, file_pattern, workspace):
    file_keys = find_file_keys(bucket, revision_build, job, file_pattern)
    out_files = [os.path.join(workspace, k.name.split('/')[-1])
                 for k in file_keys]
    for key in file_keys:
        logging.info('Selected: %s', key.name)
    download_files(file_keys, workspace)
    return out_files
Exemplo n.º 4
0
def fetch_files(bucket, revision_build, job, file_pattern, workspace):
    file_keys = find_file_keys(bucket, revision_build, job, file_pattern)
    out_files = [
        os.path.join(workspace,
                     k.name.split('/')[-1]) for k in file_keys
    ]
    for key in file_keys:
        logging.info('Selected: %s', key.name)
    download_files(file_keys, workspace)
    return out_files
Exemplo n.º 5
0
 def test_download_files__suffix(self):
     keys = [KeyStub("test.txt", "foo"), KeyStub("test2.tar", "foo2")]
     with temp_dir() as dst:
         downloaded_files = download_files(keys, dst, suffix=".tar")
         self.assertItemsEqual(os.listdir(dst), ['test2.tar'])
         self.assertEqual("foo2", get_file_content('test2.tar', dst))
     self.assertItemsEqual(downloaded_files, ['test2.tar'])
Exemplo n.º 6
0
 def test_download_files__suffix(self):
     keys = [KeyStub("test.txt", "foo"), KeyStub("test2.tar", "foo2")]
     with temp_dir() as dst:
         downloaded_files = download_files(keys, dst, suffix=".tar")
         self.assertItemsEqual(os.listdir(dst), ['test2.tar'])
         self.assertEqual("foo2", get_file_content('test2.tar', dst))
     self.assertItemsEqual(downloaded_files, ['test2.tar'])
Exemplo n.º 7
0
 def test_download_files__overwrite(self):
     keys = [KeyStub("test.txt", "foo"), KeyStub("test2.txt", "foo2")]
     with temp_dir() as dst:
         set_file_content("test.txt", "foo", dst)
         downloaded_files = download_files(keys, dst, overwrite=True)
         self.assertItemsEqual(os.listdir(dst), ['test.txt', 'test2.txt'])
         self.assertEqual("foo", get_file_content('test.txt', dst))
         self.assertEqual("foo2", get_file_content('test2.txt', dst))
     self.assertItemsEqual(downloaded_files, ['test.txt', 'test2.txt'])
Exemplo n.º 8
0
 def test_download_files__matching_file_already_exists(self):
     keys = [KeyStub("test.txt", "foo"), KeyStub("test2.txt", "foo2")]
     with temp_dir() as dst:
         set_file_content("test.txt", "foo", dst)
         downloaded_files = download_files(keys, dst)
         self.assertItemsEqual(os.listdir(dst), ['test.txt', 'test2.txt'])
         self.assertEqual("foo", get_file_content('test.txt', dst))
         self.assertEqual("foo2", get_file_content('test2.txt', dst))
     self.assertItemsEqual(downloaded_files, ['test2.txt'])
Exemplo n.º 9
0
 def test_download_files__overwrite(self):
     keys = [KeyStub("test.txt", "foo"), KeyStub("test2.txt", "foo2")]
     with temp_dir() as dst:
         set_file_content("test.txt", "foo", dst)
         downloaded_files = download_files(keys, dst, overwrite=True)
         self.assertItemsEqual(os.listdir(dst), ['test.txt', 'test2.txt'])
         self.assertEqual("foo", get_file_content('test.txt', dst))
         self.assertEqual("foo2", get_file_content('test2.txt', dst))
     self.assertItemsEqual(downloaded_files, ['test.txt', 'test2.txt'])
Exemplo n.º 10
0
 def test_download_files__matching_file_already_exists(self):
     keys = [KeyStub("test.txt", "foo"), KeyStub("test2.txt", "foo2")]
     with temp_dir() as dst:
         set_file_content("test.txt", "foo", dst)
         downloaded_files = download_files(keys, dst)
         self.assertItemsEqual(os.listdir(dst), ['test.txt', 'test2.txt'])
         self.assertEqual("foo", get_file_content('test.txt', dst))
         self.assertEqual("foo2", get_file_content('test2.txt', dst))
     self.assertItemsEqual(downloaded_files, ['test2.txt'])
Exemplo n.º 11
0
 def test_download_files__dst_dir_none(self):
     keys = [KeyStub("test.txt", "foo"), KeyStub("test2.txt", "foo2")]
     with patch('download_juju._download', autospec=True) as dj:
         download_files(keys)
     self.assertFalse(dj.called)
Exemplo n.º 12
0
 def test_download_files__dst_dir_none(self):
     keys = [KeyStub("test.txt", "foo"), KeyStub("test2.txt", "foo2")]
     with patch('download_juju._download', autospec=True) as dj:
         download_files(keys)
     self.assertFalse(dj.called)