@@ -0,0 +1,2780 @@
+# Copyright (c) 2009, 2010 Testrepository Contributors%0A# %0A# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause%0A# license at the users choice. A copy of both licenses are available in the%0A# project source as Apache-2.0 and BSD. You may not use this file except in%0A# compliance with one of these two licences.%0A# %0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under these licenses is distributed on an %22AS IS%22 BASIS, WITHOUT%0A# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the%0A# license you chose for the specific language governing permissions and%0A# limitations under that license.%0A%0A%22%22%22Access to the Samba build farm.%22%22%22%0Aimport subunit%0Aimport urllib%0A%0Afrom testrepository.repository import (%0A    AbstractRepository,%0A    AbstractRepositoryFactory,%0A    AbstractTestRun,%0A    RepositoryNotFound,%0A    )%0A%0ABUILD_FARM_URL = %22http://build.samba.org/%22%0A%0A%0Aclass RepositoryFactory(AbstractRepositoryFactory):%0A%0A    def initialise(klass, url):%0A        %22%22%22Create a repository at url/path.%22%22%22%0A        raise NotImplementedError(klass.initialise)%0A%0A    def open(self, url):%0A        if not url.startswith(BUILD_FARM_URL):%0A            raise RepositoryNotFound(url)%0A        return Repository(url)%0A%0A%0Aclass Repository(AbstractRepository):%0A    %22%22%22Access to the subunit results on the Samba build farm.%0A    %22%22%22%0A%0A    def __init__(self, base):%0A        %22%22%22Create a repository object for the Samba build farm at base.%0A        %22%22%22%0A        self.base = base.rstrip(%22/%22)+%22/%22%0A        recent_ids_url = urllib.basejoin(self.base, %22+recent-ids%22)%0A        f = urllib.urlopen(recent_ids_url, %22r%22)%0A        try:%0A            self.recent_ids = %5Bx.rstrip(%22%5Cn%22) for x in f.readlines()%5D%0A        finally:%0A            f.close()%0A%0A    def count(self):%0A        return len(self.recent_ids)%0A%0A    def latest_id(self):%0A        if len(self.recent_ids) == 0:%0A            raise KeyError(%22No tests in repository%22)%0A        return len(self.recent_ids) - 1%0A%0A    def get_failing(self):%0A        raise NotImplementedError(self.get_failing)%0A%0A    def get_test_run(self, run_id):%0A        return _HttpRun(self.base, self.recent_ids%5Brun_id%5D)%0A%0A    def _get_inserter(self, partial):%0A        raise NotImplementedError(self._get_inserter)%0A%0A%0Aclass _HttpRun(AbstractTestRun):%0A    %22%22%22A test run that was inserted into the repository.%22%22%22%0A%0A    def __init__(self, base_url, run_id):%0A        %22%22%22Create a _HttpRun with the content subunit_content.%22%22%22%0A        self.base_url = base_url%0A        self.run_id = run_id%0A        self.url = urllib.basejoin(self.base_url,%0A            %22../../build/%25s/+subunit%22 %25 self.run_id)%0A%0A    def get_subunit_stream(self):%0A        return urllib.urlopen(self.url)%0A%0A    def get_test(self):%0A        return subunit.ProtocolTestCase(self.get_subunit_stream())%0A

Add repository backend for samba buildfarm.