always use print_function
[bootmanager.git] / source / steps / ConfirmInstallWithUser.py
1 #!/usr/bin/python
2 #
3 # Copyright (c) 2003 Intel Corporation
4 # All rights reserved.
5 #
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
7 # All rights reserved.
8
9 from __future__ import print_function
10
11 from Exceptions import *
12
13 welcome_message= \
14 """
15 ********************************************************************************
16 *                                                                              *
17 *                             Welcome to PlanetLab                             *
18 *                             ~~~~~~~~~~~~~~~~~~~~                             *
19 *                                                                              *
20 * The PlanetLab boot CD allows you to automatically install this machine as a  *
21 * node within the PlanetLab overlay network.                                   *
22 *                                                                              *
23 * PlanetLab is a global overlay network for developing and accessing new       *
24 * network services. Our goal is to grow to 1000 geographically distributed     *
25 * nodes, connected by a diverse collection of links. Toward this end, we are   *
26 * putting PlanetLab nodes into edge sites, co-location and routing centers,    *
27 * and homes (i.e., at the end of DSL lines and cable modems). PlanetLab is     *
28 * designed to support both short-term experiments and long-running services.   *
29 * Currently running services include network weather maps, network-embedded    *
30 * storage, peer-to-peer networks, and content distribution networks.           *
31 *                                                                              *
32 * Information on joining PlanetLab available at planet-lab.org/consortium/     *
33 *                                                                              *
34 ********************************************************************************
35
36 WARNING : Installing PlanetLab will remove any existing operating system and 
37           data from this computer.
38 """
39
40
41 def Run(vars, log):
42     """
43     Ask the user if we really want to wipe this machine.
44
45     Return 1 if the user accept, 0 if the user denied, and
46     a BootManagerException if anything unexpected occurred.
47     """
48
49     log.write("\n\nStep: Confirming install with user.\n")
50     
51     try:
52         confirmation = ""
53         install = 0
54         print(welcome_message)
55         
56         while confirmation not in ("yes","no"):
57             confirmation = \
58                 raw_input("Are you sure you wish to continue (yes/no): ")
59         install = confirmation=="yes"
60     except EOFError as e:
61         pass
62     except KeyboardInterrupt as e:
63         pass
64     
65     if install:
66         log.write("\nUser accepted install.\n")
67     else:
68         log.write("\nUser canceled install.\n")
69         
70     return install