def __init__(self): QWidget.__init__(self) self.ui = Ui_RootPassWidget() self.ui.setupUi(self) self.intf = ctx.interface self.host_valid = True self.pass_valid = False if ctx.flags.install_type == ctx.STEP_DEFAULT: self.pthread = PThread(self, self.startInit, self.dummy) self.pds_messagebox = PMessageBox(self) self.pds_messagebox.enableOverlay() self.ui.pass1.textChanged[str].connect(self.slotTextChanged) self.ui.pass2.textChanged[str].connect(self.slotTextChanged) self.ui.pass2.returnPressed.connect(self.slotReturnPressed) self.ui.hostname.textChanged[str].connect(self.slotHostnameChanged)
def __init__(self): QWidget.__init__(self) self.ui = Ui_RootPassWidget() self.ui.setupUi(self) self.intf = ctx.interface self.host_valid = True self.pass_valid = False if ctx.flags.install_type in [ctx.STEP_DEFAULT, ctx.STEP_LIVE]: self.pthread = PThread(self, self.startInit, self.dummy) self.pds_messagebox = PMessageBox(self) self.pds_messagebox.enableOverlay() self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("returnPressed()"), self.slotReturnPressed) self.connect(self.ui.hostname, SIGNAL("textChanged(const QString &)"), self.slotHostnameChanged)
def __init__(self, *args): QtGui.QWidget.__init__(self,None) self.ui = Ui_RootPassWidget() self.ui.setupUi(self) self.host_valid = True self.pass_valid = False self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("returnPressed()"), self.slotReturnPressed) self.connect(self.ui.hostname, SIGNAL("textChanged(const QString &)"), self.slotHostnameChanged)
def __init__(self, *args): QtGui.QWidget.__init__(self, None) self.ui = Ui_RootPassWidget() self.ui.setupUi(self) self.host_valid = True self.pass_valid = False self.ui.pass_error.setVisible(False) self.ui.host_error.setVisible(False) self.ui.caps_error.setVisible(False) self.ui.caps_error.setText(_("<center>Caps Lock is on.</center>")) self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("returnPressed()"), self.slotReturnPressed) self.connect(self.ui.hostname, SIGNAL("textChanged(const QString &)"), self.slotHostnameChanged)
class Widget(QWidget, ScreenWidget): name = "admin" def __init__(self): QWidget.__init__(self) self.ui = Ui_RootPassWidget() self.ui.setupUi(self) self.intf = ctx.interface self.host_valid = True self.pass_valid = False if ctx.flags.install_type in [ctx.STEP_DEFAULT, ctx.STEP_LIVE]: self.pthread = PThread(self, self.startInit, self.dummy) self.pds_messagebox = PMessageBox(self) self.pds_messagebox.enableOverlay() self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("returnPressed()"), self.slotReturnPressed) self.connect(self.ui.hostname, SIGNAL("textChanged(const QString &)"), self.slotHostnameChanged) def update(self): if self.host_valid and self.pass_valid: ctx.mainScreen.enableNext() else: ctx.mainScreen.disableNext() def shown(self): if ctx.installData.hostName: self.ui.hostname.setText(str(ctx.installData.hostName)) else: # Use first added user's name as machine name if its exists release_hostname = yali.util.product_release() if self.ui.hostname.text() == '': self.ui.hostname.setText(release_hostname) if ctx.installData.rootPassword: self.ui.pass1.setText(ctx.installData.rootPassword) self.ui.pass2.setText(ctx.installData.rootPassword) self.update() self.checkCapsLock() self.ui.pass1.setFocus() def dummy(self): pass def execute(self): ctx.installData.rootPassword = unicode(self.ui.pass1.text()) ctx.installData.hostName = unicode(self.ui.hostname.text()) if ctx.flags.install_type in [ctx.STEP_DEFAULT, ctx.STEP_LIVE]: #FIXME:Refactor dirty code if ctx.storageInitialized: disks = filter(lambda d: not d.format.hidden, ctx.storage.disks) if len(disks) == 1: ctx.storage.clearPartDisks = [disks[0].name] ctx.mainScreen.step_increment = 2 else: ctx.mainScreen.step_increment = 1 else: self.pds_messagebox.setMessage( _("Storage Devices initialising...")) self.pds_messagebox.animate(start=MIDCENTER, stop=MIDCENTER) ctx.mainScreen.step_increment = 0 self.pthread.start() QTimer.singleShot(2, self.startStorageInitialize) return False return True def startInit(self): self.pds_messagebox.animate(start=MIDCENTER, stop=MIDCENTER) def startStorageInitialize(self): ctx.storageInitialized = yali.storage.initialize( ctx.storage, ctx.interface) self.initFinished() def initFinished(self): self.pds_messagebox.animate(start=CURRENT, stop=CURRENT, direction=OUT) disks = filter(lambda d: not d.format.hidden, ctx.storage.disks) if ctx.storageInitialized: if len(disks) == 1: ctx.storage.clearPartDisks = [disks[0].name] ctx.mainScreen.step_increment = 2 else: ctx.mainScreen.step_increment = 1 ctx.mainScreen.slotNext(dry_run=True) else: ctx.mainScreen.enableBack() def setCapsLockIcon(self, child): if type(child) == QLineEdit: if pardus.xorg.capslock.isOn(): child.setStyleSheet("""QLineEdit { background-image: url(:/gui/pics/caps.png); background-repeat: no-repeat; background-position: right; padding-right: 35px; }""") else: child.setStyleSheet("""QLineEdit { background-image: none; padding-right: 0px; }""") def checkCapsLock(self): for child in self.ui.groupBox.children(): self.setCapsLockIcon(child) def keyReleaseEvent(self, event): self.checkCapsLock() def slotTextChanged(self): password = str(self.ui.pass1.text()) password_confirm = str(self.ui.pass2.text()) if password and password == password_confirm: if len(password) < 4: self.intf.informationWindow.update(_('Password is too short.'), type="error") self.pass_valid = False else: self.intf.informationWindow.hide() self.pass_valid = True else: self.pass_valid = False if password_confirm: self.intf.informationWindow.update( _('Passwords do not match.'), type="error") if password.lower() == "root" or password_confirm.lower() == "root": self.pass_valid = False if password_confirm: self.intf.informationWindow.update( _('Do not use your username as your password.'), type="error") if self.pass_valid: self.intf.informationWindow.hide() self.update() def slotHostnameChanged(self, hostname): if len(hostname) > 64: self.host_valid = False self.intf.informationWindow.update( _('Hostname cannot be longer than 64 characters.'), type="error") self.update() return if not hostname.toAscii(): self.host_valid = False self.update() return self.host_valid = yali.util.is_text_valid(hostname.toAscii()) if not self.host_valid: self.intf.informationWindow.update( _('Hostname contains invalid characters.'), type="error") else: self.intf.informationWindow.hide() self.update() def slotReturnPressed(self): if ctx.mainScreen.isNextEnabled(): ctx.mainScreen.slotNext()
class Widget(QWidget, ScreenWidget): name = "admin" finished=pyqtSignal() def __init__(self): QWidget.__init__(self) self.ui = Ui_RootPassWidget() self.ui.setupUi(self) self.intf = ctx.interface self.host_valid = True self.pass_valid = False if ctx.flags.install_type == ctx.STEP_DEFAULT: self.pthread = PThread(self, self.startInit, self.dummy) self.pds_messagebox = PMessageBox(self) self.pds_messagebox.enableOverlay() self.ui.pass1.textChanged[str].connect(self.slotTextChanged) self.ui.pass2.textChanged[str].connect(self.slotTextChanged) self.ui.pass2.returnPressed.connect(self.slotReturnPressed) self.ui.hostname.textChanged[str].connect(self.slotHostnameChanged) def update(self): if self.host_valid and self.pass_valid: ctx.mainScreen.enableNext() else: ctx.mainScreen.disableNext() def shown(self): if ctx.installData.hostName: self.ui.hostname.setText(str(ctx.installData.hostName)) else: # Use first added user's name as machine name if its exists release_hostname = yali.util.product_release() if self.ui.hostname.text() == '': self.ui.hostname.setText(release_hostname) if ctx.installData.rootPassword: self.ui.pass1.setText(ctx.installData.rootPassword) self.ui.pass2.setText(ctx.installData.rootPassword) self.update() self.checkCapsLock() self.ui.pass1.setFocus() def dummy(self): pass def execute(self): ctx.installData.rootPassword = unicode(self.ui.pass1.text()) ctx.installData.hostName = unicode(self.ui.hostname.text()) if ctx.flags.install_type == ctx.STEP_DEFAULT: #FIXME:Refactor dirty code if ctx.storageInitialized: disks = filter(lambda d: not d.format.hidden, ctx.storage.disks) if len(disks) == 1: ctx.storage.clearPartDisks = [disks[0].name] ctx.mainScreen.step_increment = 2 else: ctx.mainScreen.step_increment = 1 else: self.pds_messagebox.setMessage(_("Storage Devices initialising...")) self.pds_messagebox.animate(start=MIDCENTER, stop=MIDCENTER) ctx.mainScreen.step_increment = 0 self.pthread.start() QTimer.singleShot(2, self.startStorageInitialize) return False return True def startInit(self): self.pds_messagebox.animate(start=MIDCENTER, stop=MIDCENTER) def startStorageInitialize(self): ctx.storageInitialized = yali.storage.initialize(ctx.storage, ctx.interface) self.initFinished() def initFinished(self): self.pds_messagebox.animate(start=CURRENT, stop=CURRENT, direction=OUT) disks = filter(lambda d: not d.format.hidden, ctx.storage.disks) if ctx.storageInitialized: if len(disks) == 1: ctx.storage.clearPartDisks = [disks[0].name] ctx.mainScreen.step_increment = 2 else: ctx.mainScreen.step_increment = 1 ctx.mainScreen.slotNext(dry_run=True) self.finished.emit() else: ctx.mainScreen.enableBack() def setCapsLockIcon(self, child): if type(child) == QLineEdit: if pardus.xorg.capslock.isOn(): child.setStyleSheet("""QLineEdit { background-image: url(:/gui/pics/caps.png); background-repeat: no-repeat; background-position: right; padding-right: 35px; }""") else: child.setStyleSheet("""QLineEdit { background-image: none; padding-right: 0px; }""") def checkCapsLock(self): for child in self.ui.groupBox.children(): self.setCapsLockIcon(child) def keyReleaseEvent(self, event): self.checkCapsLock() def slotTextChanged(self): password = str(self.ui.pass1.text()) password_confirm = str(self.ui.pass2.text()) if password and password == password_confirm: if len(password) < 4: self.intf.informationWindow.update(_('Password is too short.'), type="error") self.pass_valid = False else: self.intf.informationWindow.hide() self.pass_valid = True else: self.pass_valid = False if password_confirm: self.intf.informationWindow.update(_('Passwords do not match.'), type="error") if password.lower()=="root" or password_confirm.lower()=="root": self.pass_valid = False if password_confirm: self.intf.informationWindow.update(_('Do not use your username as your password.'), type="error") if self.pass_valid: self.intf.informationWindow.hide() self.update() def slotHostnameChanged(self, hostname): if len(hostname) > 64: self.host_valid = False self.intf.informationWindow.update(_('Hostname cannot be longer than 64 characters.'), type="error") self.update() return if not hostname: self.host_valid = False self.update() return self.host_valid = yali.util.is_text_valid(hostname) if not self.host_valid: self.intf.informationWindow.update(_('Hostname contains invalid characters.'), type="error") else: self.intf.informationWindow.hide() self.update() def slotReturnPressed(self): if ctx.mainScreen.isNextEnabled(): ctx.mainScreen.slotNext()
class Widget(QtGui.QWidget, ScreenWidget): title = _("Choose an Administrator Password and a Hostname") icon = "iconAdmin" helpSummary = _("""Your password must be easy to remember but strong enough to resist possible attacks. You can use capital and lower-case letters, numbers and punctuation marks in your password.""") help = _(""" <p> You need to define a password for the "root" user which is the conventional name of the user who has all rights and permissions (to all files and programs) in all modes (single or multi-user). </p> <p> Your password must be easy to remember but strong enough to resist possible attacks. You can use capital and lower-case letters, numbers and punctuation marks in your password. </p> <p> You can also define a hostname for your computer. A hostname is an identifier assigned to your computer. As your computer will be recognized with this name in the local network, it is recommended to select a descriptive hostname. </p> """) def __init__(self, *args): QtGui.QWidget.__init__(self,None) self.ui = Ui_RootPassWidget() self.ui.setupUi(self) self.intf = ctx.interface self.host_valid = True self.pass_valid = False self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("returnPressed()"), self.slotReturnPressed) self.connect(self.ui.hostname, SIGNAL("textChanged(const QString &)"), self.slotHostnameChanged) def update(self): if self.host_valid and self.pass_valid: ctx.mainScreen.enableNext() else: ctx.mainScreen.disableNext() def shown(self): if ctx.installData.hostName: self.ui.hostname.setText(str(ctx.installData.hostName)) else: # Use first added user's name as machine name if its exists release=open("/etc/pardus-release").read().split() releaseHostName = "".join(release[:2]).lower() if self.ui.hostname.text() == '': self.ui.hostname.setText(releaseHostName) if ctx.installData.rootPassword: self.ui.pass1.setText(ctx.installData.rootPassword) self.ui.pass2.setText(ctx.installData.rootPassword) self.update() self.checkCapsLock() self.ui.pass1.setFocus() def execute(self): ctx.installData.rootPassword = unicode(self.ui.pass1.text()) ctx.installData.hostName = unicode(self.ui.hostname.text()) ctx.storage.reset() if ctx.storage.checkNoDisks(self.intf): sys.exit(0) else: disks = filter(lambda d: not d.format.hidden, ctx.storage.disks) if len(disks) == 1: ctx.storage.clearPartDisks = [disks[0].name] ctx.mainScreen.stepIncrement = 2 else: ctx.mainScreen.stepIncrement = 1 return True def setCapsLockIcon(self, child): if type(child) == QtGui.QLineEdit: if pardus.xorg.capslock.isOn(): child.setStyleSheet("QLineEdit {background: url(:/gui/pics/caps.png) no-repeat right;\npadding-right: 35px}") else: child.setStyleSheet("QLineEdit {background: none; padding-right: 0px}") def checkCapsLock(self): for child in self.ui.groupBox.children(): self.setCapsLockIcon(child) def keyReleaseEvent(self, e): self.checkCapsLock() def slotTextChanged(self): p1 = self.ui.pass1.text() p2 = self.ui.pass2.text() if p1 == p2 and p1: if len(p1)<4: self.intf.informationWindow.update(_('Password is too short.'), type="error") self.pass_valid = False else: self.intf.informationWindow.hide() self.pass_valid = True else: self.pass_valid = False if p2: self.intf.informationWindow.update(_('Passwords do not match.'), type="error") if str(p1).lower()=="root" or str(p2).lower()=="root": self.pass_valid = False if p2: self.intf.informationWindow.update(_('Do not use your username as your password.'), type="error") if self.pass_valid: self.intf.informationWindow.hide() self.update() def slotHostnameChanged(self, hostname): if len(hostname) > 64: self.host_valid = False self.intf.informationWindow.update(_('Hostname cannot be longer than 64 characters.'), type="error") self.update() return if not hostname.toAscii(): self.host_valid = False self.update() return self.host_valid = yali.util.is_text_valid(hostname.toAscii()) if not self.host_valid: self.intf.informationWindow.update(_('Hostname contains invalid characters.'), type="error") else: self.intf.informationWindow.hide() self.update() def slotReturnPressed(self): if ctx.mainScreen.isNextEnabled(): ctx.mainScreen.slotNext()
class Widget(QtGui.QWidget, ScreenWidget): title = _("Choose an Administrator Password and a Hostname") icon = "iconAdmin" help = _( """ <font size="+2">Administrator Password and Hostname</font> <font size="+1"> <p> You need to define a password for the "root" user which is the conventional name of the user who has all rights and permissions (to all files and programs) in all modes (single or multi-user). </p> <p> Your password must be easy to remember but strong enough to resist possible attacks. You can use capital and lower-case letters, numbers and punctuation marks in your password. </p> <p> You can also define a hostname for your computer. A hostname is an identifier assigned to your computer. As your computer will be recognized with this name in the local network, it is recommended to select a descriptive hostname. </p> </font> """ ) def __init__(self, *args): QtGui.QWidget.__init__(self, None) self.ui = Ui_RootPassWidget() self.ui.setupUi(self) self.host_valid = True self.pass_valid = False self.ui.pass_error.setVisible(False) self.ui.host_error.setVisible(False) self.ui.caps_error.setVisible(False) self.ui.caps_error.setText(_("<center>Caps Lock is on.</center>")) self.connect(self.ui.pass1, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("textChanged(const QString &)"), self.slotTextChanged) self.connect(self.ui.pass2, SIGNAL("returnPressed()"), self.slotReturnPressed) self.connect(self.ui.hostname, SIGNAL("textChanged(const QString &)"), self.slotHostnameChanged) def shown(self): if ctx.installData.hostName: self.ui.hostname.setText(str(ctx.installData.hostName)) else: # Use first added user's name as machine name if its exists hostname_guess = "pardus" if len(yali.users.pending_users) > 0: hostname_guess = "%s-pardus" % yali.users.pending_users[0].username else: ctx.debugger.log("No user defined in users screen") if self.ui.hostname.text() == "": self.ui.hostname.setText(hostname_guess) if ctx.installData.rootPassword: self.ui.pass1.setText(ctx.installData.rootPassword) self.ui.pass2.setText(ctx.installData.rootPassword) self.setNext() self.checkCapsLock() self.ui.pass1.setFocus() def execute(self): ctx.installData.rootPassword = unicode(self.ui.pass1.text()) ctx.installData.hostName = self.ui.hostname.text().toAscii() return True def checkCapsLock(self): if pardus.xorg.capslock.isOn(): self.ui.caps_error.setVisible(True) else: self.ui.caps_error.setVisible(False) def keyReleaseEvent(self, e): self.checkCapsLock() def slotTextChanged(self): p1 = self.ui.pass1.text() p2 = self.ui.pass2.text() if p1 == p2 and p1: if len(p1) < 4: self.ui.pass_error.setText(_("Password is too short.")) self.ui.pass_error.setVisible(True) self.pass_valid = False else: self.ui.pass_error.setVisible(False) self.pass_valid = True else: self.pass_valid = False if p2: self.ui.pass_error.setText(_("Passwords do not match.")) self.ui.pass_error.setVisible(True) if str(p1).lower() == "root" or str(p2).lower() == "root": self.pass_valid = False if p2: self.ui.pass_error.setText(_("Do not use your username as your password.")) self.ui.pass_error.setVisible(True) if self.pass_valid: self.ui.pass_error.setVisible(False) self.setNext() ## # check hostname validity def slotHostnameChanged(self, string): if not string.toAscii(): self.host_valid = False self.setNext() return self.host_valid = yali.sysutils.isTextValid(string.toAscii()) if not self.host_valid: self.ui.host_error.setVisible(True) self.ui.host_error.setText(_("Hostname contains invalid characters.")) else: self.ui.host_error.setVisible(False) self.setNext() def setNext(self): if self.host_valid and self.pass_valid: ctx.mainScreen.enableNext() else: ctx.mainScreen.disableNext() def slotReturnPressed(self): if ctx.mainScreen.isNextEnabled(): ctx.mainScreen.slotNext()