launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04465
[Merge] lp:~julian-edwards/launchpad/job_reprs into lp:launchpad
Julian Edwards has proposed merging lp:~julian-edwards/launchpad/job_reprs into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~julian-edwards/launchpad/job_reprs/+merge/70190
Simple branch to add a __repr__ for a couple of job objects that really benefit from the extra data in the log.
The IDS one is a bit clunky as there's a lot of data but the format is not that important, as long as the data is visible in the log.
And we all know how important Soyuz logs are :)
--
https://code.launchpad.net/~julian-edwards/launchpad/job_reprs/+merge/70190
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~julian-edwards/launchpad/job_reprs into lp:launchpad.
=== modified file 'lib/lp/soyuz/model/distroseriesdifferencejob.py'
--- lib/lp/soyuz/model/distroseriesdifferencejob.py 2011-07-27 10:34:53 +0000
+++ lib/lp/soyuz/model/distroseriesdifferencejob.py 2011-08-02 16:33:33 +0000
@@ -255,6 +255,18 @@
jobs_by_dsd.setdefault(dsd, []).append(cls(job))
return jobs_by_dsd
+ def __repr__(self):
+ """Returns an informative representation of the job."""
+ parts = "%s for " % self.__class__.__name__
+ name = self.sourcepackagename
+ if not name:
+ parts += "no package name (!)"
+ else:
+ parts += "package %s" % name
+ parts += " from %s to %s" % (self.parent_series.name,
+ self.derived_series.name)
+ return "<%s>" % parts
+
@property
def sourcepackagename(self):
return SourcePackageName.get(self.metadata['sourcepackagename'])
=== modified file 'lib/lp/soyuz/model/initializedistroseriesjob.py'
--- lib/lp/soyuz/model/initializedistroseriesjob.py 2011-07-06 13:48:52 +0000
+++ lib/lp/soyuz/model/initializedistroseriesjob.py 2011-08-02 16:33:33 +0000
@@ -16,6 +16,7 @@
IMasterStore,
IStore,
)
+from lp.registry.model.distroseries import DistroSeries
from lp.services.job.interfaces.job import JobStatus
from lp.services.job.model.job import Job
from lp.soyuz.interfaces.distributionjob import (
@@ -29,6 +30,7 @@
DistributionJob,
DistributionJobDerived,
)
+from lp.soyuz.model.packageset import Packageset
from lp.soyuz.scripts.initialize_distroseries import InitializeDistroSeries
@@ -84,6 +86,31 @@
DistributionJob.distroseries_id == distroseries.id).one()
return None if distribution_job is None else cls(distribution_job)
+ def __repr__(self):
+ """Returns an informative representation of the job."""
+ # This code assumes the job is referentially intact with good data,
+ # or it will blow up.
+ parts = "%s for" % self.__class__.__name__
+ parts += " distribution: %s" % self.distribution.name
+ parts += ", distroseries: %s" % self.distroseries.name
+ parts += ", parent[overlay?/pockets/components]: "
+ parents = []
+ for i in range(len(self.parents)):
+ series = DistroSeries.get(self.parents[i])
+ parents.append("%s[%s/%s/%s]" % (
+ series.name,
+ self.overlays[i],
+ self.overlay_pockets[i],
+ self.overlay_components[i]))
+ parts += ",".join(parents)
+ pkgsets = [
+ IStore(Packageset).get(Packageset, int(pkgsetid)).name
+ for pkgsetid in self.packagesets]
+ parts += ", architectures: %s" % (self.arches,)
+ parts += ", packagesets: %s" % pkgsets
+ parts += ", rebuild: %s" % self.rebuild
+ return "<%s>" % parts
+
@property
def parents(self):
return tuple(self.metadata['parents'])
=== modified file 'lib/lp/soyuz/tests/test_distroseriesdifferencejob.py'
--- lib/lp/soyuz/tests/test_distroseriesdifferencejob.py 2011-07-28 09:03:35 +0000
+++ lib/lp/soyuz/tests/test_distroseriesdifferencejob.py 2011-08-02 16:33:33 +0000
@@ -81,6 +81,22 @@
def test_baseline(self):
verifyObject(IDistroSeriesDifferenceJobSource, self.getJobSource())
+ def test___repr__(self):
+ dsp = self.factory.makeDistroSeriesParent()
+ package = self.factory.makeSourcePackageName()
+ jobs = self.getJobSource().createForPackagePublication(
+ dsp.derived_series, package,
+ PackagePublishingPocket.RELEASE)
+ [job] = jobs
+ self.assertEqual(
+ ("<DistroSeriesDifferenceJob for package {package.name} "
+ "from {parentseries.name} to "
+ "{derivedseries.name}>").format(
+ package=package,
+ parentseries=dsp.parent_series,
+ derivedseries=dsp.derived_series),
+ repr(job))
+
def test_make_metadata_is_consistent(self):
package = self.factory.makeSourcePackageName()
parent_series = self.factory.makeDistroSeries()
=== modified file 'lib/lp/soyuz/tests/test_initializedistroseriesjob.py'
--- lib/lp/soyuz/tests/test_initializedistroseriesjob.py 2011-07-25 20:46:10 +0000
+++ lib/lp/soyuz/tests/test_initializedistroseriesjob.py 2011-08-02 16:33:33 +0000
@@ -62,6 +62,44 @@
queue."""
return len(self._getJobs())
+ def test___repr__(self):
+ parent1 = self.factory.makeDistroSeries()
+ parent2 = self.factory.makeDistroSeries()
+ distroseries = self.factory.makeDistroSeries()
+ packageset1 = self.factory.makePackageset()
+ packageset2 = self.factory.makePackageset()
+
+ overlays = (True, False)
+ overlay_pockets = (('Updates',), ('Release',))
+ overlay_components = (("main",), ("universe",))
+ arches = (u'i386', u'amd64')
+ packagesets = (packageset1.id, packageset2.id)
+ rebuild = False
+
+ job = self.job_source.create(
+ distroseries, [parent1.id, parent2.id], arches, packagesets,
+ rebuild, overlays, overlay_pockets, overlay_components)
+
+ expected = ("<InitializeDistroSeriesJob for "
+ "distribution: {distroseries.distribution.name}, "
+ "distroseries: {distroseries.name}, "
+ "parent[overlay?/pockets/components]: "
+ "{parent1.name}[True/[u'Updates']/[u'main']],"
+ "{parent2.name}[False/[u'Release']/[u'universe']], "
+ "architectures: (u'i386', u'amd64'), "
+ "packagesets: [u'{packageset1.name}', u'{packageset2.name}'], "
+ "rebuild: False>".format(
+ distroseries=distroseries,
+ parent1=parent1,
+ parent2=parent2,
+ packageset1=packageset1,
+ packageset2=packageset2))
+ self.assertEqual(
+ expected,
+ repr(job)
+ )
+
+
def test_create_with_existing_pending_job(self):
parent = self.factory.makeDistroSeries()
distroseries = self.factory.makeDistroSeries()