Package pyanaconda :: Module cmdline
[hide private]
[frames] | no frames]

Source Code for Module pyanaconda.cmdline

  1  # 
  2  # cmdline.py - non-interactive, very very simple frontend to anaconda 
  3  # 
  4  # Copyright (C) 2003, 2004, 2005, 2006, 2007  Red Hat, Inc. 
  5  # All rights reserved. 
  6  # 
  7  # This program is free software; you can redistribute it and/or modify 
  8  # it under the terms of the GNU General Public License as published by 
  9  # the Free Software Foundation; either version 2 of the License, or 
 10  # (at your option) any later version. 
 11  # 
 12  # This program is distributed in the hope that it will be useful, 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 15  # GNU General Public License for more details. 
 16  # 
 17  # You should have received a copy of the GNU General Public License 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 19  # 
 20  # Author(s): Jeremy Katz <katzj@redhat.com 
 21  # 
 22   
 23  import time 
 24  import signal 
 25  import parted 
 26  from constants import * 
 27  from flags import flags 
 28  from iutil import strip_markup 
 29  from installinterfacebase import InstallInterfaceBase 
 30   
 31  import gettext 
 32  _ = lambda x: gettext.ldgettext("anaconda", x) 
 33   
 34  import logging 
 35  log = logging.getLogger("anaconda") 
 36   
 37   
38 -def setupProgressDisplay(anaconda):
39 if anaconda.dir == DISPATCH_BACK: 40 anaconda.intf.setInstallProgressClass(None) 41 return DISPATCH_BACK 42 else: 43 anaconda.intf.setInstallProgressClass(progressDisplay()) 44 45 return DISPATCH_FORWARD
46 47 stepToClasses = { "install" : setupProgressDisplay } 48
49 -class WaitWindow:
50 - def pop(self):
51 pass
52 - def refresh(self):
53 pass
54 - def __init__(self, title, text):
55 print(text)
56
57 -class ProgressWindow:
58 - def pop(self):
59 print("")
60
61 - def pulse(self):
62 pass
63
64 - def set(self, amount):
65 if amount == self.total: 66 print(_("Completed"))
67
68 - def refresh(self):
69 pass
70
71 - def __init__(self, title, text, total, updpct = 0.05, pulse = False):
72 self.total = total 73 print(text) 74 print(_("In progress"))
75
76 -class InstallInterface(InstallInterfaceBase):
77 - def __init__(self):
78 InstallInterfaceBase.__init__(self) 79 # signal.signal(signal.SIGINT, signal.SIG_IGN) 80 signal.signal(signal.SIGTSTP, signal.SIG_DFL) 81 self.instProgress = None
82
83 - def __del__(self):
84 pass
85
86 - def reinitializeWindow(self, title, path, size, description):
87 errtxt = _("(%s)\nCommand line mode requires all choices to be specified in a " 88 "kickstart configuration file." % (title,)) 89 raise RuntimeError(errtxt)
90
91 - def shutdown(self):
92 pass
93
94 - def suspend(self):
95 pass
96
97 - def resume(self):
98 pass
99
100 - def progressWindow(self, title, text, total, updpct = 0.05, pulse = False):
101 return ProgressWindow(title, text, total, updpct, pulse)
102
103 - def kickstartErrorWindow(self, text):
104 errtxt = _("The following error was found while parsing the " 105 "kickstart configuration file:\n\n%s") % (text,) 106 raise RuntimeError(errtxt)
107
108 - def messageWindow(self, title, text, type="ok", default = None, 109 custom_icon = None, custom_buttons = []):
110 if type == "ok": 111 print(text) 112 else: 113 errtxt = _("(%s)\n%s" % (title, text)) 114 raise RuntimeError(errtxt)
115
116 - def detailedMessageWindow(self, title, text, longText=None, type="ok", 117 default=None, custom_buttons=None, 118 custom_icon=None, expanded=False):
119 if longText: 120 text += "\n\n%s" % longText 121 122 self.messageWindow(title, text, type=type, default=default, 123 custom_buttons=custom_buttons, custom_icon=custom_icon)
124
125 - def passphraseEntryWindow(self, device):
126 errtxt = _("Can't have a question in command line mode!") 127 errtxt += "\n(passphraseEntryWindow: '%s')" % (device,) 128 raise RuntimeError(errtxt)
129
130 - def getLUKSPassphrase(self, passphrase = "", isglobal = False):
131 errtxt = _("Can't have a question in command line mode!") 132 errtxt += "\n(getLUKSPassphrase)" 133 raise RuntimeError(errtxt)
134
135 - def enableNetwork(self):
136 errtxt = "(enableNetwork)\n" 137 errtxt += _("Can't have a question in command line mode!") 138 raise RuntimeError(errtxt)
139
140 - def questionInitializeDASD(self, c, devs):
141 errtxt = "(questionInitializeDASD)\n" 142 errtxt += _("Can't have a question in command line mode!") 143 raise RuntimeError(errtxt)
144
145 - def mainExceptionWindow(self, shortText, longTextFile):
146 print(shortText)
147
148 - def waitWindow(self, title, text):
149 return WaitWindow(title, text)
150
151 - def beep(self):
152 pass
153
154 - def run(self, anaconda):
155 self.anaconda = anaconda 156 self.anaconda.dispatch.dispatch()
157
158 - def display_step(self, step):
159 if stepToClasses.has_key(step): 160 stepToClasses[step](self.anaconda) 161 else: 162 errtxt = _("In interactive step can't continue. (%s)" %(step,)) 163 raise RuntimeError(errtxt)
164
165 - def setInstallProgressClass(self, c):
166 self.instProgress = c
167
168 -class progressDisplay:
169 - def __init__(self):
170 self.pct = 0 171 self.display = ""
172
173 - def __del__(self):
174 pass
175
176 - def processEvents(self):
177 pass
178 - def setShowPercentage(self, val):
179 pass
180 - def get_fraction(self):
181 return self.pct
182 - def set_fraction(self, pct):
183 self.pct = pct
184 - def set_text(self, txt):
185 print(txt)
186 - def set_label(self, txt):
187 stripped = strip_markup(txt) 188 if stripped != self.display: 189 self.display = stripped 190 print(self.display)
191
192 -def setupProgressDisplay(anaconda):
193 if anaconda.dir == DISPATCH_BACK: 194 anaconda.intf.setInstallProgressClass(None) 195 return DISPATCH_BACK 196 else: 197 anaconda.intf.setInstallProgressClass(progressDisplay()) 198 199 return DISPATCH_FORWARD
200