summaryrefslogtreecommitdiffstats
path: root/textw/fdasd_text.py
blob: 83c89c0b52033d24e42d1f7a5dcdde04c0d51073 (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
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
#
# fdasd_text.py: allows the user to partition disks with fdasd utility
# in text mode
#
# Harald Hoyer <harald@redhat.de>
# Jeremy Katz <katzj@redhat.com>
#
# Copyright 2001-2002 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

import os
import isys
import iutil
from snack import *
from rhpl.translate import _, cat, N_
from constants_text import *
import partitioning

class fdasdPartitionWindow:
    def __call__(self, screen, diskset, partrequests, intf):
        choices = []

        fdisk_name = "fdasd"
        listboxtext = _("Choose a disk to run fdasd or dasdfmt on")
        buttons = [ (_("OK"), "done"), (_("Edit Partitions"), "edit"),
                    (_("Format DASD"), "dasdfmt"),
                    TEXT_BACK_BUTTON ]        
        drives =  diskset.driveList()        
        
        drives.sort()
        
        for drive in drives:
            choices.append("%s" %(drive))

        # close all references we had to the diskset
        diskset.closeDevices()

        button = None

        while button != "done" and button != TEXT_BACK_CHECK:
            
            (button, choice) = \
                     ListboxChoiceWindow(screen, _("Disk Setup"),
                     listboxtext, choices,
                     buttons, width = 50, help = "fdasd-s390")

            if button == "edit":
                device = choices[choice]
                
                if os.access("/sbin/fdasd", os.X_OK):
                    path = "/sbin/fdasd"
                else:
                    path = "/usr/sbin/fdasd"

                try:
                    isys.makeDevInode(device, '/tmp/' + device)
                except:
                    pass

                screen.suspend()
                rc = iutil.execWithRedirect (path, [ path, "/tmp/" + device ],
                                        ignoreTermSigs = 1)
                screen.resume()
                
                if rc:
                    intf.messageWindow( _("Error"),
                                        _("An error occurred while running %s on drive %s.") % (path, device))
                    
                try:
                    os.remove('/tmp/' + device)
                except:
                    pass

            elif button == "dasdfmt":
                device = choices[choice]

                rc = intf.messageWindow(_("Warning"),
                                        _("Running dasdfmt means the loss of \n"
                                          "ALL DATA on drive %s.\n\n"
                                          "Do you really want this?")
                                        % (device,), type = "yesno")
                if rc == 0:
                    continue
                
                diskset.dasdFmt(intf, device)

            elif button == "done" or button == TEXT_BACK_CHECK:
                diskset.refreshDevices(intf)
                partitioning.checkNoDisks(diskset, intf)            
                partrequests.setFromDisk(diskset)

                if len(diskset.disks.keys()) == 0:
                    rc = intf.messageWindow(_("No Drives Found"),
                                            _("An error has occurred - no valid devices were "
                                              "found on which to create new filesystems. "
                                              "Please check your hardware for the cause "
                                              "of this problem or use dasdfmt.\n\n"
                                              "Back to the fdasd screen?"), type = "yesno")
                    
                    if rc:
                        button = ""

                    
            
        
        if button == TEXT_BACK_CHECK:
            return INSTALL_BACK

        partitioning.checkNoDisks(diskset, intf)            
        partrequests.setFromDisk(diskset)
        
        return INSTALL_OK