summaryrefslogtreecommitdiffstats
path: root/text.py
blob: 8f96ce15c587f9b58275f8090e22400571db374a (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
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
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
from snack import *
import sys
import isys
import os
import stat
import iutil
import rpm
import time
import gettext_rh
import glob
import signal
import installclass
from translate import _, cat, N_
from log import log

from constants_text import *
from lilo_text import LiloWindow
from lilo_text import LiloAppendWindow
from lilo_text import LiloImagesWindow
from silo_text import SiloWindow
from silo_text import SiloAppendWindow
from silo_text import SiloImagesWindow
from network_text import NetworkWindow
from network_text import HostnameWindow
from userauth_text import RootPasswordWindow
from userauth_text import UsersWindow
from userauth_text import AuthConfigWindow
from partitioning_text import PartitionMethod
from partitioning_text import LoopSizeWindow
from partitioning_text import ManualPartitionWindow
from partitioning_text import AutoPartitionWindow
from partitioning_text import PartitionWindow
from partitioning_text import TurnOnSwapWindow
from partitioning_text import FormatWindow
from packages_text import PackageGroupWindow
from packages_text import IndividualPackageWindow
from packages_text import PackageDepWindow
from timezone_text import TimezoneWindow
from bootdisk_text import BootDiskWindow
from bootdisk_text import MakeBootDiskWindow
from mouse_text import MouseWindow, MouseDeviceWindow

import installclass

class LanguageWindow:
    def __call__(self, screen, todo, textInterface):
        languages = todo.language.available ()
        descriptions = languages.keys ()
        descriptions.sort ()
        current = todo.language.get ()
        for lang in descriptions:
            if languages[lang] == current:
                default = descriptions.index (lang)
            
        height = min((screen.height - 16, len(descriptions)))
        if todo.reconfigOnly:
            buttons = [_("Ok"), _("Back")]
        else:
            buttons = [_("Ok")]

        (button, choice) = \
            ListboxChoiceWindow(screen, _("Language Selection"),
			_("What language would you like to use during the "
			  "installation process?"), descriptions, 
			buttons, width = 30, default = default, scroll = 1,
                                height = height, help = "lang")

	if (button == string.lower(_("Back"))): return INSTALL_BACK

        choice = descriptions[choice]
        lang = languages [choice]
        newlangs = [lang]
	if len(lang) > 2:
            newlangs.append(lang[:2])
        cat.setlangs (newlangs)
        todo.language.set (choice)
	if not todo.serial:
	    map = todo.language.getFontMap(choice)
	    font = todo.language.getFontFile(choice)
	    if map != "None":
		if os.access("/bin/consolechars", os.X_OK):
		    iutil.execWithRedirect ("/bin/consolechars",
					["/bin/consolechars", "-f", font, "-m", map])
		else:
		    try:
			isys.loadFont(map)
		    except SystemError, (errno, msg):
			log("Could not load font %s: %s" % (font, msg))
	    elif os.access("/bin/consolechars", os.X_OK):
		# test and reconfig
		iutil.execWithRedirect ("/bin/consolechars", 
			["/bin/consolechars", "-d", "-m", "iso01"])

	textInterface.drawFrame()
	    
        return INSTALL_OK

class KeyboardWindow:
    def __call__(self, screen, todo):
	if todo.serial:
	    return INSTALL_NOOP
        keyboards = todo.keyboard.available ()
        keyboards.sort ()
        default = keyboards.index (todo.keyboard.get ())

        (button, choice) = \
            ListboxChoiceWindow(screen, _("Keyboard Selection"),
                                _("Which model keyboard is attached to this computer?"), keyboards, 
                                buttons = [_("OK"), _("Back")], width = 30, scroll = 1, height = 8,
                                default = default, help = "kybd")
        
        if button == string.lower (_("Back")):
            return INSTALL_BACK
        todo.keyboard.set (keyboards[choice])
	if not todo.serial:
            if todo.reconfigOnly:
                iutil.execWithRedirect ("/bin/loadkeys",
                                        ["/bin/loadkeys", keyboards[choice]],
					stderr = "/dev/null")
            else:
                try:
                    isys.loadKeymap(keyboards[choice])
                except SystemError, (errno, msg):
		    log("Could not install keymap %s: %s" % (keyboards[choice], msg))
        return INSTALL_OK
    
class InstallPathWindow:
    def __call__ (self, screen, todo, intf):
	from fstab import NewtFstab

        # see if kickstart specified install type
	showScreen = 1
	if (todo.instClass.installType == "install"):
            intf.steps = intf.commonSteps + intf.installSteps
            todo.upgrade = 0
	    showScreen = 0
	elif (todo.instClass.installType == "upgrade"):
            intf.steps = intf.commonSteps + intf.upgradeSteps
            todo.upgrade = 1
	    showScreen = 0

        # this is (probably) the first place todo.fstab gets created
        if not showScreen:
	    todo.fstab = NewtFstab(todo.setupFilesystems, 
                                   todo.serial, 0, 0,
                                   todo.intf.waitWindow,
                                   todo.intf.messageWindow,
                                   todo.intf.progressWindow,
                                   not todo.expert,
                                   todo.method.protectedPartitions(),
                                   todo.expert, todo.upgrade)
	    return INSTALL_NOOP

	classes = installclass.availableClasses()

	choices = []
	for (name, object, icon) in classes:
	    choices.append(_(name))
	upgradeChoice = len(choices)
	choices.append(_("Upgrade Existing Installation"))

	if (todo.upgrade):
	    default = upgradeChoice
	    orig = None
	else:
	    instClass = todo.getClass()
	    orig = None
	    i = 0
	    for (name, object, icon) in classes:
		if isinstance(instClass, object):
		    orig = i
		    break
		i = i + 1

	    if (orig):
		default = orig
	    else:
		default = 0

	(button, choice) = ListboxChoiceWindow(screen, _("Installation Type"),
			_("What type of system would you like to install?"),
			    choices, [(_("OK"), "ok"), (_("Back"), "back")],
			    width = 40, default = default, help = "installpath")

        if button == "back":
            return INSTALL_BACK

	needNewDruid = 0

	if (choice == upgradeChoice):
            intf.steps = intf.commonSteps + intf.upgradeSteps
            todo.upgrade = 1
        else:
            intf.steps = intf.commonSteps + intf.installSteps
            todo.upgrade = 0
	    if (choice != orig):
		(name, objectClass, logo) = classes[choice]
		todo.setClass(objectClass(todo.expert))
		needNewDruid = 1

	if needNewDruid or not todo.fstab:
	    todo.fstab = NewtFstab(todo.setupFilesystems, 
                                   todo.serial, 0, 0,
                                   todo.intf.waitWindow,
                                   todo.intf.messageWindow,
                                   todo.intf.progressWindow,
                                   not todo.expert,
                                   todo.method.protectedPartitions(),
                                   todo.expert, todo.upgrade)

        return INSTALL_OK

class UpgradeExamineWindow:
    def __call__ (self, dir, screen, todo):
	if dir == -1:
	    # Hack to let backing out of upgrades work properly
	    from fstab import NewtFstab
	    if todo.fstab:
		todo.fstab.turnOffSwap()
	    todo.fstab = NewtFstab(todo.setupFilesystems, 
                                   todo.serial, 0, 0,
                                   todo.intf.waitWindow,
                                   todo.intf.messageWindow,
                                   todo.intf.progressWindow,
                                   not todo.expert,
                                   todo.method.protectedPartitions(),
                                   todo.expert, 1)

	    return INSTALL_NOOP

        parts = todo.upgradeFindRoot ()

        if not parts:
            ButtonChoiceWindow(screen, _("Error"),
                               _("You don't have any Linux partitions. You "
                                 "can't upgrade this system!"),
                               [ _("Back") ], width = 50)
            return INSTALL_BACK
        
        if len (parts) > 1:
            height = min (len (parts), 12)
            if height == 12:
                scroll = 1
            else:
                scroll = 0

	    partList = []
	    for drive in parts:
		partList.append(drive)

            (button, choice) = \
                ListboxChoiceWindow(screen, _("System to Upgrade"),
                                    _("What partition holds the root partition "
                                      "of your installation?"), partList, 
                                    [ _("OK"), _("Back") ], width = 30,
                                    scroll = scroll, height = height,
				    help = "multipleroot")
            if button == string.lower (_("Back")):
                return INSTALL_BACK
            else:
                root = parts[choice]
        else:
            root = parts[0]

        todo.upgradeFindPackages (root)

class CustomizeUpgradeWindow:
    def __call__ (self, screen, todo, indiv):
        rc = ButtonChoiceWindow (screen, _("Customize Packages to Upgrade"),
                                 _("The packages you have installed, "
                                   "and any other packages which are "
                                   "needed to satisfy their "
                                   "dependencies, have been selected "
                                   "for installation. Would you like "
                                   "to customize the set of packages "
                                   "that will be upgraded?"),
                                 buttons = [ _("Yes"), _("No"), _("Back") ],
				help = "custupgrade")

        if rc == string.lower (_("Back")):
            return INSTALL_BACK

        if rc == string.lower (_("No")):
            indiv.set (0)
        else:
            indiv.set (1)

        return INSTALL_OK


class WelcomeWindow:
    def __call__(self, screen):
        rc = ButtonChoiceWindow(screen, _("Red Hat Linux"), 
                                _("Welcome to Red Hat Linux!\n\n"
                                  "This installation process is outlined in detail in the "
                                  "Official Red Hat Linux Installation Guide available from "
                                  "Red Hat Software. If you have access to this manual, you "
                                  "should read the installation section before continuing.\n\n"
                                  "If you have purchased Official Red Hat Linux, be sure to "
                                  "register your purchase through our web site, "
                                  "http://www.redhat.com/."),
                                buttons = [_("OK"), _("Back")], width = 50,
				help = "welcome")

	if rc == string.lower(_("Back")):
	    return INSTALL_BACK

        return INSTALL_OK

class ReconfigWelcomeWindow:
    def __call__(self, screen):
        rc = ButtonChoiceWindow(screen, _("Red Hat Linux"), 
                                _("Welcome to the Red Hat Linux!\n\n"
                                  "You have entered reconfiguration mode, "
                                  "which will allow you to configure "
                                  "site-specific options of your computer."
                                  "\n\n"
                                  "To exit without changing your setup "
                                  "select the ""Cancel"" button below."),
                                buttons = [_("OK"), _("Cancel")], width = 50,
				help = "reconfigwelcome")

	if rc == string.lower(_("Cancel")):
            screen.finish()
	    os._exit(0)

        return INSTALL_OK

class XConfigWindow:
    def __call__(self, screen, todo):
        #
        # if in reconfigOnly mode we query existing rpm db
        # if X not installed, just skip this step
        #
        if todo.reconfigOnly:
#            import rpm
#            db = rpm.opendb()
#            rc = db.findbyname ("XFree86")
#            if len(rc) == 0:
#                return None

#
#       for now ignore request to configure X11 in reconfig mode
#
            return None
        
        else:
            # we need to get the package list here for things like
            # workstation install - which will not have read the
            # package list yet.
            todo.getCompsList ()

            if not todo.hdList.packages.has_key('XFree86') or \
               not todo.hdList.packages['XFree86'].selected:
                return None

        todo.x.probe (probeMonitor = 0)

        if todo.x.server:
            rc = ButtonChoiceWindow (screen, _("X probe results"),
                                     todo.x.probeReport (),
                                     buttons = [ _("OK"), _("Back") ],
                                     help = 'xprobe')
        
            if rc == string.lower (_("Back")):
                return INSTALL_BACK

	    todo._cardindex = -1
            return INSTALL_OK

	if todo.serial:
	    # if doing serial installation and no card was probed,
	    # assume no card is present (typical case).
	    return INSTALL_NOOP

	# if we didn't find a server, we need the user to choose...
	carddb = todo.x.cards()
	cards = carddb.keys ()
	cards.sort ()
	cards.append (_("Unlisted Card"))

	servers = [ "Mono", "VGA16", "SVGA", "S3", "Mach32", "Mach8", "8514", "P9000", "AGX",
		    "W32", "W32", "Mach64", "I128", "S3V", "3DLabs" ]
	server = None

	rc = INSTALL_NOOP
	while rc != INSTALL_OK:
	    (rc, choice) = ListboxChoiceWindow(screen, _("Video Card Selection"),
					       _("Which video card do you have?"),
					       cards,
					       buttons = [_("OK"), _("Back")],
					       width = 70, scroll = 1,
					       height = screen.height - 14,
					       help = "videocard")
	    if rc == string.lower (_("Back")):
		return INSTALL_BACK

	    todo._cardindex = -1

	    if cards[choice] == _("Unlisted Card"):
		(rc , choice) = \
		    ListboxChoiceWindow(screen, _("X Server Selection"), _("Choose a server"),
					servers,
					buttons = [ (_("Ok"), "ok"), (_("Back"), "back") ],
					scroll = 1,
					height = screen.height - 14,
					help = "xserver")

		if (rc == "back"):
		    rc = INSTALL_BACK
		else:
		    rc = INSTALL_OK
		    server = "XF86_" + servers[choice]
	    else:
		todo._cardindex = choice
		rc = INSTALL_OK

	if server:
	    todo.x.setVidcard ( { "NAME" : "Generic " + server,
				  "SERVER" : server } )
	else:
	    card = carddb[cards[choice]]

            depth = 0
            while depth < 16 and card.has_key ("SEE"):
                card = carddb[card["SEE"]]
                depth = depth + 1

	    todo.x.setVidcard (card)
	
	return INSTALL_OK


class XconfiguratorWindow:
    def __call__ (self, screen, todo):
        if not todo.x.server: return INSTALL_NOOP

	# if serial install, we can't run it.
	if todo.serial:
	    todo.x.skip = 1
	    return INSTALL_NOOP

        # if Xconfigurator isn't installed, we can't run it.
        if not os.access (todo.instPath + '/usr/X11R6/bin/Xconfigurator',
                          os.X_OK):
            log("Could not find Xconfigurator, skipping X configuration.")
            return INSTALL_NOOP

        f = open (todo.instPath + "/tmp/SERVER", "w")
        f.write ("%s %d\n" % (todo.x.server, todo._cardindex))
        f.close ()

        screen.suspend ()
        iutil.execWithRedirect ("/usr/X11R6/bin/Xconfigurator",
                                ["xconfigurator", "--continue"],
                                root = todo.instPath)
        screen.resume ()
	todo.x.skip = 1
        return INSTALL_NOOP
        
class BeginInstallWindow:
    def __call__ (self, screen, todo):
        rc = ButtonChoiceWindow (screen, _("Installation to begin"),
                                _("A complete log of your installation will be in "
                                  "/tmp/install.log after rebooting your system. You "
                                  "may want to keep this file for later reference."),
                                buttons = [ _("OK"), _("Back") ],
				help = "begininstall")
        if rc == string.lower (_("Back")):
            return INSTALL_BACK
        return INSTALL_OK

class BeginUpgradeWindow:
    def __call__ (self, screen, todo):
        rc = ButtonChoiceWindow (screen, _("Upgrade to begin"),
                                _("A complete log of your upgrade will be in "
                                  "/tmp/upgrade.log after rebooting your system. You "
                                  "may want to keep this file for later reference."),
                                buttons = [ _("OK"), _("Back") ],
				help = "beginupgrade")
        if rc == string.lower (_("Back")):
            return INSTALL_BACK
        return INSTALL_OK

class InstallWindow:
    def __call__ (self, screen, todo):
        if todo.doInstall ():
            return INSTALL_BACK
        return INSTALL_OK

class FinishedWindow:
    def __call__ (self, screen, todo):
	rc = ButtonChoiceWindow (screen, _("Complete"), 
		 _("Congratulations, installation is complete.\n\n"
		   "Press return to reboot, and be sure to remove your "
		   "boot medium as the system reboots, or your system "
		   "will rerun the install. For information on fixes which "
		   "are available for this release of Red Hat Linux, "
		   "consult the "
		   "Errata available from http://www.redhat.com/errata.\n\n"
		   "Information on configuring and using your Red Hat "
		   "Linux system is contained in the Red Hat Linux "
		   "manuals."),
		[ _("OK") ], help = "finished")

        return INSTALL_OK


class ReconfigFinishedWindow:
    def __call__ (self, screen, todo):

        todo.writeConfiguration()
            
        rc = ButtonChoiceWindow (screen, _("Complete"), 
                                 _("Congratulations, configuration is complete.\n\n"
                                   " For information on fixes which "
                                   "are available for this release of Red Hat Linux, "
                                   "consult the "
                                   "Errata available from http://www.redhat.com.\n\n"
                                   "Information on further configuring your system is "
                                   "available "
                                   "in the post install chapter of the Official Red Hat "
                                   "Linux User's Guide."),
                                 [ _("OK") ], help = "reconfigfinished")

        return INSTALL_OK

class InstallProgressWindow:
    def completePackage(self, header):
        def formatTime(amt):
            hours = amt / 60 / 60
            amt = amt % (60 * 60)
            min = amt / 60
            amt = amt % 60
            secs = amt

            return "%01d:%02d.%02d" % (int(hours) ,int(min), int(secs))

       	self.numComplete = self.numComplete + 1
	self.sizeComplete = self.sizeComplete + header[rpm.RPMTAG_SIZE]
	self.numCompleteW.setText("%12d" % self.numComplete)
	self.sizeCompleteW.setText("%10dM" % (self.sizeComplete / (1024 * 1024)))
	self.numRemainingW.setText("%12d" % (self.numTotal - self.numComplete))
	self.sizeRemainingW.setText("%10dM" % ((self.sizeTotal - self.sizeComplete) / (1024 * 1024)))
	self.total.set(self.sizeComplete)

	elapsedTime = time.time() - self.timeStarted 
	self.timeCompleteW.setText("%12s" % formatTime(elapsedTime))
	finishTime = (float (self.sizeTotal) / self.sizeComplete) * elapsedTime;
	self.timeTotalW.setText("%12s" % formatTime(finishTime))
	remainingTime = finishTime - elapsedTime;
	self.timeRemainingW.setText("%12s" % formatTime(remainingTime))

	self.g.draw()
	self.screen.refresh()

    def setPackageScale(self, amount, total):
	self.s.set(int(((amount * 1.0)/ total) * 100))
	self.g.draw()
	self.screen.refresh()

    def setPackage(self, header):
	self.name.setText("%s-%s-%s" % (header[rpm.RPMTAG_NAME],
                                        header[rpm.RPMTAG_VERSION],
                                        header[rpm.RPMTAG_RELEASE]))
	self.size.setText("%dk" % (header[rpm.RPMTAG_SIZE] / 1024))
	summary = header[rpm.RPMTAG_SUMMARY]
	if (summary != None):
	    self.summ.setText(summary)
	else:
            self.summ.setText("(none)")

	self.g.draw()
	self.screen.refresh()

    def __init__(self, screen, total, totalSize):
	self.screen = screen
        toplevel = GridForm(self.screen, _("Package Installation"), 1, 5)
        
        name = _("Name   : ")
        size = _("Size   : ")
        sum =  _("Summary: ")
        
        width = 40 + max (len (name), len (size), len (sum))
	self.name = Label(" " * 40)
	self.size = Label(" ")
	detail = Grid(2, 2)
	detail.setField(Label(name), 0, 0, anchorLeft = 1)
	detail.setField(Label(size), 0, 1, anchorLeft = 1)
	detail.setField(self.name, 1, 0, anchorLeft = 1)
	detail.setField(self.size, 1, 1, anchorLeft = 1)
	toplevel.add(detail, 0, 0)

	summary = Grid(2, 1)
	summlabel = Label(sum)
	self.summ = Textbox(40, 2, "", wrap = 1)
	summary.setField(summlabel, 0, 0)
	summary.setField(self.summ, 1, 0)
	toplevel.add(summary, 0, 1)

	self.s = Scale (width, 100)
	toplevel.add (self.s, 0, 2, (0, 1, 0, 1))

	overall = Grid(4, 4)
	# don't ask me why, but if this spacer isn"t here then the 
        # grid code gets unhappy
	overall.setField (Label (" "), 0, 0, anchorLeft = 1)
	overall.setField (Label (_("    Packages")), 1, 0, anchorLeft = 1)
	overall.setField (Label (_("       Bytes")), 2, 0, anchorLeft = 1)
	overall.setField (Label (_("        Time")), 3, 0, anchorLeft = 1)

	overall.setField (Label (_("Total    :")), 0, 1, anchorLeft = 1)
	overall.setField (Label ("%12d" % total), 1, 1, anchorLeft = 1)
	overall.setField (Label ("%10dM" % (totalSize / (1024 * 1024))),
                          2, 1, anchorLeft = 1)
	self.timeTotalW = Label("")
	overall.setField(self.timeTotalW, 3, 1, anchorLeft = 1)

	overall.setField (Label (_("Completed:   ")), 0, 2, anchorLeft = 1)
	self.numComplete = 0
	self.numCompleteW = Label("%12d" % self.numComplete)
	overall.setField(self.numCompleteW, 1, 2, anchorLeft = 1)
	self.sizeComplete = 0
        self.sizeCompleteW = Label("%10dM" % (self.sizeComplete / (1024 * 1024)))
	overall.setField(self.sizeCompleteW, 2, 2, anchorLeft = 1)
	self.timeCompleteW = Label("")
	overall.setField(self.timeCompleteW, 3, 2, anchorLeft = 1)

	overall.setField (Label (_("Remaining:  ")), 0, 3, anchorLeft = 1)
	self.numRemainingW = Label("%12d" % total)
        self.sizeRemainingW = Label("%10dM" % (totalSize / (1024 * 1024)))
	overall.setField(self.numRemainingW, 1, 3, anchorLeft = 1)
	overall.setField(self.sizeRemainingW, 2, 3, anchorLeft = 1)
	self.timeRemainingW = Label("")
	overall.setField(self.timeRemainingW, 3, 3, anchorLeft = 1)

	toplevel.add(overall, 0, 3)

	self.numTotal = total
	self.sizeTotal = totalSize
	self.total = Scale (width, totalSize)
	toplevel.add(self.total, 0, 4, (0, 1, 0, 0))

	self.timeStarted = time.time()	
	
	toplevel.draw()
	self.g = toplevel
	screen.refresh()

    def __del__ (self):
        self.screen.popWindow ()

class WaitWindow:

    def pop(self):
	self.screen.popWindow()
	self.screen.refresh()

    def __init__(self, screen, title, text):
	self.screen = screen
	width = 40
	if (len(text) < width): width = len(text)

	t = TextboxReflowed(width, _(text))

	g = GridForm(self.screen, _(title), 1, 1)
	g.add(t, 0, 0)
	g.draw()
	self.screen.refresh()

class Flag:
    """a quick mutable boolean class"""
    def __init__(self, value = 0):
        self.flag = value

    def set(self, value):
        self.flag = value;

    def get(self):
        return self.flag


class ProgressWindow:
    def pop(self):
	self.screen.popWindow()
	self.screen.refresh()

    def set (self, amount):
        self.scale.set (amount)
	self.screen.refresh()

    def __init__(self, screen, title, text, total):
	self.screen = screen
	width = 55
	if (len(text) > width): width = len(text)

	t = TextboxReflowed(width, text)

	g = GridForm(self.screen, title, 1, 2)
	g.add(t, 0, 0, (0, 0, 0, 1), anchorLeft = 1)

        self.scale = Scale (width, total)
        g.add(self.scale, 0, 1)
                
	g.draw()
	self.screen.refresh()

class InstallInterface:

    def helpWindow(self, screen, key, firstTime = 1):
	try:
	    lang = cat.getlangs()
	    if not lang or lang[0] == "en_US":
		lang = 'C'
	    else:
		lang = lang[0]

	    fn = "/usr/share/anaconda/help/%s/s1-help-screens-%s.txt" \
			% (lang, key)
	    try:
		f = open(fn)
	    except IOError, msg:
		if firstTime:	
		    return self.helpWindow(screen, "helponhelp", firstTime = 0)
		else:
		    ButtonChoiceWindow(screen, _("Help not available"), 
				_("No help is available for this install."),
				       buttons = [ _("OK") ])
		    return None

	    l = f.readlines()
	    while not string.strip(l[0]):
		l = l[1:]
	    title = string.strip(l[0])
	    l = l[1:]
	    while not string.strip(l[0]):
		l = l[1:]
	    f.close()

	    height = 10
	    scroll = 1
	    if len(l) < height: 
		height = len(l)
		scroll = 0

	    width = len(title) + 6
	    stream = ""
	    for line in l:
		line = string.strip(line)
		stream = stream + line + "\n"
		if len(line) > width:
		    width = len(line)

	    bb = ButtonBar(screen, [ (_("OK"), "ok" ) ] )
	    t = Textbox(width, height, stream, scroll = scroll)

	    g = GridFormHelp(screen, title, "helponhelp", 1, 2)
	    g.add(t, 0, 0, padding = (0, 0, 0, 1))
	    g.add(bb, 0, 1, growx = 1)

	    g.runOnce()
	except:
	    import sys, traceback
	    (type, value, tb) = sys.exc_info()
	    from string import joinfields
	    list = traceback.format_exception (type, value, tb)
	    text = joinfields (list, "")
	    rc = self.exceptionWindow (_("Exception Occurred"), text)
	    if rc:
		import pdb
		pdb.post_mortem (tb)
	    os._exit (1)

    def progressWindow(self, title, text, total):
        return ProgressWindow (self.screen, _(title), _(text), total)

    def messageWindow(self, title, text):
	ButtonChoiceWindow(self.screen, _(title), _(text),
                           buttons = [ _("OK") ])

    def dumpWindow(self):
	rc = ButtonChoiceWindow(self.screen, _("Save Crash Dump"),
	    _("Please insert a floppy now. All contents of the disk "
	      "will be erased, so please choose your diskette carefully."),
	    [ _("OK"), _("Cancel") ])

        if rc == string.lower (_("Cancel")):
	    return 1

	return 0
    
    def exceptionWindow(self, title, text):
	ugh = _("An internal error occurred in the installation program. "
		"Please report this error to Red Hat (through the "
		"bugzilla.redhat.com web site) as soon as possible. The "
		"information on this failure may be saved to a floppy disk, "
		"and will help Red Hat in fixing the problem.\n\n")

	rc = ButtonChoiceWindow(self.screen, title, ugh + text,
                           buttons = [ _("OK"), _("Save"), _("Debug") ])
        if rc == string.lower (_("Debug")):
            return 1
	elif rc == string.lower (_("Save")):
            return 2
        return None

    def waitWindow(self, title, text):
	return WaitWindow(self.screen, title, text)

    def packageProgressWindow(self, total, totalSize):
	return InstallProgressWindow(self.screen, total, totalSize)

    def drawFrame(self):
        self.welcomeText = _("Red Hat Linux (C) 2000 Red Hat, Inc.")
        self.screen.drawRootText (0, 0, self.welcomeText)
	if (os.access("/usr/share/anaconda/help/C/s1-help-screens-lang.txt", os.R_OK)):
	    self.screen.pushHelpLine (_(" <F1> for help | <Tab> between elements | <Space> selects | <F12> next screen"))
	else:
	    self.screen.pushHelpLine (_("  <Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen"))

    def shutdown(self):
	self.screen.finish()
	self.screen = None

    def __init__(self):
        self.screen = SnackScreen()
	self.screen.helpCallback(self.helpWindow)
	self.drawFrame()
# uncomment this line to make the installer quit on <Ctrl+Z>
# handy for quick debugging.
	self.screen.suspendCallback(killSelf, self.screen)
# uncomment this line to drop into the python debugger on <Ctrl+Z>
# --VERY handy--
	#self.screen.suspendCallback(debugSelf, self.screen)
        self.individual = Flag(0)
        self.step = 0
        self.dir = 1
	signal.signal(signal.SIGINT, signal.SIG_IGN)
	signal.signal(signal.SIGTSTP, signal.SIG_IGN)

    def __del__(self):
        self.screen.finish()

    def run(self, todo, test = 0):
	if todo.serial:
	    self.screen.suspendCallback(spawnShell, self.screen)

        if todo.reconfigOnly:
            self.commonSteps = [
                [N_("Welcome"), ReconfigWelcomeWindow, 
                 (self.screen,), "reconfig" ],
                [N_("Language Selection"), LanguageWindow, 
                 (self.screen, todo, self), "language" ],
                [N_("Keyboard Selection"), KeyboardWindow, 
                 (self.screen, todo), "keyboard" ],
                [N_("Hostname Setup"), HostnameWindow, (self.screen, todo), 
                 "network"],
                [N_("Network Setup"), NetworkWindow, (self.screen, todo), 
                 "network"],
#                [N_("Mouse Configuration"), MouseWindow, (self.screen, todo),
#                 "mouse" ],
#                [N_("Mouse Configuration"), MouseDeviceWindow, (self.screen, todo),
#                 "mouse" ],
                [N_("Time Zone Setup"), TimezoneWindow, 
                 (self.screen, todo, test), "timezone" ],
                [N_("Root Password"), RootPasswordWindow, 
                 (self.screen, todo), "accounts" ],
                [N_("User Account Setup"), UsersWindow, 
                 (self.screen, todo), "accounts" ],
                [N_("Authentication"), AuthConfigWindow, (self.screen, todo),
                 "authentication" ],
#                [N_("X Configuration"), XConfigWindow, (self.screen, todo),
#                 "xconfig" ],
#                [N_("X Configuration"), XconfiguratorWindow, (self.screen, todo), 
#		    "xconfig"],
                [N_("Configuration Complete"), ReconfigFinishedWindow, (self.screen,todo),
                 "complete" ],
                ]
        else:
            self.commonSteps = [
                [N_("Language Selection"), LanguageWindow, 
                 (self.screen, todo, self), "language" ],
                [N_("Keyboard Selection"), KeyboardWindow, 
                 (self.screen, todo), "keyboard" ],
                [N_("Welcome"), WelcomeWindow, (self.screen,), "welcome" ],
                [N_("Installation Type"), InstallPathWindow, 
                 (self.screen, todo, self) ],
                ]

	if iutil.getArch() == 'sparc':
	    BootloaderAppendWindow = SiloAppendWindow
	    BootloaderWindow = SiloWindow
	    BootloaderImagesWindow = SiloImagesWindow
	    BootloaderConfiguration = _("SILO Configuration")
            BootloaderSkipName = "silo"
	else:
	    BootloaderAppendWindow = LiloAppendWindow
	    BootloaderWindow = LiloWindow
	    BootloaderImagesWindow = LiloImagesWindow
	    BootloaderConfiguration = _("LILO Configuration")
            BootloaderSkipName = "lilo"            

        self.installSteps = [
            [N_("Partition"), PartitionMethod,
		    (self.screen, todo), "partition" ],
            [N_("Manually Partition"), ManualPartitionWindow, 
		    (self.screen, todo), "partition" ],
            [N_("Automatic Partition"), AutoPartitionWindow, 
		    (self.screen, todo), "partition" ],
            [N_("Partition"), PartitionWindow, (self.screen, todo),
		    "partition" ],
            [N_("Root Filesystem Size"), LoopSizeWindow, (self.screen, todo),
		    "partition" ],
            [N_("Swap"), TurnOnSwapWindow, (self.screen, todo),
		    "partition" ],
            [N_("Filesystem Formatting"), FormatWindow, (self.screen, todo),
		    "format" ],
            [BootloaderConfiguration, BootloaderAppendWindow, 
		    (self.screen, todo), BootloaderSkipName ],
            [BootloaderConfiguration, BootloaderWindow, 
		    (self.screen, todo), BootloaderSkipName ],
	    [BootloaderConfiguration, BootloaderImagesWindow, 
		    (self.screen, todo), BootloaderSkipName ],
            [N_("Hostname Setup"), HostnameWindow, (self.screen, todo), 
		    "network"],
            [N_("Network Setup"), NetworkWindow, (self.screen, todo), 
		    "network"],
            [N_("Mouse Configuration"), MouseWindow, (self.screen, todo.mouse),
		    "mouse" ],
            [N_("Mouse Configuration"), MouseDeviceWindow, (self.screen, todo.mouse),
		    "mouse" ],
            [N_("Time Zone Setup"), TimezoneWindow, 
		    (self.screen, todo, test), "timezone" ],
            [N_("Root Password"), RootPasswordWindow, 
		    (self.screen, todo), "accounts" ],
            [N_("User Account Setup"), UsersWindow, 
		    (self.screen, todo), "accounts" ],
            [N_("Authentication"), AuthConfigWindow, (self.screen, todo),
		    "authentication" ],
            [N_("Package Groups"), PackageGroupWindow, 
		(self.screen, todo, self.individual), "package-selection" ],
            [N_("Individual Packages"), IndividualPackageWindow, 
		(self.screen, todo, self.individual), "package-selection" ],
            [N_("Package Dependencies"), PackageDepWindow, (self.screen, todo),
		"package-selection" ],
            [N_("X Configuration"), XConfigWindow, (self.screen, todo),
                "xconfig" ],
            [N_("Installation Begins"), BeginInstallWindow, 
		(self.screen, todo), "confirm-install" ],
            [N_("Install System"), InstallWindow, (self.screen, todo) ],
            [N_("Boot Disk"), BootDiskWindow, (self.screen, todo),
		"bootdisk" ],
            [N_("Boot Disk"), MakeBootDiskWindow, (self.screen, todo), "bootdisk"],
            [N_("X Configuration"), XconfiguratorWindow, (self.screen, todo), 
		    "xconfig"],
            [N_("Installation Complete"), FinishedWindow, (self.screen, todo),
		"complete" ]
            ]

	self.upgradeSteps = [
	    [_("Examine System"), UpgradeExamineWindow, (self.screen, todo)],
            [BootloaderConfiguration, BootloaderAppendWindow, 
		    (self.screen, todo), "lilo"],
            [BootloaderConfiguration, BootloaderWindow, 
		    (self.screen, todo), "lilo"],
	    [BootloaderConfiguration, BootloaderImagesWindow, 
		    (self.screen, todo), "lilo"],
	    [_("Customize Upgrade"), CustomizeUpgradeWindow, 
		    (self.screen, todo, self.individual), "custom-upgrade" ],
            [_("Individual Packages"), IndividualPackageWindow, (self.screen, todo, self.individual)],
            [N_("Upgrade Begins"), BeginUpgradeWindow, 
		(self.screen, todo), "confirm-upgrade" ],
            [_("Upgrade System"), InstallWindow, (self.screen, todo)],
            [_("Boot Disk"), BootDiskWindow, (self.screen, todo),
		"bootdisk" ],
            [_("Boot Disk"), MakeBootDiskWindow, (self.screen, todo), "bootdisk"],
            [_("Upgrade Complete"), FinishedWindow, (self.screen, todo)]
            ]

	dir = 1
        self.steps = self.commonSteps

        while self.step >= 0 and self.step < len(self.steps) and self.steps[self.step]:
	    step = self.steps[self.step]

	    rc = INSTALL_OK
	    if (len(step) == 4):
		if (todo.instClass.skipStep(step[3])):
		    rc = INSTALL_NOOP

	    if (rc != INSTALL_NOOP):
		# clear out the old root text by writing spaces in the blank
		# area on the right side of the screen
		self.screen.drawRootText (len(self.welcomeText), 0,
			     (self.screen.width - len(self.welcomeText)) * " ")
		self.screen.drawRootText (0 - len(step[0]),
					 0, _(step[0]))
		# This is *disgusting* (ewt)
		if step[1] == UpgradeExamineWindow:
		    rc = apply (step[1](), (dir,) + step[2])
		else:
		    rc = apply (step[1](), step[2])

	    if rc == INSTALL_BACK:
		dir = -1
	    elif rc == INSTALL_OK:
		dir = 1

	    self.step = self.step + dir
            if self.step < 0:
                ButtonChoiceWindow(self.screen, _("Cancelled"),
                                   _("I can't go to the previous step"
                                     " from here. You will have to try again."),
                                   buttons = [ _("OK") ])
                                   
                self.step = 0
                dir = 1
        self.screen.finish ()

def killSelf(screen):
    screen.finish()
    os._exit(0)

def debugSelf(screen):
    screen.suspend ()
    import pdb
    pdb.set_trace()
    screen.resume ()

def spawnShell(screen):
    screen.suspend ()
    print "\n\nType <exit> to return to the install program.\n"
    iutil.execWithRedirect ("/bin/sh", ["-/bin/sh"])
    time.sleep(5)
    screen.resume ()