[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.45-56-gf60418b
Andreas Beckmann
debian at abeckmann.de
Wed Jul 18 19:28:39 UTC 2012
The following commit has been merged in the develop branch:
commit 0f534c63b25ca238385e3b89a1401e1ecf8025b6
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Thu Jun 21 18:55:10 2012 +0200
p-s: use finally to chdir back
simplify control flow with try/except/else/finally
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/piuparts-slave.py b/piuparts-slave.py
index cf1829f..1d27fb0 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -338,20 +338,19 @@ class Section:
return 0
with open(os.path.join(self._slave_directory, "slave.lock"), "we") as lock:
+ oldcwd = os.getcwd()
+ os.chdir(self._slave_directory)
try:
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
logging.info("busy")
self._error_wait_until = time.time() + 900
- return 0
-
- oldcwd = os.getcwd()
- os.chdir(self._slave_directory)
-
- ret = self._run()
+ else:
+ return self._run()
+ finally:
+ os.chdir(oldcwd)
+ return 0
- os.chdir(oldcwd)
- return ret
def _run(self):
try:
--
piuparts git repository
More information about the Piuparts-commits
mailing list