1 |
commit: 2437a115e29f4b92ed90354d518ea17e1bc378ac |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Oct 29 13:03:33 2020 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Oct 29 13:08:32 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=2437a115 |
7 |
|
8 |
catalyst: Factor out run_sequence() |
9 |
|
10 |
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> |
11 |
|
12 |
catalyst/base/stagebase.py | 41 +++++++++++++++++++++++------------------ |
13 |
1 file changed, 23 insertions(+), 18 deletions(-) |
14 |
|
15 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py |
16 |
index cdc5a8a9..da133bf2 100644 |
17 |
--- a/catalyst/base/stagebase.py |
18 |
+++ b/catalyst/base/stagebase.py |
19 |
@@ -1349,6 +1349,22 @@ class StageBase(TargetBase, ClearBase, GenBase): |
20 |
|
21 |
log.debug('setup_environment(); env = %r', self.env) |
22 |
|
23 |
+ def run_sequence(self, sequence): |
24 |
+ for func in sequence: |
25 |
+ log.notice('--- Running action sequence: %s', func) |
26 |
+ sys.stdout.flush() |
27 |
+ try: |
28 |
+ getattr(self, func)() |
29 |
+ except LockInUse: |
30 |
+ log.error('Unable to aquire the lock...') |
31 |
+ return False |
32 |
+ except Exception: |
33 |
+ log.error('Exception running action sequence %s', |
34 |
+ func, exc_info=True) |
35 |
+ return False |
36 |
+ |
37 |
+ return True |
38 |
+ |
39 |
def run(self): |
40 |
self.chroot_lock.write_lock() |
41 |
|
42 |
@@ -1373,26 +1389,15 @@ class StageBase(TargetBase, ClearBase, GenBase): |
43 |
log.info('StageBase: run() purge') |
44 |
self.purge() |
45 |
|
46 |
- failure = False |
47 |
- for x in self.prepare_sequence + self.build_sequence + self.finish_sequence: |
48 |
- log.notice('--- Running action sequence: %s', x) |
49 |
- sys.stdout.flush() |
50 |
- try: |
51 |
- getattr(self, x)() |
52 |
- except LockInUse: |
53 |
- log.error('Unable to aquire the lock...') |
54 |
- failure = True |
55 |
- break |
56 |
- except Exception: |
57 |
- log.error('Exception running action sequence %s', |
58 |
- x, exc_info=True) |
59 |
- failure = True |
60 |
- break |
61 |
+ if not self.run_sequence(self.prepare_sequence): |
62 |
+ return False |
63 |
|
64 |
- if failure: |
65 |
- log.notice('Cleaning up... Running unbind()') |
66 |
- self.unbind() |
67 |
+ if not self.run_sequence(self.build_sequence): |
68 |
return False |
69 |
+ |
70 |
+ if not self.run_sequence(self.finish_sequence): |
71 |
+ return False |
72 |
+ |
73 |
return True |
74 |
|
75 |
def unmerge(self): |