1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
|
#!/usr/bin/python
# -*- coding: UTF-8 -*-
###########################################################################
# grubconfig.py - description #
# ------------------------------ #
# begin : Sun Dec 10 2006 #
# copyright : (C) 2006-2007 by Martin Böhm #
# email : [email protected] #
# #
###########################################################################
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
###########################################################################
import sys
import os
import os.path
from python_tqt.qt import *
from tdeui import *
from tdecore import *
from tdefile import *
import string, re
import shutil
import locale
import tempfile
programname = "Boot Loader Configuration"
version = "0.0.2"
standalone = __name__=='__main__'
if standalone:
programbase = KDialogBase
else:
programbase = TDECModule
parsable = ["default","menu","color","timeout","hiddenmenu","title","root","kernel","initrd"]
cat1 = ["default","menu","color","timeout","hiddenmenu","root","initrd"]
cat2 = ["savedefault","makeactive","chainloader"]
cat3 = ["kernel"]
class GreyListViewItem(TDEListViewItem):
def paintCell(self, p, cg, column, width, align ):
cgGrey = cg
cgGrey.setColor(TQColorGroup.Text,TQColor("grey"))
TDEListViewItem.paintCell(self, p, cgGrey, column, width, align)
cg.restore()
class BoldListViewItem(TDEListViewItem):
def paintCell(self, p, cg, column, width, align ):
p.save()
f = p.font()
f.setBold(True)
TDEListViewItem.paintCell(self, p, cg, column, width, align)
p.restore()
class GrubConfigAppClass(programbase):
def __init__(self,parent=None,name=None):
if standalone:
KDialogBase.__init__(self,KJanusWidget.Tabbed,i18n("Boot Loader Configuration"),
KDialogBase.Help|KDialogBase.Ok|KDialogBase.Close, KDialogBase.Close)
# no need to include About button yet
self.menulstlocation = "/boot/grub/menu.lst"
self.readfilename = self.menulstlocation
self.globalvars = {}
self.itemslist = []
#--- Load menu.lst using the load_menulst() method
self.load_menulst()
print self.globalvars
print self.itemslist
# - GRUB Options Tab -
if standalone:
usershbox = self.addHBoxPage(i18n("Grub Options"))
vbox = TQVBox(usershbox)
else:
vbox = TQVBox(tabcontrol)
vbox.setMargin(KDialog.marginHint())
# -- Operating Systems List & MakeDefault Button --
horizontalbox = TQHBox(vbox)
self.itemslistview = TDEListView(horizontalbox)
self.itemslistview.addColumn("")
self.itemslistview.setSorting(-1)
self.itemslistview.header().hide()
self.itemslistviewitems = []
arrowsbox = TQVBox(horizontalbox)
self.upbutton = KPushButton(i18n("Move Up"),arrowsbox)
self.connect(self.upbutton,SIGNAL("clicked()"),self.slotUpButtonClicked)
self.downbutton = KPushButton(i18n("Move Down"),arrowsbox)
self.connect(self.downbutton,SIGNAL("clicked()"),self.slotDownButtonClicked)
self.defaultbutton = KPushButton(i18n("Make Default"),vbox)
self.connect(self.defaultbutton,SIGNAL("clicked()"),self.slotSetDefaultButtonClicked)
# -- Boot Options Group Box --
bootoptionsbasebox = TQVGroupBox(vbox,"Boot Options")
bootoptionsbasebox.setTitle(i18n("Boot Options"));
bootoptionsbasevbox = TQWidget(bootoptionsbasebox)
infogrid = TQGridLayout(bootoptionsbasevbox,3,2)
infogrid.setSpacing(KDialog.spacingHint())
# --- Timeout ---
label = TQLabel(i18n("Timeout:"),bootoptionsbasevbox)
infogrid.addWidget(label,0,0)
timeoutbox = TQHBox(bootoptionsbasevbox)
timeoutbox.setSpacing(KDialog.spacingHint())
self.timeout = KIntSpinBox(timeoutbox,"Timeout")
if "timeout" in self.globalvars:
self.timeout.setValue(int(self.globalvars['timeout'][0]))
label = TQLabel(i18n("seconds"),timeoutbox)
infogrid.addWidget(timeoutbox,0,1)
infogrid.addWidget(self.timeout,0,1)
# --- Hide Menu on Boot ---
self.hidemenuonboot = TQCheckBox(i18n("Hide Menu on Boot"),bootoptionsbasevbox)
if 'hiddenmenu' in self.globalvars:
self.hidemenuonboot.setChecked(int(self.globalvars['hiddenmenu'][0]))
infogrid.addWidget(self.hidemenuonboot,1,1)
# --- Make Last OS Default ---
self.lastdefault = TQCheckBox(i18n("Make Last Operating System Default"),bootoptionsbasevbox)
infogrid.addWidget(self.lastdefault,2,1)
# -- Security Group Box --
securitybox = TQVGroupBox(vbox,"Security")
securitybox.setTitle(i18n("Security"));
securityvbox = TQWidget(securitybox)
infogrid = TQGridLayout(securityvbox,2,2)
infogrid.setSpacing(KDialog.spacingHint())
# --- Password ---
label = TQLabel(i18n("Password:"),securityvbox)
infogrid.addWidget(label,0,0)
self.userpassword = KPasswordEdit(securityvbox)
infogrid.addWidget(self.userpassword,0,1)
# --- Repeat Password ---
label = TQLabel(i18n("Repeat Password:"),securityvbox)
infogrid.addWidget(label,1,0)
self.userrepeatpassword = KPasswordEdit(securityvbox)
infogrid.addWidget(self.userrepeatpassword,1,1)
# -- Splash Screen Group Box --
splashbox = TQVGroupBox(vbox,"Splash screen")
splashbox.setTitle(i18n("Splash screen"));
# --- Background Color ---
labelandeditbox = TQHBox(splashbox)
label = TQLabel(i18n("Background Color:"),labelandeditbox)
self.backgroundcolor = TQComboBox(labelandeditbox)
# --- Highlight Color ---
labelandeditbox = TQHBox(splashbox)
label = TQLabel(i18n("Highlight Color:"),labelandeditbox)
self.highlightcolor = TQComboBox(labelandeditbox)
# - Operating Systems Tab -
if standalone:
groupsvbox = self.addVBoxPage(i18n("Operating Systems"))
vb = TQVBox(groupsvbox)
else:
groupsvbox = TQVBox(tabcontrol)
roupsvbox.setMargin(KDialog.marginHint())
vb = TQVBox(groupsvbox)
# -- Operating Systems List --
horizontalbox = TQHBox(vb)
self.oslistview = TDEListView(horizontalbox)
self.oslistview.addColumn("")
self.oslistview.addColumn("")
self.oslistview.setSorting(-1)
self.oslistview.header().hide()
self.oslistviewitems = []
self.connect(self.oslistview,SIGNAL("selectionChanged()"),self.oslistviewitemSelected)
# -- Operating Systems Details Box --
osdetailsbox = TQVGroupBox(vb,"Operating System Details")
# label = TQLabel(i18n("Security"),securitybox)
detailsvbox = TQWidget(osdetailsbox)
infogrid = TQGridLayout(detailsvbox,7,2)
infogrid.setSpacing(KDialog.spacingHint())
osdetailsbox.setTitle(i18n("Operating System Details"));
# --- List in GRUB Menu ---
self.listingrub = TQCheckBox(i18n("List in GRUB Menu"),detailsvbox)
infogrid.addWidget(self.listingrub,0,1)
# --- Display Name ---
label = TQLabel(i18n("Display Name:"),detailsvbox)
infogrid.addWidget(label,1,0)
self.displaynamelabel = TQLineEdit("",detailsvbox)
infogrid.addWidget(self.displaynamelabel,1,1)
self.connect(self.displaynamelabel,SIGNAL("textChanged(const TQString &)"),self.slotDisplayNameLabelChanged)
# --- Operating System ---
label = TQLabel(i18n("Operating System:"),detailsvbox)
infogrid.addWidget(label,2,0)
self.operatingsystem = TQComboBox(detailsvbox)
infogrid.addWidget(self.operatingsystem,2,1)
# --- Kernel ---
label = TQLabel(i18n("Kernel:"),detailsvbox)
infogrid.addWidget(label,3,0)
self.kernel = KURLRequester(detailsvbox)
infogrid.addWidget(self.kernel,3,1)
# --- Failsafe Kernel ---
# not sure if that is possible - requested by seele
label = TQLabel(i18n("Failsafe Kernel:"),detailsvbox)
infogrid.addWidget(label,4,0)
self.failsafekernel = TQComboBox(detailsvbox)
infogrid.addWidget(self.failsafekernel,4,1)
# --- Initial RAM Disk ---
label = TQLabel(i18n("Initial RAM Disk:"),detailsvbox)
infogrid.addWidget(label,5,0)
self.initrd = KURLRequester(detailsvbox)
infogrid.addWidget(self.initrd,5,1)
# --- Root Filesystem ---
label = TQLabel(i18n("Root Filesystem:"),detailsvbox)
infogrid.addWidget(label,6,0)
self.rootfilesystem = TQComboBox(detailsvbox)
infogrid.addWidget(self.rootfilesystem,6,1)
# -- Boot Options Box --
bootoptionsbox = TQVGroupBox(vb,"Boot Options")
# label = TQLabel(i18n("Security"),securitybox)
bootoptionsbox.setTitle(i18n("Boot Options"));
self.acpibox = TQCheckBox(i18n("Power Management (ACPI) "),bootoptionsbox)
self.debugbox = TQCheckBox(i18n("Debugging Messages "),bootoptionsbox)
self.selinuxbox = TQCheckBox(i18n("SELinux Support "),bootoptionsbox)
self.splashbox = TQCheckBox(i18n("Splash Screen"),bootoptionsbox)
labelandeditbox = TQHBox(bootoptionsbox)
label = TQLabel(i18n("Custom Options:"),labelandeditbox)
self.customoptions = KLineEdit("",labelandeditbox)
# -- (static) UI finished --
self.reloadListViews("oslist")
self.reloadListViews("itemslist")
try:
self.oslistview.setSelected(self.oslistviewitems[int(self.globalvars['default'][0])],True)
except ValueError:
self.oslistview.setSelected(self.oslistviewitems[0],True)
ops_list = self.load_osprobe()
print ops_list # mhb debug
#######################################################################
# reload listviews, because they have changed
def reloadListViews(self,name):
print "reloaded"
# you should repaint the one that is not changed on screen
if name == "oslist":
self.oslistview.clear()
for item in self.itemslist:
try:
if self.itemslist.index(item) == int(self.globalvars['default'][0]):
self.oslistviewitems.append(BoldListViewItem(self.oslistview,self.oslistview.lastItem(),item['title'][0]))
else:
self.oslistviewitems.append(TDEListViewItem(self.oslistview,self.oslistview.lastItem(),item['title'][0]))
except ValueError:
self.oslistviewitems.append(TDEListViewItem(self.oslistview,self.oslistview.lastItem(),item['title'][0]))
# if it has a root option (other than 1 which means only root by itself), it is an OS
else:
self.itemslistview.clear()
#repaint main list
for item in self.itemslist:
try:
if self.itemslist.index(item) == int(self.globalvars['default'][0]):
print "bam!"
self.itemslistviewitems.append(BoldListViewItem(self.itemslistview,self.itemslistview.lastItem(),item['title'][0]))
else:
self.itemslistviewitems.append(TDEListViewItem(self.itemslistview,self.itemslistview.lastItem(),item['title'][0]))
except ValueError:
self.itemslistviewitems.append(TDEListViewItem(self.itemslistview,self.itemslistview.lastItem(),item['title'][0]))
#######################################################################
def slotUser1(self):
self.aboutus.show()
#######################################################################
# def slotClose(self):
# self.close()
#######################################################################
def slotOk(self):
self.save_menulst()
# mhb TODO: catching exceptions here would be useful
self.close()
#######################################################################
def slotCheckOsClicked(self):
self.OsProbedList = self.load_osprobe()
#######################################################################
def oslistviewitemSelected(self):
# save current item changes & select another one
i = self.oslistviewitems.index(self.oslistview.selectedItem())
self.updatingGUI = True
self.displaynamelabel.setText(self.itemslist[i]["title"][0])
# visible in GRUB reload
# kernel reload
try:
self.kernel.setURL(self.itemslist[i]["kernel"][0])
except KeyError:
self.initrd.setURL("unavailable") # mhb debug
# initrd reload
try:
self.initrd.setURL(self.itemslist[i]["initrd"][0])
except KeyError:
self.initrd.setURL("unavailable") # mhb debug
# custom options reload
customoptions = ""
for word in self.itemslist[i]["kernel"][1:-1]:
customoptions += word + " "
self.customoptions.setText(customoptions[:-1])
self.updatingGUI = False
print "oslistview item selected" #mhb debug
pass
#######################################################################
def slotDisplayNameLabelChanged(self, string):
if(self.updatingGUI == False):
print "display name changed" #mhb debug
i = self.oslistviewitems.index(self.oslistview.selectedItem())
self.itemslist[i]["title"][0] = string
self.oslistview.selectedItem().setText(0,string)
self.reloadListViews("itemslist")
pass
#######################################################################
def slotUpButtonClicked(self):
print "UpButton clicked" #mhb debug
i = self.itemslistviewitems.index(self.itemslistview.selectedItem())
self.itemslistview.selectedItem().itemAbove().moveItem(self.itemslistview.selectedItem())
# itemslist should have the same i for the same option
if(i != 0):
container = self.itemslist[i]
self.itemslist[i] = self.itemslist[i-1]
self.itemslist[i-1] = container
self.reloadListViews("oslist")
return "not working yet"
#######################################################################
def slotDownButtonClicked(self):
print "DownButton clicked" #mhb debug
i = self.itemslistviewitems.index(self.itemslistview.selectedItem())
self.itemslistview.selectedItem().moveItem(self.itemslistview.selectedItem().itemBelow())
if(i != len(self.itemslist)-1):
container = self.itemslist[i]
self.itemslist[i] = self.itemslist[i+1]
self.itemslist[i+1] = container
self.reloadListViews("oslist")
return "not working yet"
#######################################################################
def slotSetDefaultButtonClicked(self):
print "SetDefaultButton cliicked" #mhb debug
try:
defaultn = int(self.globalvars["default"][0])
except ValueError:
pass
else:
container = self.itemslistviewitems[defaultn]
self.itemslistviewitems[defaultn] = TDEListViewItem(self.itemslistview,container,self.itemslist[defaultn]['title'][0])
self.itemslistview.takeItem(container)
indexn = self.itemslistviewitems.index(self.itemslistview.selectedItem())
self.globalvars["default"] = str(indexn)
self.itemslistviewitems[indexn] = BoldListViewItem(self.itemslistview,self.itemslistview.selectedItem(),self.itemslist[indexn]['title'][0])
self.itemslistview.takeItem(self.itemslistview.selectedItem())
self.reloadListViews("oslist")
return "not working yet"
#######################################################################
# loop
def exec_loop(self):
global programbase
# self.__loadOptions()
self.updatingGUI = True
#self.__updateUserList()
#self.__updateGroupList()
self.updatingGUI = False
programbase.exec_loop(self)
print "done"
#######################################################################
# loads menu.lst
# NOT YET parsing:
# fallback
# currently parsing: (type of the location number)
# default <int>
# timeout <int>
# hiddenmenu <int>
# color <int>
# password (consider an md5 sum?) <int>
# AUTOMAGIC KERNELS LIST <interval - two ints>
# GRUBCONFIG DISABLED ITEMS <interval - two ints>
# IMPORTANT note:
# any value that is not parsed MUST not be ommited at the end!
# any value that is commented (parsed or not) MUST not be omitted at the end!
# not so important note:
# if a value we parse is not defined:
# apply defaults (how do find them out?)
# but specify it in the menu.lst when saving
# mhb TODO: somehow handle automagic kernel list (target: feisty)
# mhb TODO: adapt to more distributions, find menu.lst on different locations
def load_menulst(self):
self.modifiedlines = []
menufd = open(self.menulstlocation,"r")
linenum = 0
lock = 0
itemlock = 0
currentitem = 0
for line in menufd:
# Checks if the first non-white char in a line is a #
if re.search(r'^(/s)*#',line) or re.search(r'^(/s)*$',line):
print "a commented line" # mhb debug
if itemlock == 1:
itemlock = 0
currentitem += 1
# if it is a start of an area we parse, use a lock
if re.search(r'sumthin',line) and (lock == 0):
lock = 1
elif re.search(r'sumthin_other',line) and (lock == 0):
lock = 2
# else if it is an end of an area we parse, close the lock
elif re.search(r'sumthin_other_end',line) and (lock == 2):
lock = 0
elif re.search(r'sumthin_end',line) and (lock == 1):
lock = 0
# errors
# mhb TODO: exception catching
elif re.search(r'sumthin',line) and (lock == 0):
raise IdentationError
elif re.search(r'sumthin_other',line) and (lock == 1):
raise EndOfNotOpenedError
# if it is in the lock, do the mumbo-jumbo
# find out what kind of lock it is
# AUTOCONFIG
if lock == 1:
# automagic kernels list?
if re.search(r'sumthin',line):
pass
# or the other one (grubconfig disabled kernel's list )?
else:
self.modifiedlines.append(linenum)
# else save it as a commented line (does not save the locks)
# GRUBCONFiG commented item
elif lock == 2:
# remove leading spaces and one #
# the parse as a normal menu item
pass
# it's a commented, no need to do anything
else:
pass
# okay, it's not commented
else:
print "a not commented line" # mhb debug
self.modifiedlines.append(linenum)
# we presume the first character is already a name
var_name = line.split()[0]
#print "variable name is " + var_name # mhb debug
# var_value's last item is always the line that has to be changed
var_value = []
if var_name in parsable:
# cat 0 - a title - triggers itemlock, has a name and a value, which should be stored as text
if var_name == "title":
print line.split(None,1)
var_value.append(line.split(None,1)[1][:-1])
itemlock = 1
self.itemslist.append({})
# cat 1 - has a name and 1 value
elif var_name in cat1:
try:
var_value.append(line.split()[1])
except IndexError:
var_value.append(1)
# cat 2 - has a name, but no value ( implicit 1 )
elif var_name in cat2:
var_value.append(1)
# cat 3 - has a name, has multiple values, should be saved as list
elif var_name in cat3:
var_value = line.split()[1:]
# now, append the number
var_value.append(linenum)
if itemlock == 1:
self.itemslist[currentitem][var_name] = var_value
else:
self.globalvars[var_name] = var_value
#if var_name in parsable:
#print "variable name " + var_name + " is parsable " # mhb debug
#if var_name == "title":
#itemlock = 1
#self.itemslist.append({})
#if(len(line.split()) > 1):
#var_value = line.split()[1]
#if itemlock == 1:
#else:
#print "variable value is " + var_value # mhb debug
#else:
#if itemlock == 1:
#self.itemslist[currentitem][var_name] = var_value
#else:
#self.globalvars[var_name] = 1
#else:
#print "variable name " + var_name + " is currently not parsable" # mhb debug
#print "it has no value" # mhb debug
# print "parsed another line" # mhb debug
linenum += 1;
print "load_menulst() called" # mhb debug
return "not working yet"
#######################################################################
# writes menu.lst
def save_menulst(self):
delimeter = " "
# phase 1: preparing the values
lines = []
linecontent = []
# this consists of:
# 1. concatenating the list of lines that were modified
# 2. writing the lines in another list (or something more efficient
output = {}
# the globals first
for unit, value in self.globalvars.items():
lines.append(value[-1])
temp_str=""
temp_str+=(str(unit)+" ")
for index in range(len(value)-1):
temp_str+=(str(value[index])+" ")
linecontent.append(temp_str)
# itemslist next (abattoir)
for item in self.itemslist:
for unit, value in reversed(item.items()):
lines.append(value[-1])
temp_str=""
temp_str+=(str(unit)+" ")
for index in range(len(value)-1):
temp_str+=(str(value[index])+" ")
linecontent.append(temp_str)
# phase 2: writing the file
# by now we have a list of numbers (let's call it lines[])
# and a list of mofified lines (let's call it linecontent[] )
# lines[i] corresponds with linecontent[]
trfile = open(self.readfilename, "r" )
twfilename = tempfile.mkstemp("menulst")[1]
twfile = open(twfilename,"w")
# the current solution is:
# read the menu.lst again (or rather its copy, to prevent the file being changed)
# line by line write it in the output file (to be exact, to a file in /tmp)
linenum = 0
print linecontent
print lines
# foreach file as line:
for originalline in trfile:
# if its number isn't in the location list, simply write it
if linenum in lines:
twfile.writelines(linecontent[linenum])
else:
twfile.writelines(originalline)
linenum += 1;
# if there are any more lines to be written (newly detected options)
# write them at the end (now)
# when that process works out fine do a quick rewrite to /boot/grub/menu.lst
# mhb TODO: declare self.menulstlocation
twfile.close()
shutil.move(twfilename,self.menulstlocation)
# mhb TODO: Exception handling
os.remove(self.readfilename)
print "save_menulst() called" # mhb debug
return "not working yet"
#######################################################################
# loads output from os-probe
def load_osprobe(self):
detected = os.popen('os-prober').readlines()
ops_list = []
for ops in detected:
ops = string.replace(ops,"\n","")
temp_list = ops.split(':')
partition = temp_list[0]
temp_list[0] = string.replace(temp_list[0],"/dev/","")
re_obj = re.search(r'([sh]d)([a-z])([0-9])*$',temp_list[0])
disk = ord(re_obj.group(2))%97
part = int(re_obj.group(3))-1
if re_obj == None:
re_obj = re.search(r'(fd[0-9]*)$',temp_list[0])
if re_obj:
disk = temp_list[0]
part = ""
else : re_obj = re.search(r'(part[0-9]*$', temp_list[0])
if re_obj:
disk = '/disc'
part = temp_list[0]
temp_list[0] = '('+re_obj.group(1)+str(disk)+','+str(part)+')'
if temp_list[3].lower() == "linux":
mounted = os.popen('mount | grep '+partition).readlines()
if mounted:
linux_os = os.popen('linux-boot-prober --mounted '+partition).readlines()
else:
linux_os = os.popen('linux-boot-prober '+partition).readlines()
linux_list = []
for lops in linux_os:
lops = string.replace(lops,"\n","")
temp_linux_list = lops.split(':')
linux_list.append(temp_linux_list)
temp_list.append(linux_list)
ops_list.append(temp_list)
temp_list = []
return ops_list
############################################################################
# Factory function for KControl
def create_grubconfig(parent,name):
return GrubConfigAppClass(parent, name)
##########################################################################
def MakeAboutData():
aboutdata = TDEAboutData("guidance", programname, version,
unicode(i18n("Boot Loader Configuration Tool")).encode(locale.getpreferredencoding()),
TDEAboutData.License_GPL, "Copyright (C) 2006-2007 Martin Böhm")
aboutdata.addAuthor("Martin Böhm", "Developer", "[email protected]", "http://mhb.ath.cx/")
aboutdata.addAuthor("Simon Edwards", "Developer", "[email protected]", "http://www.simonzone.com/software/")
aboutdata.addAuthor("Sebastian Kügler", "Developer", "[email protected]", "http://vizZzion.org")
return aboutdata
if standalone:
aboutdata = MakeAboutData()
TDECmdLineArgs.init(sys.argv,aboutdata)
kapp = TDEApplication()
grubconfigapp = GrubConfigAppClass()
grubconfigapp.exec_loop()
|