summaryrefslogtreecommitdiffstats
path: root/desktop.py
blob: 4ab0caa92e7834a59554a51e8d7e6f3ec6e61d3b (plain)
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
import string
import kudzu
import iutil
import isys
from log import log

class Desktop:
#
# This class represents the default desktop to run and the default runlevel
# to start in
#

    def setDefaultDesktop(self, desktop):
        self.desktop = desktop

    def setDefaultRunLevel(self, runlevel):
        if str(runlevel) != "3" and str(runlevel) != "5":
            raise RuntimeError, "Desktop::setDefaultRunLevel() - Must specify runlevel as 3 or 5!"
        self.runlevel = runlevel

    def getDefaultDesktop(self):
        return self.desktop

    def getDefaultRunLevel(self):
        return self.runlevel

    def __init__ (self):
        self.desktop = None
        self.runlevel = 3

    def write (self, instPath):
	#
	# XXX
	#
	return

        try:
            inittab = open (instPath + '/etc/inittab', 'r')
        except IOError:
            log ("WARNING, there is no inittab, bad things will happen!")
            return
        lines = inittab.readlines ()
        inittab.close ()
        inittab = open (instPath + '/etc/inittab', 'w')        
        for line in lines:
            if len (line) > 3 and line[:3] == "id:":
                fields = string.split (line, ':')
                fields[1] = str (self.runlevel)
                line = string.join (fields, ':')
            inittab.write (line)
        inittab.close ()