2
# -*- coding: utf-8 -*-
3
# Copyright (C) 2012 Canonical
8
# This program is free software; you can redistribute it and/or modify it under
9
# the terms of the GNU General Public License as published by the Free Software
10
# Foundation; version 3.
12
# This program is distributed in the hope that it will be useful, but WITHOUT
13
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17
# You should have received a copy of the GNU General Public License along with
18
# this program; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26
from cupstream2distro.stack import Stack
27
from cupstream2distro.settings import TIME_BETWEEN_STACK_CHECKS
30
if __name__ == '__main__':
32
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
34
parser = argparse.ArgumentParser(description="Wait on other stacks to finish their work to exit",
35
epilog="Stack should be in a directory matching their current stack name stacks and all should have the same parent dir.")
36
args = parser.parse_args()
38
stack = Stack.get_current_stack()
39
waiting_on_stacks = stack.get_direct_depending_stacks()
41
if not waiting_on_stacks:
42
logging.info("No depending stacks were found. This steps should even not be called.")
46
for stack in waiting_on_stacks[:]: # as we modify the list, makes a copy first
47
logging.info("Waiting on {} ({})".format(stack.stack_name, stack.release))
48
if not stack.is_started():
49
logging.info("Stack {} ({}) is stopped".format(stack.stack_name, stack.release))
50
waiting_on_stacks.remove(stack)
51
if not waiting_on_stacks:
53
time.sleep(TIME_BETWEEN_STACK_CHECKS)