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

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


The following commit has been merged in the develop branch:
commit 617e8e001904e7621f7573ef47d637e7ef2d7836
Author: Andreas Beckmann <debian at abeckmann.de>
Date:   Sun Jul 22 13:28:22 2012 +0200

    p-m: remember idle mode by creating stamp files
    
    distinguish between "regular" idle and "recycle" idle
    
    Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

diff --git a/debian/changelog b/debian/changelog
index 2b3d146..ea4cddf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -39,6 +39,7 @@ piuparts (0.46) UNRELEASED; urgency=low
       "reserve" commands, but not for submitting logs.
     - Add "recycle" command to enter logfile recycling mode (needs to be
       issued before "status" or "reserve").
+    - Remember idle state by creating stamp files.
   * 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 f364d6d..c4257d6 100644
--- a/piuparts-master.py
+++ b/piuparts-master.py
@@ -131,6 +131,8 @@ class Master(Protocol):
         }
         self._section = section
         self._recycle_mode = False
+        self._idle_mode = None
+        self._idle_stamp = os.path.join(section, "idle.stamp")
         self._package_databases = None
         # start with a dummy _binary_db (without Packages file), sufficient
         # for submitting finished logs
@@ -157,6 +159,19 @@ class Master(Protocol):
         db.read_packages_file(packages_file)
         packages_file.close()
 
+    def _clear_idle(self):
+        if not self._idle_mode is False:
+            self._idle_mode = False
+            if os.path.exists(self._idle_stamp):
+                os.unlink(self._idle_stamp)
+
+    def _set_idle(self):
+        if not self._idle_mode is True:
+            self._idle_mode = True
+            open(self._idle_stamp, "w").close()
+            os.utime(self._idle_stamp, (-1, self._binary_db._stamp))
+
+
     def do_transaction(self):
         line = self._readline()
         if line:
@@ -181,6 +196,7 @@ class Master(Protocol):
     def _recycle(self, command, args):
         self._check_args(0, command, args)
         if self._binary_db.enable_recycling():
+            self._idle_stamp = os.path.join(self._section, "recycle.stamp")
             self._recycle_mode = True
             self._short_response("ok")
         else:
@@ -205,8 +221,10 @@ class Master(Protocol):
         self._init_db()
         package = self._binary_db.reserve_package()
         if package is None:
+            self._set_idle()
             self._short_response("error")
         else:
+            self._clear_idle()
             self._short_response("ok",
                                  package["Package"],
                                  package["Version"])

-- 
piuparts git repository



More information about the Piuparts-commits mailing list