> +Country DNS mirrors
> +-------------------
> +
> +Country DNS mirrors are mirrors which have been assigned $CC.archive.ubuntu.com
> +or $CC.releases.ubuntu.com. These assignments are tracked in Launchpad.
> +Mirrors which are not official or do not have an HTTP URL may not be set as
> +country mirrors:
> +
> + >>> login('<email address hidden>')
> + >>> osuosl_mirror = factory.makeMirror(ubuntu_distro, "OSU Open Source Lab",
> + ... country=226,
> + ... ftp_url="ftp://ubuntu.osuosl.org/pub/ubuntu/",
> + ... official_candidate=True)
> + >>> osuosl_mirror.status = MirrorStatus.OFFICIAL
> + >>> print osuosl_mirror.http_base_url
> + None
Wrap the code at 78 characters.
> === modified file 'lib/lp/registry/interfaces/distribution.py'
> --- lib/lp/registry/interfaces/distribution.py 2010-03-24 21:59:58 +0000
> +++ lib/lp/registry/interfaces/distribution.py 2010-03-29 15:54:12 +0000
>
> @@ -321,6 +321,14 @@
> if it's not found.
> """
>
> + @operation_parameters(
> + country=copy_field(IDistributionMirror['country'], required=True),
> + mirror_type=copy_field(IDistributionMirror['content'], required=True))
> + @operation_returns_entry(IDistributionMirror)
> + @export_read_operation()
> + def getCountryMirror(country, mirror_type):
> + """Return the country DNS mirror for acountry and content type."""
> +class MirrorHasNoHTTPUrl(CannotTransitionToCountryMirror):
> + """Distribution mirror has no HTTP URL.
> +
> + Raised when a user tries to make an official mirror a country mirror,
> + however the mirror has not HTTP URL set.
> + """
The capitalisation is inconsistent: MirrorHasNoHTTPURL.
Hi Jonathan.
I have some trivial suggestions to improve this branch. I think the implementation
is good and ready to land.
I can land the branch at the end of this week after these changes are made.
make lint reported these problems that need fixing:
lib/lp/ registry/ interfaces/ distributionmir ror.py
339: [C0301] Line too long (83/78)
436: [W0311] Bad indentation. Found 7 spaces, expected 8
> === modified file 'lib/lp/ registry/ doc/distributio n-mirror. txt' registry/ doc/distributio n-mirror. txt 2009-12-09 10:03:20 +0000 registry/ doc/distributio n-mirror. txt 2010-03-29 15:54:12 +0000
> --- lib/lp/
> +++ lib/lp/
@@ -814,3 +814,107 @@
> +Country DNS mirrors ------- ------ ubuntu. com ubuntu. com. These assignments are tracked in Launchpad.
> +------
> +
> +Country DNS mirrors are mirrors which have been assigned $CC.archive.
> +or $CC.releases.
Wrap the narrative at 78 characters.
> + >>> login('<email address hidden>') IDistributionSe t).getByName( 'ubuntu' ) makeMirror( ubuntu_ distro, ubuntu. mirror. tudos.de/ ubuntu/", candidate= True) archive = factory. makeMirror( ubuntu_ distro, mirror. davis.antarctic a.org/ubuntu", candidate= True) mirror. status = MirrorStatus. OFFICIAL prober_ log = factory. makeMirrorProbe Record( de_archive_ mirror)
> + >>> ubuntu_distro = getUtility(
> + >>> de_archive_mirror = factory.
> + ... "Technische Universitaet Dresden", country=82,
> + ... http_url="http://
> + ... official_
> + >>> davis_station_
> + ... "Davis Station", country=9,
> + ... http_url="http://
> + ... official_
> + >>> de_archive_
> + >>> de_archive_
> + >>> logout()
Wrap the code at 78 characters.
...
> +Mirrors which are not official or do not have an HTTP URL may not be set as makeMirror( ubuntu_ distro, "OSU Open Source Lab", osuosl. org/pub/ ubuntu/", candidate= True) mirror. status = MirrorStatus. OFFICIAL mirror. http_base_ url
> +country mirrors:
> +
> + >>> login('<email address hidden>')
> + >>> osuosl_mirror = factory.
> + ... country=226,
> + ... ftp_url="ftp://ubuntu.
> + ... official_
> + >>> osuosl_
> + >>> print osuosl_
> + None
Wrap the code at 78 characters.
> === modified file 'lib/lp/ registry/ interfaces/ distribution. py' registry/ interfaces/ distribution. py 2010-03-24 21:59:58 +0000 registry/ interfaces/ distribution. py 2010-03-29 15:54:12 +0000 parameters( copy_field( IDistributionMi rror['country' ], required=True), type=copy_ field(IDistribu tionMirror[ 'content' ], required=True)) returns_ entry(IDistribu tionMirror) read_operation( ) r(country, mirror_type):
> --- lib/lp/
> +++ lib/lp/
>
> @@ -321,6 +321,14 @@
> if it's not found.
> """
>
> + @operation_
> + country=
> + mirror_
> + @operation_
> + @export_
> + def getCountryMirro
> + """Return the country DNS mirror for acountry and content type."""
grammar: s/acountry/a country/
> === modified file 'lib/lp/ registry/ interfaces/ distributionmir ror.py' registry/ interfaces/ distributionmir ror.py 2010-02-22 15:50:06 +0000 registry/ interfaces/ distributionmir ror.py 2010-03-29 15:54:12 +0000
> --- lib/lp/
> +++ lib/lp/
> @@ -6,21 +6,24 @@
> __metaclass__ = type
__all__ = [
...
> + 'CannotTransiti onToCountryMirr or', lreadySet' , irror', rchSeries' , eriesSource' , cord', irrorSet' , DistroSeries' , PUrl', ial', DImageFileList'
> + 'CountryMirrorA
> + 'IDistributionM
> + 'IMirrorDistroA
> + 'IMirrorDistroS
> + 'IMirrorProbeRe
> + 'IDistributionM
> + 'IMirrorCDImage
> + 'PROBE_INTERVAL',
> + 'MirrorContent',
> + 'MirrorFreshness',
> + 'MirrorHasNoHTT
> + 'MirrorNotOffic
> + 'MirrorNotProbed',
> + 'MirrorSpeed',
> + 'MirrorStatus',
> + 'UnableToFetchC
This is missing the PEP 8 trailing comma.
...
> +class MirrorHasNoHTTP Url(CannotTrans itionToCountryM irror):
> + """Distribution mirror has no HTTP URL.
> +
> + Raised when a user tries to make an official mirror a country mirror,
> + however the mirror has not HTTP URL set.
> + """
The capitalisation is inconsistent: MirrorHasNoHTTPURL.
> === modified file 'lib/lp/ registry/ stories/ webservice/ xx-distribution .txt' registry/ stories/ webservice/ xx-distribution .txt 2010-02-23 17:36:27 +0000 registry/ stories/ webservice/ xx-distribution .txt 2010-03-29 15:54:12 +0000
> --- lib/lp/
> +++ lib/lp/
...
> +For "getCountryMirror", the mirror_type parameter must be "Archive" or mirror_ archive = webservice. named_get( 'self_link' ], 'getCountryMirror', uk['self_ link'], type="Bogus" ) mirror_ archive. jsonBody( )
> +"CD Images":
> +
> + >>> uk_country_
> + ... ubuntu[
> + ... country=
> + ... mirror_
> + >>> print uk_country_
> + Traceback (most recent call last):
> + ...
> + ValueError: mirror_type: Invalid value "Bogus". Acceptable values are: Archive, CD Image
Wrap the code at 78 characters.
> === modified file 'lib/lp/ testing/ factory. py' testing/ factory. py 2010-03-25 02:21:15 +0000 testing/ factory. py 2010-03-29 15:54:12 +0000 gList(team, owner) Record( self, mirror): write(" Fake probe, nothing useful here.") ILibraryFileAli asSet). create( log_file. getvalue( )), 'text/plain' ) newProbeRecord( library_ alias)
> --- lib/lp/
> +++ lib/lp/
> @@ -1981,8 +1981,22 @@
> team_list = self.makeMailin
> return team, team_list
>
> + def makeMirrorProbe
> + """Create a probe record for a mirror of a distribution."""
> + log_file = StringIO()
> + log_file.
> + log_file.seek(0)
> +
> + library_alias = getUtility(
> + name='foo', size=len(
> + file=log_file, contentType=
> +
> + proberecord = mirror.
> + return proberecord
lp/registry/ tests/test_ distributionmir ror.py still uses probe_record( ) I think The test can use the factory method if you
_create_
make these changes:
from lp.testing import TestCaseWithFactory nMirror( TestCaseWithFac tory):
super( TestDistributio nMirror, self).setUp() factory. makeMirrorProbe Record( mirror) factory. makeMirrorProbe Record( mirror)
...
class TestDistributio
...
def setUp():
...
self.
...
self.