[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.45-102-g4c48ac2

Andreas Beckmann debian at abeckmann.de
Fri Aug 3 08:51:46 UTC 2012


The following commit has been merged in the develop branch:
commit bfe63264e3797471ecb0f16424b807f99c4f08ee
Author: Andreas Beckmann <debian at abeckmann.de>
Date:   Sun Jul 22 02:03:34 2012 +0200

    p-m: add "recycle" command
    
    needs to be issued before "reserve" or "status"
    
    Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

diff --git a/README.txt b/README.txt
index ef87fdb..2865296 100644
--- a/README.txt
+++ b/README.txt
@@ -327,6 +327,18 @@ The slave shall not speak until the master has spoken.
 Commands and responses in this protocol:
 
 ----
+Command: recycle
+Success: ok
+Failure: error
+----
+Slave asks master to enable logfile recycling mode. In this mode
+logfiles that have been marked for rechecking will be deleted
+and reissued in subsequent "reserve" commands. The "recycle"
+command must be issued before the first "reserve" (or "status")
+command. It will return "error" if no more logfiles are marked
+for rechecking or the command is issued too late.
+
+----
 Command: reserve
 Success: ok <packagename> <packageversion>
 Failure: error
diff --git a/debian/changelog b/debian/changelog
index abc04c3..f3f1432 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -33,6 +33,8 @@ piuparts (0.46) UNRELEASED; urgency=low
       retrying infinitely.
     - Delay loading the Packages file which is only needed for "status" and
       "reserve" commands, but not for submitting logs.
+    - Add "recycle" command to enter logfile recycling mode (needs to be
+      issued before "status" or "reserve").
   * piuparts-slave.py:
     - Fix stopping the currently running test (Ctrl-C Ctrl-C).
     - Handle master communication exceptions while sending logs or reserving
diff --git a/piuparts-master.py b/piuparts-master.py
index ee8a9d4..f364d6d 100644
--- a/piuparts-master.py
+++ b/piuparts-master.py
@@ -121,6 +121,7 @@ class Master(Protocol):
     def __init__(self, input, output, section):
         Protocol.__init__(self, input, output)
         self._commands = {
+            "recycle": self._recycle,
             "status": self._status,
             "reserve": self._reserve,
             "unreserve": self._unreserve,
@@ -129,6 +130,7 @@ class Master(Protocol):
             "untestable": self._untestable,
         }
         self._section = section
+        self._recycle_mode = False
         self._package_databases = None
         # start with a dummy _binary_db (without Packages file), sufficient
         # for submitting finished logs
@@ -142,6 +144,8 @@ class Master(Protocol):
         self._package_databases = {}
         self._load_package_database(self._section)
         self._binary_db = self._package_databases[self._section]
+        if self._recycle_mode:
+            self._binary_db.enable_recycling()
 
     def _load_package_database(self, section):
         config = Config(section=section, defaults_section="global")
@@ -174,10 +178,20 @@ class Master(Protocol):
             for name in self._binary_db.get_pkg_names_in_state(st):
                 logging.debug("%s : %s\n" % (st,name))
 
+    def _recycle(self, command, args):
+        self._check_args(0, command, args)
+        if self._binary_db.enable_recycling():
+            self._recycle_mode = True
+            self._short_response("ok")
+        else:
+            self._short_response("error")
+
     def _status(self, command, args):
         self._check_args(0, command, args)
         self._init_db()
         stats = ""
+        if self._binary_db._recycle_mode:
+            stats += "(recycle) "
         total = 0
         for state in self._binary_db.get_states():
             count = len(self._binary_db.get_pkg_names_in_state(state))

-- 
piuparts git repository



More information about the Piuparts-commits mailing list