[Piuparts-commits] [SCM] piuparts git repository branch, master, updated. eda668423fa87898c59d1075118693714aa5a053
Andreas Beckmann
debian at abeckmann.de
Fri Dec 23 10:27:12 UTC 2011
The following commit has been merged in the master branch:
commit 8f977215f167b805fa571ceb1b1eb270e6d39b2b
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Sun Nov 27 16:51:33 2011 +0100
add a 'status' command to the master/slave protocol
* returns a string of all package states and the number of
packages in that state
* should only be used after uploading logs so that they are taken
into account when computing the package states
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/README.txt b/README.txt
index b5f1292..0c4e6fa 100644
--- a/README.txt
+++ b/README.txt
@@ -330,6 +330,14 @@ Success: ok
Slave reports that a particular package is untestable, possibly
because it insists on interacting with the user.
+----
+Command: status
+Success: ok <package-state>=<count> <package-state>=<count>...
+----
+Slave asks master to report the number of packages in all
+different states. The "status" command should only be issued
+after all "pass" and "fail" commands.
+
In all cases, if the master cannot respond with "ok" (e.g.,
because of a disk error storing a log file), it aborts and the
connection fails. The slave may only assume the command has
diff --git a/debian/changelog b/debian/changelog
index 6230693..ea89d1d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -71,10 +71,13 @@ piuparts (0.42) UNRELEASED; urgency=low
- Compute the changes in restore_selections().
- Check for settings.scriptsdir inside run_scripts().
- Consistently use chroot.relative() to build filenames inside the chroot.
+ * piuparts-master.py:
+ - Add a 'status' command that reports package counts for all states.
* piuparts-slave.py:
- Fix triggering tarball recreation.
- Check tarball age regularily.
- Log tarball creation in *.tgz.log.
+ - Request and print package counts from master.
* piuparts-report.py:
- state-*.html: Sort package lists by name.
- source/?/*.html: Sort binary packages by name.
diff --git a/piuparts-master.py b/piuparts-master.py
index ab5f843..cb50af6 100644
--- a/piuparts-master.py
+++ b/piuparts-master.py
@@ -114,6 +114,7 @@ class Master(Protocol):
def __init__(self, input, output, packages_file, known_circular_depends="", section=None):
Protocol.__init__(self, input, output)
self._commands = {
+ "status": self._status,
"reserve": self._reserve,
"unreserve": self._unreserve,
"pass": self._pass,
@@ -155,6 +156,17 @@ class Master(Protocol):
for name in self._binary_db.get_pkg_names_in_state(st):
logging.debug("%s : %s\n" % (st,name))
+ def _status(self, command, args):
+ self._check_args(0, command, args)
+ stats = ""
+ total = 0
+ for state in self._binary_db.get_states():
+ count = len(self._binary_db.get_packages_in_state(state))
+ total += count
+ stats += "%s=%d " % (state, count)
+ stats += "total=%d" % total
+ self._short_response("ok", stats)
+
def _reserve(self, command, args):
self._check_args(0, command, args)
package = self._binary_db.reserve_package()
diff --git a/piuparts-slave.py b/piuparts-slave.py
index a85b502..62be796 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -187,6 +187,15 @@ class Slave:
if line != "ok\n":
raise MasterNotOK()
+ def get_status(self):
+ self._writeline("status")
+ line = self._readline()
+ words = line.split()
+ if words and words[0] == "ok":
+ logging.info("Master status: " + " ".join(words[1:]))
+ else:
+ raise MasterIsCrazy()
+
def reserve(self):
self._writeline("reserve")
line = self._readline()
@@ -294,6 +303,7 @@ class Section:
while len(self._slave.get_reserved()) < max_reserved and self._slave.reserve():
pass
+ self._slave.get_status()
self._slave.close()
test_count = len(self._slave.get_reserved())
--
piuparts git repository
More information about the Piuparts-commits
mailing list