!C99Shell v. 1.0 pre-release build #16!

Software: Apache/2.0.54 (Fedora). PHP/5.0.4 

uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 

uid=48(apache) gid=48(apache) groups=48(apache)
context=system_u:system_r:httpd_sys_script_t
 

Safe-mode: OFF (not secure)

/usr/bin/X11/./../../share/rhn/up2date_client/   drwxr-xr-x
Free 5.47 GB of 27.03 GB (20.22%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     tui.py (39.78 KB)      -rwxr-xr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/usr/bin/python
#
# TUI for RHN Registration
# Copyright (c) 2000-2002 Red Hat, Inc.
#
# Author:
#       Adrian Likins <alikins@redhat.com>
#       Preston Brown <pbrown@redhat.com>

from socket import gethostname
from os import geteuid, chdir
import sys
sys.path.insert(0, "/usr/share/rhn/")
sys.path.insert(1,"/usr/share/rhn/up2date_client")

from rhpl.translate import _, N_

import snack

import signal

sys.path.append("/usr/share/rhn/up2date")

import rhnreg, hardware
import up2dateErrors
import up2dateUtils
import rpmUtils
import rpcServer


def FatalErrorWindow(screen, errmsg):
    snack.ButtonChoiceWindow(screen, _("Fatal Error"), "%s" % errmsg,
                             [_("OK")])
    screen.finish()
    sys.exit(1)

def WarningWindow(screen, errmsg):
    snack.ButtonChoiceWindow(screen, _("Warning"), "%s" % errmsg,
                             [_("OK")])
    screen.finish()
    
class StartWindow:
    
    def __init__(self, screen, tui):
        self.name = "StartWindow"
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()
        toplevel = snack.GridForm(self.screen, _("Register with Red Hat Network"),
                                  1, 2)

        try:
            tb = snack.Textbox(size[0]-10, size[1]-14, rhnreg.welcomeText(), 1)
        except up2dateErrors.CommunicationError, e:
            FatalErrorWindow(self.screen, e.errmsg)

        toplevel.add(tb, 0, 0, padding = (0, 0, 0, 1))


        self.bb = snack.ButtonBar(self.screen,
                                  [(_("Next"), "next"),
                                   (_("Cancel"), "cancel")])
        toplevel.add(self.bb, 0, 1, growx = 1)

        self.g = toplevel

        rhnreg.getCaps()

    def saveResults(self):
        pass


    def run(self):
        result = self.g.runOnce()
        button = self.bb.buttonPressed(result)

        if result == "F12":
            return "next"
        return button
    

class PrivacyWindow:

    def __init__(self, screen, tui):
        self.name = "PrivacyWindow"
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()
        toplevel = snack.GridForm(screen, _("Step 1: Review the Red Hat Privacy Statement"),
                                  1, 2)

        try:
            tb = snack.Textbox(size[0]-10, size[1]-14, rhnreg.privacyText(), 1)
        except up2dateErrors.CommunicationError, e:
            FatalErrorWindow(screen, e.errmsg)

        toplevel.add(tb, 0, 0, padding = (0, 0, 0, 1))

        self.bb = snack.ButtonBar(screen,
                                  [(_("Next"), "next"),
                                   (_("Back"), "back"),
                                   (_("Cancel"), "cancel")])
        toplevel.add(self.bb, 0, 1, growx = 1)
        self.g = toplevel


    def saveResults(self):
        pass

    def run(self):
        self.screen.refresh()
        result = self.g.runOnce()
        button = self.bb.buttonPressed(result)

        if result == "F12":
            return "next"
        return button

class TermsAndConditionsWindow:
    def __init__(self, screen, tui):
        self.name = "TermsAndConditionsWindow"
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()
        toplevel = snack.GridForm(screen, _("Review the Red Hat Network Terms And Conditions"),
                                  1, 2)

        try:
            text = """ \n\n\n This is a sample Terms and Conditions. \n\n\n"""
            print "#FIXME"
            # text  = rhnreg.termsAndConditions()
            tb = snack.Textbox(size[0]-10, size[1]-14, text, 1)
        except up2dateErrors.CommunicationError, e:
            FatalErrorWindow(screen, e.errmsg)

        toplevel.add(tb, 0, 0, padding = (0, 0, 0, 1))

        self.bb = snack.ButtonBar(screen,
                                  [(_("Next"), "next"),
                                   (_("Back"), "back"),
                                   (_("Cancel"), "cancel")])
        toplevel.add(self.bb, 0, 1, growx = 1)
        self.g = toplevel
        
    def saveResults(self):
        pass

    def run(self):
        self.screen.refresh()
        result = self.g.runOnce()
        button = self.bb.buttonPressed(result)

        if result == "F12":
            return "next"
        return button
    
class InfoWindow:

    def __init__(self, screen, tui):
        self.name = "InfoWindow"
        self.screen = screen
        self.tui = tui
        self.tui.alreadyRegistered = 0
        
        size = snack._snack.size()
        
        toplevel = snack.GridForm(screen, _("Step 2: Register a User Account"),
                                  1, 9)
        label = snack.Label(_("Are you already registered with redhat.com?"))
        toplevel.add(label, 0, 0, anchorLeft = 1)

        label = snack.Label(_("Yes: Enter your current user name and password below."))
        toplevel.add(label, 0, 1, anchorLeft = 1)

        label = snack.Label(_("No: Choose a new user and password and enter it below."))
        toplevel.add(label, 0, 2, padding = (0, 0, 0, 1),
                     anchorLeft = 1)

        grid = snack.Grid(2, 3)
        
        label = snack.Label(_("User name:"))
        grid.setField(label, 0, 0, padding = (0, 0, 1, 0),
                      anchorRight = 1)

        self.userNameEntry = snack.Entry(20)
        self.userNameEntry.set(tui.userName)
        grid.setField(self.userNameEntry, 1, 0, anchorLeft = 1)

        label = snack.Label(_("Password:"))
        grid.setField(label, 0, 1, padding = (0, 0, 1, 0),
                      anchorRight = 1)

        try:
            self.passwordEntry = snack.Entry(20, password = 1)
        except TypeError:
            self.passwordEntry = snack.Entry(20, hidden = 1)
        self.passwordEntry.set(tui.password)
        grid.setField(self.passwordEntry, 1, 1, anchorLeft = 1)

        label = snack.Label(_("Again, for verification:"))
        grid.setField(label, 0, 2, padding = (0, 0, 1, 0),
                      anchorRight = 1)

        try:
            self.password2Entry = snack.Entry(20, password = 1)
        except TypeError:
            self.password2Entry = snack.Entry(20, hidden = 1)
        self.password2Entry.set(tui.password)
        grid.setField(self.password2Entry, 1, 2, anchorLeft = 1)
        
        toplevel.add(grid, 0, 3)

        grid = snack.Grid(2, 1)

        self.emailLabel = snack.Label(_("E-mail address:"))
        grid.setField(self.emailLabel, 0, 0, padding = (0, 1, 1, 0),
                      anchorRight = 1)

        self.emailEntry = snack.Entry(35)
        self.emailEntry.set(tui.email)
        grid.setField(self.emailEntry, 1, 0, anchorLeft = 1,
                      padding = (0, 1, 0, 0))

        toplevel.add(grid, 0, 4)


        # BUTTON BAR
        self.bb = snack.ButtonBar(screen,
                                  [(_("Next"), "next"),
                                   (_("Back"), "back"),
                                   (_("Cancel"), "cancel")])
        toplevel.add(self.bb, 0, 8, padding = (0, 1, 0, 0),
                     growx = 1)


        self.g = toplevel


    def validateFields(self):
        if self.userNameEntry.value() == "":
            snack.ButtonChoiceWindow(self.screen, _("Error"),
                                     _("You must enter a user name."),
                                     buttons = [_("OK")])
            self.g.setCurrent(self.userNameEntry)
            return 0
        if self.passwordEntry.value() == "" or self.password2Entry.value() == "":
            snack.ButtonChoiceWindow(self.screen, _("Error"),
                                     _("You must enter and verify a password."),
                                     buttons = [_("OK")])
            self.g.setCurrent(self.passwordEntry)
            return 0
        if self.passwordEntry.value() != self.password2Entry.value():
            snack.ButtonChoiceWindow(self.screen, _("Error"),
                                     _("The two passwords you entered do not match.\nPlease re-type your passwords."),
                                     buttons = [_("OK")])
            self.g.setCurrent(self.password2Entry)
            return 0
        try:
            self.tui.alreadyRegistered = rhnreg.reserveUser(self.userNameEntry.value(),
                                                            self.passwordEntry.value())
        except up2dateErrors.ValidationError, e:
            snack.ButtonChoiceWindow(self.screen, _("Error"),
                                     _("The server indicated an error:\n") + e.errmsg,
                                     buttons = [_("OK")])
            self.g.setCurrent(self.userNameEntry)
            return 0
        except up2dateErrors.CommunicationError,e:
            FatalErrorWindow(self.screen,
                             _("There was an error communicating with the registration server:\n") + e.errmsg)

        if not rhnreg.validateEmail(self.emailEntry.value()):
            snack.ButtonChoiceWindow(self.screen, _("Error"),
                                     _("You must enter a valid e-mail address."),
                                     buttons = [_("OK")])
            self.emailEntry.set("")
            self.g.setCurrent(self.emailEntry)
            return 0
        
        return 1


    def saveResults(self):
        self.tui.userName = self.userNameEntry.value()
        self.tui.password = self.passwordEntry.value()
        self.tui.email = self.emailEntry.value()
        
        
    def run(self):
        self.screen.refresh()
        valid = 0
        while not valid:
            result = self.g.run()
            button = self.bb.buttonPressed(result)

            if result == "F12":
                button = "next"

            if button == "next":
                valid = self.validateFields()
            else:
                break

        self.screen.popWindow()
        return button
    

class ProductWindow:

    def __init__(self, screen, tui):
        self.name = "ProductWindow"
        self.screen = screen
        self.tui = tui

        if tui.productInfo['reg_num'] != "":
            toplevel = snack.GridForm(screen, _("Step 2: Register a User Account (\"*\" Fields Required)"),
                                      1, 8)
        else:
            toplevel = snack.GridForm(screen, _("Step 2: Register a User Account (All Optional)"),
                                      1, 8)
            

        grid = snack.Grid(4, 4)
        
        if tui.productInfo['reg_num'] != "":
            label = snack.Label(_("*Title:"))
        else:
            label = snack.Label(_("Title:"))
        grid.setField(label, 0, 0, anchorRight = 1)

        self.titleEntry = snack.Entry(4)
        self.titleEntry.set(tui.productInfo['title'])
        grid.setField(self.titleEntry, 1, 0, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        if tui.productInfo['reg_num'] != "":
            label = snack.Label(_("*First Name:"))
        else:
            label = snack.Label(_("First Name:"))
        grid.setField(label, 0, 1, anchorRight = 1)

        self.firstNameEntry = snack.Entry(20)
        self.firstNameEntry.set(tui.productInfo['first_name'])
        grid.setField(self.firstNameEntry, 1, 1, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        if tui.productInfo['reg_num'] != "":
            label = snack.Label(_("*Last Name:"))
        else:
            label = snack.Label(_("Last Name:"))
        grid.setField(label, 2, 1, padding = (1, 0, 0, 0), anchorRight = 1)

        self.lastNameEntry = snack.Entry(25)
        self.lastNameEntry.set(tui.productInfo['last_name'])
        grid.setField(self.lastNameEntry, 3, 1, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        label = snack.Label(_("Company:"))
        grid.setField(label, 0, 2, anchorRight = 1)

        self.companyEntry = snack.Entry(20)
        self.companyEntry.set(tui.productInfo['company'])
        grid.setField(self.companyEntry, 1, 2, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        label = snack.Label(_("Position:"))
        grid.setField(label, 2, 2, padding = (1, 0, 0, 0), anchorRight = 1)

        self.positionEntry = snack.Entry(25)
        self.positionEntry.set(tui.productInfo['position'])
        grid.setField(self.positionEntry, 3, 2, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        toplevel.add(grid, 0, 0, anchorLeft = 1)

        grid = snack.Grid(2, 2)

        if tui.productInfo['reg_num'] != "":
            label = snack.Label(_("*Address:"))
        else:
            label = snack.Label(_("Address:"))
        grid.setField(label, 0, 0, anchorRight = 1)

        self.address1Entry = snack.Entry(40)
        self.address1Entry.set(tui.productInfo['address1'])
        grid.setField(self.address1Entry, 1, 0, padding = (2, 0, 0, 0),
                      anchorLeft = 1)

        label = snack.Label(_("Address 2:"))
        grid.setField(label, 0, 1, padding = (1, 0, 0, 0), anchorRight = 1)

        self.address2Entry = snack.Entry(40)
        self.address2Entry.set(tui.productInfo['address2'])
        grid.setField(self.address2Entry, 1, 1, padding = (2, 0, 0, 0),
                      anchorRight = 1)

        toplevel.add(grid, 0, 1, anchorLeft = 1)

        grid = snack.Grid(4, 3)

        if tui.productInfo['reg_num'] != "":
            label = snack.Label(_("*City:"))
        else:
            label = snack.Label(_("City:"))
        grid.setField(label, 0, 0, anchorRight = 1)

        self.cityEntry = snack.Entry(20)
        self.cityEntry.set(tui.productInfo['city'])
        grid.setField(self.cityEntry, 1, 0, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        if tui.productInfo['reg_num'] != "":
            label = snack.Label(_("*State/Prov:"))
        else:
            label = snack.Label(_("State/Prov:"))
        grid.setField(label, 2, 0, padding = (1, 0, 0, 0), anchorRight = 1)

        self.stateEntry = snack.Entry(20)
        self.stateEntry.set(tui.productInfo['state'])
        grid.setField(self.stateEntry, 3, 0, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        if tui.productInfo['reg_num'] != "":
            label = snack.Label(_("*Zip/Post Code:"))
        else:
            label = snack.Label(_("Zip/Post Code:"))
        grid.setField(label, 0, 1, anchorRight = 1)

        self.zipEntry = snack.Entry(7)
        self.zipEntry.set(tui.productInfo['zip'])
        grid.setField(self.zipEntry, 1, 1, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        if tui.productInfo['reg_num'] != "":
            label = snack.Label(_("*Country:"))
        else:
            label = snack.Label(_("Country:"))
        grid.setField(label, 2, 1, padding = (1, 0, 0, 0), anchorRight = 1)

        self.countryEntry = snack.Entry(20)
        self.countryEntry.set(tui.productInfo['country'])
        grid.setField(self.countryEntry, 3, 1, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        if tui.productInfo['reg_num'] != "":
            label = snack.Label(_("*Phone:"))
        else:
            label = snack.Label(_("Phone:"))
        grid.setField(label, 0, 2, anchorRight = 1)

        self.phoneEntry = snack.Entry(20)
        self.phoneEntry.set(tui.productInfo['phone'])
        grid.setField(self.phoneEntry, 1, 2, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        label = snack.Label(_("Fax:"))
        grid.setField(label, 2, 2, padding = (1, 0, 0, 0), anchorRight = 1)

        self.faxEntry = snack.Entry(20)
        self.faxEntry.set(tui.productInfo['fax'])
        grid.setField(self.faxEntry, 3, 2, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        toplevel.add(grid, 0, 2, anchorLeft = 1)


        label = snack.Label(_("Contact Preferences:"))
        toplevel.add(label, 0, 3, anchorLeft = 1)

        grid = snack.Grid(4, 2)

        if tui.productInfo['contact_email']:
            self.emailContactButton = snack.Checkbox(_("E-mail"), isOn = 1)
        else:
            self.emailContactButton = snack.Checkbox(_("E-mail"))
            
        if tui.email == "":
            self.emailContactButton.setFlags(snack.FLAG_DISABLED, snack.FLAGS_SET)

        grid.setField(self.emailContactButton, 0, 0, anchorLeft = 1)


        if tui.productInfo['contact_mail']:
            self.mailContactButton = snack.Checkbox(_("Regular mail"),isOn = 1)
        else:
            self.mailContactButton = snack.Checkbox(_("Regular mail"))
        grid.setField(self.mailContactButton, 1, 0, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        if tui.productInfo['contact_phone']:
            self.phoneContactButton = snack.Checkbox(_("Telephone"),isOn = 1)
        else:
            self.phoneContactButton = snack.Checkbox(_("Telephone"))
        grid.setField(self.phoneContactButton, 2, 0, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        if tui.productInfo['contact_fax']:
            self.faxContactButton = snack.Checkbox(_("Fax"), isOn = 1)
        else:
            self.faxContactButton = snack.Checkbox(_("Fax"))
        grid.setField(self.faxContactButton, 3, 0, padding = (1, 0, 0, 0),
                      anchorLeft = 1)

        toplevel.add(grid, 0, 4, anchorLeft = 1)

        if tui.productInfo['contact_special']:
            self.specialContactButton = snack.Checkbox(_("Contact me with special offers from Red Hat's partners"), isOn = 1)
        else:
            self.specialContactButton = snack.Checkbox(_("Contact me with special offers from Red Hat's partners"))
            
        if tui.email == "":
            self.specialContactButton.setFlags(snack.FLAG_DISABLED, snack.FLAGS_SET)
        toplevel.add(self.specialContactButton, 0, 5, anchorLeft = 1)

        if tui.productInfo['contact_newsletter']:
            self.newsletterContactButton = snack.Checkbox(_("Subscribe to Red Hat e-Newsletter"),isOn = 1)
        else:
            self.newsletterContactButton = snack.Checkbox(_("Subscribe to Red Hat e-Newsletter"))
        if tui.email == "":
            self.newsletterContactButton.setFlags(snack.FLAG_DISABLED, snack.FLAGS_SET)
        toplevel.add(self.newsletterContactButton, 0, 6, anchorLeft = 1)


        # BUTTON BAR
        self.bb = snack.ButtonBar(screen,
                                  [(_("Next"), "next"),
                                   (_("Back"), "back"),
                                   (_("Cancel"), "cancel")])
        toplevel.add(self.bb, 0, 7, padding = (0, 1, 0, 0),
                     growx = 1)

        self.g = toplevel


    def validateFields(self):
        if self.mailContactButton.selected() and (self.firstNameEntry.value() == "" or self.lastNameEntry.value() == "" or self.address1Entry.value() == "" or
self.cityEntry.value() == "" or self.stateEntry.value == "" or self.zipEntry.value() == ""):
            snack.ButtonChoiceWindow(self.screen, _("Error"),
                                     _("In order to receive communication by mail from Red Hat, you must fill out your full name and address."))
            return

        # validate information for phone contact
        if self.phoneContactButton.selected() and (self.phoneEntry.value() == "" or self.firstNameEntry.value() == ""):
            snack.ButtonChoiceWindow(self.screen, _("Error"),
                                     _("In order to have Red Hat contact you by phone, you must provide at least phone number and a name."))
            if self.firstNameEntry.value() == "":
                self.g.setCurrent(self.firstNameEntry)
            else:
                self.g.setCurrent(self.phoneEntry)
            return 0

        # validate information for fax contact
        if self.faxContactButton.selected() and (self.faxEntry.value() == "" or self.firstNameEntry.value() == ""):
            snack.ButtonChoiceWindow(self.screen, _("Error"),
                                     _("In order to have Red Hat contact you by fax, you must provide at least fax number and a name."))
            if self.firstNameEntry.value() == "":
                self.g.setCurrent(self.firstNameEntry)
            else:
                self.g.setCurrent(self.faxEntry)
            return 0

        return 1


    def saveResults(self):
       self.tui.productInfo['title'] = self.titleEntry.value()
        self.tui.productInfo['first_name'] = self.firstNameEntry.value()
        self.tui.productInfo['last_name'] = self.lastNameEntry.value()
        self.tui.productInfo['company'] = self.companyEntry.value()
        self.tui.productInfo['position'] = self.positionEntry.value()
        self.tui.productInfo['address1'] = self.address1Entry.value()
        self.tui.productInfo['address2'] = self.address2Entry.value()
        self.tui.productInfo['city'] = self.cityEntry.value()
        self.tui.productInfo['state'] = self.stateEntry.value()
        self.tui.productInfo['zip'] = self.zipEntry.value()
        self.tui.productInfo['country'] = self.countryEntry.value()
        self.tui.productInfo['phone'] = self.phoneEntry.value()
        self.tui.productInfo['fax'] = self.faxEntry.value()
        self.tui.productInfo['contact_email'] = self.emailContactButton.selected()
        self.tui.productInfo['contact_mail'] = self.mailContactButton.selected()
        self.tui.productInfo['contact_phone'] = self.phoneContactButton.selected()
        self.tui.productInfo['contact_fax'] = self.faxContactButton.selected()
        self.tui.productInfo['contact_special'] = self.specialContactButton.selected()
        self.tui.productInfo['contact_newsletter'] = self.newsletterContactButton.selected()


    
    def run(self):
        valid = 0
        while not valid:
            result = self.g.run()
            button = self.bb.buttonPressed(result)

            if result == "F12":
                button = "next"

            if button == "next":
                valid = self.validateFields()
            else:
                break

        self.screen.popWindow()
        return button


class HardwareWindow:

    def __init__(self, screen, tui):
        self.name = "HardwareWindow"
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()

        # read all hardware in
        tui.hardware = hardware.Hardware()
        
        toplevel = snack.GridForm(screen, _("Step 3: Register a System Profile - Hardware"),
                                  1, 8)

        text = snack.TextboxReflowed(size[0]-10, _("A Profile Name is a descriptive name that you choose to identify this System Profile on the Red Hat Network web pages. Optionally, include a computer serial or identification number."))

        toplevel.add(text, 0, 0, anchorLeft = 1)

        grid = snack.Grid(2, 2)

        label = snack.Label(_("Profile name:"))
        grid.setField(label, 0, 0, padding = (0, 0, 1, 0), anchorRight = 1)

        self.profileEntry = snack.Entry(20)
        grid.setField(self.profileEntry, 1, 0, anchorLeft = 1)

        toplevel.add(grid, 0, 1, anchorLeft = 1)
        
        if tui.includeHardware:
            self.hardwareButton = snack.Checkbox(_("Include the following information about hardware and network:"), isOn = 1)
        else:
            self.hardwareButton = snack.Checkbox(_("Include the following information about hardware and network:"))
            
        toplevel.add(self.hardwareButton, 0, 2, padding = (0, 1, 0, 1),
                     anchorLeft = 1)

        grid = snack.Grid(4, 3)

        self.versionLabel = snack.Label(_("Version:"))
        grid.setField(self.versionLabel, 0, 0, padding = (0, 0, 1, 0), anchorRight = 1)

        self.versionLabel2 = snack.Label(up2dateUtils.getVersion())
        tui.version = up2dateUtils.getVersion()
        grid.setField(self.versionLabel2, 1, 0, anchorLeft = 1)

        self.cpuLabel = snack.Label(_("CPU model:"))
        grid.setField(self.cpuLabel, 2, 0, padding = (1, 0, 1, 0), anchorRight = 1)

        for hw in tui.hardware:            
            if hw['class'] == 'CPU':
                self.cpuLabel2 = snack.Label(hw['model'])
                grid.setField(self.cpuLabel2, 3, 0, anchorLeft = 1)
                
        self.hostnameLabel = snack.Label(_("Hostname:"))
        grid.setField(self.hostnameLabel, 0, 1, padding = (0, 0, 1, 0), anchorRight = 1)

        for hw in tui.hardware:
            if hw['class'] == 'NETINFO':
                self.hostnameLabel2 = snack.Label(hw['hostname'])
                grid.setField(self.hostnameLabel2, 1, 1, anchorLeft = 1)

                if tui.profileName != "":
                    self.profileEntry.set(tui.profileName)
                else:
                    self.profileEntry.set(hw['hostname'])

        self.cpuLabel = snack.Label(_("CPU speed:"))
        grid.setField(self.cpuLabel, 2, 1, padding = (1, 0, 1, 0), anchorRight = 1)

        for hw in tui.hardware:            
            if hw['class'] == 'CPU':
                self.speedLabel2 = snack.Label(_("%d MHz") % hw['speed'])
                grid.setField(self.speedLabel2, 3, 1, anchorLeft = 1)

        self.ipLabel = snack.Label(_("IP Address:"))
        grid.setField(self.ipLabel, 0, 2, padding = (0, 0, 1, 0), anchorRight = 1)


        for hw in tui.hardware:
            if hw['class'] == 'NETINFO':
                self.ipLabel2 = snack.Label(hw['ipaddr'])
                grid.setField(self.ipLabel2, 1, 2, anchorLeft = 1)

        self.ramLabel = snack.Label(_("Memory:"))
        grid.setField(self.ramLabel, 2, 2, padding = (1, 0, 1, 0), anchorRight = 1)

        for hw in tui.hardware:
            if hw['class'] == 'MEMORY':
                self.ramLabel2 = snack.Label(_("%s megabytes") % hw['ram'])
                grid.setField(self.ramLabel2, 3, 2, anchorLeft = 1)

        toplevel.add(grid, 0, 4)

        self.additionalHWLabel = snack.TextboxReflowed(size[0]-10, _("Additional hardware information including PCI devices, disk sizes and mount points will be included in the profile."))

        toplevel.add(self.additionalHWLabel, 0, 5, padding = (0, 1, 0, 0),
                     anchorLeft = 1)
        
        # BUTTON BAR
        self.bb = snack.ButtonBar(screen,
                                  [(_("Next"), "next"),
                                   (_("Back"), "back"),
                                   (_("Cancel"), "cancel")])
        toplevel.add(self.bb, 0, 6, padding = (0, 1, 0, 0),
                     growx = 1)

        self.g = toplevel


    def saveResults(self):
        self.tui.profileName = self.profileEntry.value()
        self.tui.includeHardware = self.hardwareButton.selected()

    def run(self):
        result = self.g.runOnce()
        button = self.bb.buttonPressed(result)

        if result == "F12":
            return "next"
        return button

class PackagesWindow:

    def __init__(self, screen, tui):
        self.name = "PackagesWindow"
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()
        toplevel = snack.GridForm(screen, _("Step 3 : Register a System Profile - Packages"),
                                  1, 7)
        self.g = toplevel


        text = snack.TextboxReflowed(size[0]-10, _("RPM information is important to determine what updated software packages are relevant to this system."))

        toplevel.add(text, 0, 1, anchorLeft = 1)

        self.packagesButton = snack.Checkbox(_("Include RPM packages installed on this system in my System Profile"), 1)
        toplevel.add(self.packagesButton, 0, 2, padding = (0, 1, 0, 1),
                     anchorLeft = 1)

        label = snack.Label(_("You may deselect individual packages by unchecking them below."))
        toplevel.add(label, 0, 3, anchorLeft = 1)

        #self.packageList = snack.Listbox(size[1]-18, 1, width = size[0]-10)
        self.packageList = snack.CheckboxTree(size[1]-18, 1)
        toplevel.add(self.packageList, 0, 4)

        # do we need to read the packages from disk?
        if tui.packageList == []:
            self.pwin = snack.GridForm(screen, _("Building Package List"),
                               1, 1)

            self.scale = snack.Scale(40, 100)
            self.pwin.add(self.scale, 0, 0)
            self.pwin.draw()
            self.screen.refresh()
            getInfo = 0
            if rhnreg.cfg['supportsExtendedPackageProfile']:
                getInfo = 1
            tui.packageList = rpmUtils.getInstalledPackageList(getInfo=getInfo)
            self.screen.popWindow()

        for package in tui.packageList:
            self.packageList.append("%s-%s-%s" % (package[0],
                                                  package[1],
                                                  package[2]),
                                                  item = package[0],
                                                  selected = 1)
            
        # BUTTON BAR
        self.bb = snack.ButtonBar(screen,
                                  [(_("Next"), "next"),
                                   (_("Back"), "back"),
                                   (_("Cancel"), "cancel")])
        toplevel.add(self.bb, 0, 5, padding = (0, 1, 0, 0),
                     growx = 1)



    def setScale(self, amount, total):
        self.scale.set(int(((amount * 1.0)/ total) * 100))
        self.pwin.draw()
        self.screen.refresh()
        

    def saveResults(self):
        self.tui.includePackages = self.packagesButton.selected()
       selection = self.packageList.getSelection()
        for pkg in self.tui.packageList:
            if pkg[0] in selection:
                self.tui.selectedPackages.append(pkg)

        
    def run(self):
        result = self.g.runOnce()
        button = self.bb.buttonPressed(result)

        if result == "F12":
            return "next"
        return button

class SendWindow:

    def __init__(self, screen, tui):
        self.screen = screen
        self.tui = tui
        self.name = "SendWindow"
        size = snack._snack.size()
        
        toplevel = snack.GridForm(screen, _("Send Profile Information to Red Hat Network"),
                                  1, 2)

        text = snack.TextboxReflowed(size[0]-15, _("We are finished collecting information for the System Profile.\n\nPress \"Next\" to send this System Profile to Red Hat Network.  Click \"Cancel\" and no information will be sent.  You can run the registration program later by typing `up2date --register` at the command line."))
        toplevel.add(text, 0, 0)

        # BUTTON BAR
        self.bb = snack.ButtonBar(screen,
                                  [(_("Next"), "next"),
                                   (_("Back"), "back"),
                                   (_("Cancel"), "cancel")])
        toplevel.add(self.bb, 0, 1, padding = (0, 1, 0, 0),
                     growx = 1)

        self.g = toplevel

    def saveResults(self):
        pass


    def run(self):
        result = self.g.runOnce()
        button = self.bb.buttonPressed(result)

        if result == "F12":
            return "next"
        return button

class FinishWindow:

    def __init__(self, screen, tui):
        self.name = "FinishWindow"
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()
        
        toplevel = snack.GridForm(screen, _("Registration Finished"),
                                  1, 2)

        text = snack.TextboxReflowed(size[0]-11, _("You have successfully registered this System Profile on Red Hat Network.\n\nPlease visit http://www.redhat.com/network to login and access your Red Hat Network benefits.\n\nTo upgrade your system with the latest product updates, bug fixes and security enhancements, run up2date at the command line, or choose \"Update Agent\" from the panel."))
        toplevel.add(text, 0, 0)
        
        # BUTTON BAR
        self.bb = snack.ButtonBar(screen,
                                  [(_("Finish"), "next")])
        toplevel.add(self.bb, 0, 1, padding = (0, 1, 0, 0),
                     growx = 1)

        self.g = toplevel

        self.pwin = snack.GridForm(screen, _("Sending Profile to Red Hat Network"),
                                   1, 1)

        self.scale = snack.Scale(40, 100)
        self.pwin.add(self.scale, 0, 0)
        self.pwin.draw()
        self.screen.refresh()

        # send the data
        try:
            rhnreg.registerUser(tui.userName, tui.password, tui.email)
        except up2dateErrors.CommunicationError, e:
            FatalErrorWindow(self.screen, _("Problem registering user name:\n") + e.errmsg)
        except:
            FatalErrorWindow(self.screen, _("Problem registering username."))

        self.setScale(1, 5)

        try:
            systemId = rhnreg.registerSystem(tui.userName, tui.password,
                                             tui.profileName)
        except up2dateErrors.CommunicationError, e:
            FatalErrorWindow(self.screen, _("Problem registering system:\n") + e.errmsg)
        except up2dateErrors.RhnUuidUniquenessError, e:
            FatalErrorWindow(self.screen, _("Problem registering system:\n") + e.errmsg)
        except:
            FatalErrorWindow(self.screen, _("Problem registering system."))

        # write the system id out.
        if not rhnreg.writeSystemId(systemId):
            FatalErrorWindow(self.screen, _("Problem writing out system id to disk."))

        self.setScale(2, 5)

        # include the info from the oeminfo file as well
        self.oemInfo = rhnreg.getOemInfo()
        
        # dont send if already registered, do send if they have oemInfo
        if ( not self.tui.alreadyRegistered ) or ( len(self.oemInfo)):
            # send product registration information
            if rhnreg.cfg['supportsUpdateContactInfo']:
                #rhnreg.updateContactInfo(self.username, self.password,  self.tui.productInfo,self.tui.oemInfo)
                try:
                    rhnreg.updateContactInfo(tui.userName, tui.password,  self.tui.productInfo)
                except up2dateErrors.CommunicationError, e:
                    FatalErrorWindow(self.screen, _("Problem registering personal information:\n") + e.errmsg)
                except:
                    print sys.exc_info()
                    print sys.exc_type
                    
                    FatalErrorWindow(self.screen, _("Problem registering personal information"))
                    
            else:
                rhnreg.registerProduct(systemId, self.tui.productInfo,self.tui.oemInfo)
                try:
                    rhnreg.registerProduct(systemId, self.tui.productInfo,self.tui.oemInfo)
                except up2dateErrors.CommunicationError, e:
                    FatalErrorWindow(self.screen, _("Problem registering personal information:\n") + e.errmsg)
                except:
                    FatalErrorWindow(self.screen, _("Problem registering personal information"))

        self.setScale(3, 5)

        # maybe upload hardware profile
        if tui.includeHardware:
            try:
                rhnreg.sendHardware(systemId, tui.hardware)
            except up2dateErrors.CommunicationError, e:
                FatalErrorWindow(self.screen,
                                 _("Problem sending hardware profile:\n") + e.errmsg)
            except:
                FatalErrorWindow(self.screen,
                                 _("Problem sending hardware profile."))

        self.setScale(4, 5)

        # build up package list if necessary
        if tui.includePackages:
            try:
                rhnreg.sendPackages(systemId, tui.selectedPackages)
            except up2dateErrors.CommunicationError, e:
                FatalErrorWindow(self.screen, _("Problem sending package list:\n") + e.errmsg)
            except:
                FatalErrorWindow(self.screen, _("Problem sending package list."))

        rhnreg.startRhnsd()

        self.setScale(5, 5)
        self.screen.popWindow()


    def setScale(self, amount, total):
        self.scale.set(int(((amount * 1.0)/ total) * 100))
        self.pwin.draw()
        self.screen.refresh()


    def saveResults(self):
        pass


    def run(self):
        result = self.g.runOnce()
        button = self.bb.buttonPressed(result)

        if result == "F12":
            return "next"
        return button


class Tui:

    def __init__(self, screen):
        self.screen = screen
        self.size = snack._snack.size()
        self.drawFrame()
        self.alreadyRegistered = 0

        self.windows = [
            StartWindow,
            PrivacyWindow,
#            TermsAndConditionsWindow,
           InfoWindow,
#            OrgWindow,
            ProductWindow,
            HardwareWindow,
            PackagesWindow,
            SendWindow,
            FinishWindow
            ]
       
    def __del__(self):
        self.screen.finish()


    def drawFrame(self):
        self.welcomeText = (_("Red Hat Network Registration (c) 2000-2001 Red Hat, Inc."))
        self.screen.drawRootText(0, 0, self.welcomeText)
        self.screen.pushHelpLine(_("  <Tab>/<Alt-Tab> between elements  |  <Space> selects  |  <F12> next screen"))


    def initResults(self):
        self.userName = ""
        self.password = ""
        self.enableEmail = 1
        self.email = ""

        self.oemInfo = {}
        self.productInfo = {
            "reg_num" : "",
            "title" : "",
            "first_name" : "",
            "last_name" : "",
            "company" : "",
            "position" : "",
            "address1" : "",
            "address2" : "",
            "city" : "",
            "state" : "",
            "zip" : "",
            "country" : "",
            "phone" : "",
            "fax" : "",
            "contact_email" : 1,
            "contact_mail" : 0,
            "contact_phone" : 0,
            "contact_fax" : 0,
            "contact_special" : 0,
            "contact_newsletter" : 0
            }
        
        self.profileName = ""
        self.includeHardware = 1
        self.version = ""
        self.hostname = ""
        self.ip = ""
        self.cpu = ""
        self.speed = 0
        self.ram = ""
        
        self.includePackages = 0
        self.packageList = []
        self.selectedPackages = []

        
    def run(self):
        self.initResults()
        
        try:
            index = 0
            while index < len(self.windows):
                win = self.windows[index](self.screen, self)
                # dont get all the gory user info if they already registered
                if win.name == "ProductWindow" and self.alreadyRegistered:
                    index = index + 1
                    continue
                
                result = win.run()
                win.saveResults()

                if result == "back":
                    # hardware window
                    if win == self.windows[4] and self.alreadyRegistered:
                        index = index - 2
                    else:
                        index = index - 1
                elif result == "next":
                    # info window
                    if win == self.windows[2] and self.alreadyRegistered:
                        index = index + 2
                    else:
                        index = index + 1
                elif result == "cancel":
                    return

        finally:
            self.screen.finish()

        
def main():
    test = 0    
    signal.signal(signal.SIGINT, signal.SIG_IGN)

    if len(sys.argv) > 1:
        if sys.argv[1] == "-t" or sys.argv[1] == "--test":
            test = 1
            
    screen = snack.SnackScreen()

    if not rpcServer.hasSSL():
        if snack.ButtonChoiceWindow(screen, _("SSL Warning"),
                                    _("""Your system libraries do not support SSL (secure) connections.  Any data that you send or receive from Red Hat Network will be transmitted in the clear. Continue anyway?""")) == "cancel":
            screen.finish()
            sys.exit(1)

    if geteuid() != 0 and not test:
        FatalErrorWindow(screen, _("You must run the RHN registration program as root."))


    if rhnreg.registered() and not test:
        if snack.ButtonChoiceWindow(screen, _("Already Registered"),
                                    _("This system appears to already be registered.  Continue anyway?")) == "cancel":
            
            screen.finish()
            sys.exit(1)
        
    tui = Tui(screen)
    tui.run()

    
if __name__ == "__main__":
    main()

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0072 ]--