Subversion Repositories HelenOS-historic

Rev

Rev 707 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 707 Rev 1652
Line 106... Line 106...
106
            if number < 0 or number >= len(choices):
106
            if number < 0 or number >= len(choices):
107
                continue
107
                continue
108
            return choices[number][0]
108
            return choices[number][0]
109
 
109
 
110
 
110
 
-
 
111
def eof_checker(fnc):
-
 
112
    def wrapper(self, *args, **kw):
-
 
113
        try:
-
 
114
            return fnc(self, *args, **kw)
-
 
115
        except EOFError:
-
 
116
            return getattr(self.bckdialog,fnc.func_name)(*args, **kw)
-
 
117
    return wrapper
-
 
118
 
111
class Dialog(NoDialog):
119
class Dialog(NoDialog):
112
    def __init__(self):
120
    def __init__(self):
113
        NoDialog.__init__(self)
121
        NoDialog.__init__(self)
114
        self.dlgcmd = os.environ.get('DIALOG','dialog')
122
        self.dlgcmd = os.environ.get('DIALOG','dialog')
115
        self.title = ''
123
        self.title = ''
116
        self.backtitle = 'HelenOS Kernel Configuration'
124
        self.backtitle = 'HelenOS Kernel Configuration'
117
       
125
       
118
        if os.system('%s --print-maxsize >/dev/null 2>&1' % self.dlgcmd) != 0:
126
        if os.system('%s --print-maxsize >/dev/null 2>&1' % self.dlgcmd) != 0:
119
            raise NotImplementedError
127
            raise NotImplementedError
-
 
128
       
-
 
129
        self.bckdialog = NoDialog()
120
 
130
 
121
    def set_title(self,text):
131
    def set_title(self,text):
122
        self.title = text
132
        self.title = text
-
 
133
        self.bckdialog.set_title(text)
123
       
134
       
124
    def calldlg(self,*args,**kw):
135
    def calldlg(self,*args,**kw):
125
        "Wrapper for calling 'dialog' program"
136
        "Wrapper for calling 'dialog' program"
126
        indesc, outdesc = os.pipe()
137
        indesc, outdesc = os.pipe()
127
        pid = os.fork()
138
        pid = os.fork()
Line 174... Line 185...
174
            res,data = self.calldlg('--yesno',text,height,width)
185
            res,data = self.calldlg('--yesno',text,height,width)
175
 
186
 
176
        if res == 0:
187
        if res == 0:
177
            return 'y'
188
            return 'y'
178
        return 'n'
189
        return 'n'
-
 
190
    yesno = eof_checker(yesno)
179
 
191
 
180
    def menu(self, text, choices, button, defopt=None):
192
    def menu(self, text, choices, button, defopt=None):
181
        self.title = 'Main menu'
193
        self.title = 'Main menu'
182
        text = text + ':'
194
        text = text + ':'
183
        width = '70'
195
        width = '70'
Line 201... Line 213...
201
            sys.exit(1)
213
            sys.exit(1)
202
        elif res:
214
        elif res:
203
            print data
215
            print data
204
            raise EOFError
216
            raise EOFError
205
        return data
217
        return data
-
 
218
    menu = eof_checker(menu)
206
   
219
   
207
    def choice(self, text, choices, defopt=None):
220
    def choice(self, text, choices, defopt=None):
208
        text = text + ':'
221
        text = text + ':'
209
        width = '50'
222
        width = '50'
210
        height = str(8 + len(choices))
223
        height = str(8 + len(choices))
Line 220... Line 233...
220
                                str(len(choices)),*args, **kw)
233
                                str(len(choices)),*args, **kw)
221
        if res:
234
        if res:
222
            print data
235
            print data
223
            raise EOFError
236
            raise EOFError
224
        return data
237
        return data
-
 
238
    choice = eof_checker(choice)
225
   
239
   
226
def read_defaults(fname,defaults):
240
def read_defaults(fname,defaults):
227
    "Read saved values from last configuration run"
241
    "Read saved values from last configuration run"
228
    f = file(fname,'r')
242
    f = file(fname,'r')
229
    for line in f:
243
    for line in f: