Exemplo n.º 1
0
    def setUp(self):
        super(ApplicationTestCase, self).setUp()

        shutil.copy(
            os.path.join(FIXTURES_DIR, 'config.py'), self.tmppath('config.py'))

        store = LocalRepositoryStore(self.mkdir('artifacts'))
        self.repo = Repository(store)
        self.app = Application('test', self.tmppath('config.py'))
        if not os.path.exists('test-data/deploy-ve/virtualenv.tar.gz'):
            self._create_test_ve()
        self._deploy_ve_hash = ve_version(sha224sum(
            'test-data/deploy-ve/requirements.txt'))
Exemplo n.º 2
0
    def deploy_ve(self):
        log = logging.getLogger(__name__)
        ve_hash = ve_version(sha224sum(self.deploy_path('requirements.txt')))
        ve_working = os.path.join(self.root, 'virtualenvs', 'unpack')
        ve_dir = os.path.join(self.root, 'virtualenvs', ve_hash)
        tarball = os.path.join(ve_working, 'virtualenv.tar.gz')
        ve_unpack_root = os.path.join(ve_working, 'virtualenv')

        if not os.path.exists(ve_dir):
            log.debug('Deploying virtualenv %s', ve_hash)

            if not os.path.exists(ve_working):
                os.makedirs(ve_working)
            download_ve(self.repository, self.app, ve_hash, self.target,
                        dest=tarball)
            extract_tar(tarball, ve_unpack_root)
            os.rename(ve_unpack_root, ve_dir)

        ve_symlink = self.deploy_path('virtualenv')
        if not os.path.exists(ve_symlink):
            os.symlink(os.path.join('..', '..', 'virtualenvs', ve_hash),
                       ve_symlink)