def open(self, url): repo = Repository(url) # To test the repository's existence call get_ids_for_all_tests() # if it raises an OperationalError that means the DB doesn't exist or # it couldn't connect, either way the repository was not found. try: session = repo.session_factory() db_api.get_ids_for_all_tests(session=session) session.close() except sqlalchemy.exc.OperationalError: raise repository.RepositoryNotFound(url) return repo
def open(self, url): path = os.path.expanduser(url) base = os.path.join(path, '.stestr') try: stream = open(os.path.join(base, 'format'), 'rt') except (IOError, OSError) as e: if e.errno == errno.ENOENT: raise repository.RepositoryNotFound(url) raise if '1\n' != stream.read(): raise ValueError(url) return Repository(base)
def open(self, url): try: return self.repos[url] except KeyError: raise repository.RepositoryNotFound(url)