[Piuparts-commits] [piuparts] 04/20: p-s: fold create_or_replace_chroot_tgz into _check_tarball
Holger Levsen
holger at moszumanska.debian.org
Sat Nov 23 20:23:34 UTC 2013
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to branch develop
in repository piuparts.
commit 540069c5549bb1c06702a56b23a9596e6160e943
Author: Andreas Beckmann <anbe at debian.org>
Date: Sat Nov 9 17:22:09 2013 +0100
p-s: fold create_or_replace_chroot_tgz into _check_tarball
Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
piuparts-slave.py | 40 ++++++++++++++++++----------------------
1 file changed, 18 insertions(+), 22 deletions(-)
diff --git a/piuparts-slave.py b/piuparts-slave.py
index bd75a83..9bd7cea 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -413,8 +413,24 @@ class Section:
oldcwd = os.getcwd()
os.chdir(self._slave_directory)
- create_or_replace_chroot_tgz(self._config, self._get_tarball(),
- self._config.get_start_distro())
+ tgz = self._get_tarball()
+ max_tgz_age = int(self._config["max-tgz-age"])
+ min_tgz_retry_delay = int(self._config["min-tgz-retry-delay"])
+ needs_update = not os.path.exists(tgz)
+ if not needs_update and max_tgz_age > 0:
+ # tgz exists and age is limited, so check age
+ now = time.time()
+ age = now - os.path.getmtime(tgz)
+ logging.info("Check-replace %s: age=%d vs. max=%d" % (tgz, age, max_tgz_age))
+ if age > max_tgz_age:
+ if os.path.exists(tgz + ".log"):
+ age = now - os.path.getmtime(tgz + ".log")
+ logging.info("Limit-replace %s: last-retry=%d vs. min=%d" % (tgz, age, min_tgz_retry_delay))
+ if age > min_tgz_retry_delay:
+ needs_update = True
+ logging.info("%s too old. Forcing re-creation" % tgz)
+ if needs_update:
+ create_chroot(self._config, tgz, self._config.get_start_distro())
os.chdir(oldcwd)
@@ -855,26 +871,6 @@ def create_chroot(config, tarball, distro):
logging.error("Tarball creation failed, see %s" % output_name)
-def create_or_replace_chroot_tgz(config, tgz, distro):
- max_tgz_age = int(config["max-tgz-age"])
- min_tgz_retry_delay = int(config["min-tgz-retry-delay"])
- needs_update = not os.path.exists(tgz)
- if not needs_update and max_tgz_age > 0:
- # tgz exists and age is limited, so check age
- now = time.time()
- age = now - os.path.getmtime(tgz)
- logging.info("Check-replace %s: age=%d vs. max=%d" % (tgz, age, max_tgz_age))
- if age > max_tgz_age:
- if os.path.exists(tgz + ".log"):
- age = now - os.path.getmtime(tgz + ".log")
- logging.info("Limit-replace %s: last-retry=%d vs. min=%d" % (tgz, age, min_tgz_retry_delay))
- if age > min_tgz_retry_delay:
- needs_update = True
- logging.info("%s too old. Forcing re-creation" % tgz)
- if needs_update:
- create_chroot(config, tgz, distro)
-
-
def create_file(filename, contents):
f = file(filename, "w")
f.write(contents)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git
More information about the Piuparts-commits
mailing list