def remove_entry(self, widget, data): (model, iter) = self.name_map['bootlist_treeview'].get_selection().get_selected() if not iter: magicpopup.magicmsgbox(None, _('Please choose an entry to remove.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return device = model.get_value(iter, 2) if device == CF.G.root_device: magicpopup.magicmsgbox(None, _('Please do not remove the entry to boot the installed system.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return else: self.restore_dos = None default = model.get_value(iter, 3) self.list_remove('bootloader.entrylist', iter) iter = model.get_iter_first() while iter: device = model.get_value(iter, 2) if device == CF.G.root_device: model.set_value(iter, 0, self.get_pixbuf_map('images/yes.png')) model.set_value(iter, 3, 'true') break iter = model.iter_next(iter)
def check_leave_others(self): self.fetch_values(self.rootobj.values) ulnode = self.srh_data_node(self.values, 'accounts.userlist') all_username = {} all_uid = {} for rownode in ulnode.getElementsByTagName('row'): username = rownode.getAttribute('c0') if all_username.has_key(username): # TO TRANSLATOR: Do not translate %FIRST. errtxt = _("Two user share the same username '%s'.") errtxt = errtxt % username magicpopup.magicmsgbox(None, errtxt, magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return 0 all_username[username] = 'y' uid = rownode.getAttribute('c4') if uid == 'Auto': continue if all_uid.has_key(uid): errtxt = _("The custom uid is conflict between '%s' and '%s'.") errtxt = errtxt % (all_uid[uid], rownode.getAttribute('c0')) magicpopup.magicmsgbox(None, errtxt, magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return 0 all_uid[uid] = rownode.getAttribute('c0') return 1
def remove_entry(self, widget, data): (model, iter ) = self.name_map['bootlist_treeview'].get_selection().get_selected() if not iter: magicpopup.magicmsgbox(None, _('Please choose an entry to remove.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return device = model.get_value(iter, 2) if device == CF.G.root_device: magicpopup.magicmsgbox( None, _('Please do not remove the entry to boot the installed system.' ), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return else: self.restore_dos = None default = model.get_value(iter, 3) self.list_remove('bootloader.entrylist', iter) iter = model.get_iter_first() while iter: device = model.get_value(iter, 2) if device == CF.G.root_device: model.set_value(iter, 0, self.get_pixbuf_map('images/yes.png')) model.set_value(iter, 3, 'true') break iter = model.iter_next(iter)
def leave(self): if self.doing: magicpopup.magicmsgbox( None, _('We are doing setup, do not leave please.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return 0 return 1
def check_leave_others(self): self.fetch_values(self.rootobj.values) ulnode = self.srh_data_node(self.values, 'accounts.userlist') all_username = {} all_uid = {} for rownode in ulnode.getElementsByTagName('row'): username = rownode.getAttribute('c0') if all_username.has_key(username): # TO TRANSLATOR: Do not translate %FIRST. errtxt = _("Two user share the same username '%s'.") errtxt = errtxt % username magicpopup.magicmsgbox(None, errtxt, magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return 0 all_username[username] = 'y' uid = rownode.getAttribute('c4') if uid == 'Auto': continue if all_uid.has_key(uid): errtxt = _("The custom uid is conflict between '%s' and '%s'.") errtxt = errtxt % (all_uid[uid], rownode.getAttribute('c0')) magicpopup.magicmsgbox(None, errtxt, magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return 0 all_uid[uid] = rownode.getAttribute('c0') return 1
def enter(self): if CF.G.skipxsetting: if not self.gen_x_settings(): magicpopup.magicmsgbox(None, _('Failed to collect the information about Xwindow configuration.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) # Continue anyway. #return 0 self.rootobj.tm.add_action(_('Generate Xwindow configuration'), None, None, 'gen_x_config', self.x_settings) self.rootobj.tm.add_action(_('Backup Xwindow configuration files'), None, None, 'backup_xconfig', 0) self.rootobj.btnback_sensitive(False) self.rootobj.btnnext_sensitive(False) dolog('action_accounts\n') rootpasswd = self.get_data(self.values, 'accounts.root.password') acclist = [] accnode = self.srh_data_node(self.values, 'accounts.userlist') for node in accnode.getElementsByTagName('row'): acclist.append((node.getAttribute('c0'), # Username. node.getAttribute('c1'), # Password. node.getAttribute('c2'), # Shell. node.getAttribute('c3'), # Home directory. node.getAttribute('c4'))) # Real UID or 'Auto'. dolog('%s\n' % 'setup_accounts') #str(('setup_accounts', rootpasswd, acclist))) self.rootobj.tm.add_action(_('Setup accounts'), self.doshort, None, 'setup_accounts', rootpasswd, acclist) return 1
def leave(self): if self.doing: magicpopup.magicmsgbox(None, _('We are doing setup, do not leave please.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return 0 return 1
def remove_user(self, widget, data): iter = self.name_map['userlist_treeview'].get_selection().get_selected() if iter[1]: self.list_remove('accounts.userlist', iter[1]) else: magicpopup.magicmsgbox(None, _('Please choose a user to remove.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK)
def dispatch(self, *args): no_err = True self.lock.acquire() task_info = self.task_info_map[self.cur_tmid] # optional record #self.task_grp_info[task_info['grp_name']]['last_result'] = args # handle with this task's result self.lock.release() if callable(task_info['task'].rcfunc): ret = task_info['task'].rcfunc(*args) else: ret = 'quit' if type(ret) is str: if ret == 'quit': # quit current task group, do next task group self.cur_grp_name = None else: raise Exception('Not Support', 'Unknow ret %s' % ret) elif len(ret) == 2: valid, task_or_msg = ret if valid or valid == 'continue': # add a task if isinstance(task_or_msg, MiTask): self.add_task(task_info['grp_name'], task_or_msg, False) else: # ?? pass else: # occur error show error message class BoxMsgHandler(object): def __init__(self, sself): self.sself = sself def yes_clicked(self, widget, data): # quit program data.topwin.destroy() gtk.main_quit() def ignore_clicked(self, widget, data): # continue next task data.topwin.destroy() self.sself.lock.acquire() self.sself._run_next_task() self.sself.lock.release() magicpopup.magicmsgbox(BoxMsgHandler(self), _("Occur error! Click Yes to quit installation!\nTask(%s) Group(%s)\nERROR:%s" % (self.task_info_map[self.cur_tmid]['task'].describe, self.cur_grp_name, task_or_msg)), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_YES|magicpopup.magicpopup.MB_IGNORE) no_err = False else: raise Exception('Not Support', 'Unknow ret %s' % ret) self.lock.acquire() self.cur_tmid = None if no_err: self._run_next_task() self.lock.release()
def remove_user(self, widget, data): iter = self.name_map['userlist_treeview'].get_selection().get_selected( ) if iter[1]: self.list_remove('accounts.userlist', iter[1]) else: magicpopup.magicmsgbox(None, _('Please choose a user to remove.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK)
def act_parted_format_result(self, tdata, data): result = tdata if result: # Error occurred. Stop it? # Yes, we should stop it, and we should stop at mount failed place too. logger.info('format_result ERROR: %s\n' % str(result)) magicpopup.magicmsgbox(None, _('Format Partition Error: %s' % result), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) #self.rootobj.btnback_do() self.act_parted_format_start(data + 1)
def test_x_settings_result(self, tdata, data): result = tdata print 'test_x_settings:', result if result == 'SUCCESS': magicpopup.magicmsgbox(None, _('Success!'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) else: magicpopup.magicmsgbox(None, _(result), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK)
def leave(self): if not magicstep.magicstepgroup.leave(self): return 0 if not self.gen_x_settings(): magicpopup.magicmsgbox(None, _('Failed to collect the information about Xwindow configuration.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 self.rootobj.tm.add_action(_('Generate Xwindow configuration'), None, None, 'gen_x_config', self.x_settings) return 1
def test_x_settings_result(self, tdata, data): result = tdata print 'test_x_settings:', result if result == 'SUCCESS': magicpopup.magicmsgbox(None, _('Success!'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) else: magicpopup.magicmsgbox(None, _(result), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK)
def leave(self): if not magicstep.magicstepgroup.leave(self): return 0 if not self.gen_x_settings(): magicpopup.magicmsgbox( None, _('Failed to collect the information about Xwindow configuration.' ), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 self.rootobj.tm.add_action(_('Generate Xwindow configuration'), None, None, 'gen_x_config', self.x_settings) return 1
def check_leave_choose(self): if CF.G.win_probe_status != STAT.OP_STATUS_DONE: magicpopup.magicmsgbox(None, _('Please wait a while for the search of Windows partition.'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) return 0 # save bltype self.fetch_values(self.rootobj.values, valuename_list = ['bootloader.bltype']) # fill ui self.fill_values(self.values) return 1
def check_leave_choose(self): if CF.G.win_probe_status != STAT.OP_STATUS_DONE: magicpopup.magicmsgbox( None, _('Please wait a while for the search of Windows partition.'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) return 0 # save bltype self.fetch_values(self.rootobj.values, valuename_list=['bootloader.bltype']) # fill ui self.fill_values(self.values) return 1
def btncancel_clicked(self, widget, data): self.msgbox = magicpopup.magicmsgbox( self, _('Do you realy want to cancel the installation?'), magicpopup.magicmsgbox.MB_QUESTION, magicpopup.magicmsgbox.MB_YES | magicpopup.magicmsgbox.MB_NO) self.cancel_widget = widget self.cancel_data = data
def reboot_0(self, tdata, data): self.rebootdlg = \ magicpopup.magicmsgbox(self, _('Click "OK" to reboot your system!\nEject the cdrom if you are installed from cdrom.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK, 'reboot_0_')
def reboot_0(self, tdata, data): self.rebootdlg = \ magicpopup.magicmsgbox(self, _('Click "OK" to reboot your system!\nEject the cdrom if you are installed from cdrom.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK, 'reboot_0_')
def check_leave_root(self): self.fetch_values(self.rootobj.values) rootpwd = self.get_data(self.values, 'accounts.root.password') rootpwdconfirm = self.get_data(self.values, 'accounts.root.passwordconfirm') if rootpwd != rootpwdconfirm: magicpopup.magicmsgbox(None, _('Your root password is different with your root password confirmation!'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return 0 if len(rootpwd) < 3: magicpopup.magicmsgbox(None, _('Please do not use the password which shorter than 3 characters.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return 0 return 1
def get_modprobe_result(self, tdata, data): CF.G.reprobe_all_disks_required success = tdata self.waitdlg.topwin.destroy() if not success: magicpopup.magicmsgbox(None, _('Load module failed.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) else: CF.G.reprobe_all_disks_required = 1 stepobj = self.rootobj.stepobj_list[self.rootobj.curstep + 1] # reprobe disk stepobj.reprobe_all() magicpopup.magicmsgbox(None, _('Load module success.'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) self.do_refresh_fill()
def btncancel_clicked(self, widget, data): self.msgbox = magicpopup.magicmsgbox(self, _('Do you realy want to cancel the installation?'), magicpopup.magicmsgbox.MB_QUESTION, magicpopup.magicmsgbox.MB_YES | magicpopup.magicmsgbox.MB_NO) self.cancel_widget = widget self.cancel_data = data
def get_modprobe_result(self, tdata, data): CF.G.reprobe_all_disks_required success = tdata self.waitdlg.topwin.destroy() if not success: magicpopup.magicmsgbox(None, _('Load module failed.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) else: CF.G.reprobe_all_disks_required = 1 stepobj = self.rootobj.stepobj_list[self.rootobj.curstep + 1] # reprobe disk stepobj.reprobe_all() magicpopup.magicmsgbox(None, _('Load module success.'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) self.do_refresh_fill()
def do_modprobe(self, widget, data): (model, iter) = self.name_map['scsilist_treeview'].get_selection().get_selected() if not iter: magicpopup.magicmsgbox(None, _('Not any driver is selected.'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) return loaded = model.get_value(iter, 0) if loaded == self.get_pixbuf_map('images/yes.png'): magicpopup.magicmsgbox(None, _('The selected module has been loaded already.'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) return module = model.get_value(iter, 1) self.rootobj.tm.add_action(None, self.get_modprobe_result, module, 'do_modprobe', module) self.waitdlg = magicpopup.magicmsgbox(None, _('Please wait......'), magicpopup.magicmsgbox.MB_INFO, 0)
def gen_x_settings(self): self.fetch_values(self.rootobj.values) self.x_settings['monitor'] = ( self.get_data(self.values, 'Xwindow.monitor.name'), self.get_data(self.values, 'Xwindow.monitor.horiz_sync'), self.get_data(self.values, 'Xwindow.monitor.vert_refresh')) self.x_settings['videocard'] = ( self.get_data(self.values, 'Xwindow.videocard.name'), self.get_data(self.values, 'Xwindow.videocard.driver'), self.get_data(self.values, 'Xwindow.videocard.videoram')) self.x_settings['mouse'] = ( self.get_data(self.values, 'Xwindow.mouse.name'), self.get_data(self.values, 'Xwindow.mouse.protocol'), self.get_data(self.values, 'Xwindow.mouse.device'), self.get_data(self.values, 'Xwindow.mouse.xemu3'), self.get_data(self.values, 'Xwindow.mouse.shortname')) self.x_settings['modes'] = {} resmap = {640: '640x480', 800: '800x600', 1024: '1024x768', 1280: '1280x1024'} for depth in [8, 15, 16, 24]: for res in [1280, 1024, 800, 640]: if self.get_data(self.values, 'Xwindow.modes.m%dx%d' % (res, depth)) == 'true': self.x_settings['modes'].setdefault(str(depth), []).append(resmap[res]) # wide mode widemode_x = self.get_data(self.values, 'Xwindow.modes.widemode_x') widemode_y = self.get_data(self.values, 'Xwindow.modes.widemode_y') widemode_depth = self.get_data(self.values, 'Xwindow.modes.widemode_depth') widemode_refresh = self.get_data(self.values, 'Xwindow.modes.widemode_refresh') self.x_settings['wide_mode'] = (widemode_x, widemode_y, widemode_depth, widemode_refresh) print self.x_settings if len(widemode_x) != 0 and len(widemode_y) != 0: try: widemode_x = int(widemode_x) widemode_y = int(widemode_y) widemode_refresh = int(widemode_refresh) except ValueError, e: magicpopup.magicmsgbox(None, _('Widemode resolution or refresh rate error.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 self.x_settings['modes'].setdefault(widemode_depth, []).insert(0, "%dx%d" % (widemode_x, widemode_y))
def srcpos_ok_clicked(self, widget, data): (model, iter) = \ self.srcpos_dialog.name_map['srcposlist_treeview'].get_selection().get_selected() if iter: pafile = model.get_value(iter, 0) for patuple in CF.G.pkgarr_probe_result: if patuple[0] == pafile: break if self.tryload_file(patuple): self.srcpos_dialog.topwin.destroy() else: magicpopup.magicmsgbox( None, _('Load the choosed package arrangement failed!'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) else: magicpopup.magicmsgbox(None, _('Please choose one position.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK)
def do_modprobe(self, widget, data): (model, iter ) = self.name_map['scsilist_treeview'].get_selection().get_selected() if not iter: magicpopup.magicmsgbox(None, _('Not any driver is selected.'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) return loaded = model.get_value(iter, 0) if loaded == self.get_pixbuf_map('images/yes.png'): magicpopup.magicmsgbox( None, _('The selected module has been loaded already.'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) return module = model.get_value(iter, 1) self.rootobj.tm.add_action(None, self.get_modprobe_result, module, 'do_modprobe', module) self.waitdlg = magicpopup.magicmsgbox(None, _('Please wait......'), magicpopup.magicmsgbox.MB_INFO, 0)
def act_parted_format_result(self, tdata, data): result = tdata class CallBack(): def __init__(self, cb): self.cb = cb def ok_clicked(self, widget, data): self.cb() if result: # Error occurred. Stop it? # Yes, we should stop it, and we should stop at mount failed place too. # TOOD: we should give a stop option too. logger.info('format_result ERROR: %s\n' % str(result)) call_back = CallBack(lambda : self.act_parted_format_start(data + 1)) magicpopup.magicmsgbox(call_back, _('Format Partition Error: %s' % result), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) #self.rootobj.btnback_do() else: self.act_parted_format_start(data + 1)
def check_leave_root(self): self.fetch_values(self.rootobj.values) rootpwd = self.get_data(self.values, 'accounts.root.password') rootpwdconfirm = self.get_data(self.values, 'accounts.root.passwordconfirm') if rootpwd != rootpwdconfirm: magicpopup.magicmsgbox( None, _('Your root password is different with your root password confirmation!' ), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return 0 if len(rootpwd) < 3: magicpopup.magicmsgbox( None, _('Please do not use the password which shorter than 3 characters.' ), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return 0 return 1
def srcpos_ok_clicked(self, widget, data): (model, iter) = \ self.srcpos_dialogger.name_map['srcposlist_treeview'].get_selection().get_selected() if iter: pafile = model.get_value(iter, 0) for patuple in CF.G.pkgarr_probe_result: if patuple[0] == pafile: break if self.tryload_file(patuple): self.srcpos_dialogger.topwin.destroy() else: magicpopup.magicmsgbox(None, _('Load the choosed package arrangement failed!'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) else: magicpopup.magicmsgbox(None, _('Please choose one position.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK)
def check_leave_bootlist(self): self.fetch_values(self.rootobj.values) instpos = self.get_data(self.values, 'bootloader.instpos') win_device = self.get_data(self.values, 'bootloader.win_device') if win_device: for dev, os_type in CF.G.win_probe_result: if dev == win_device: break else: magicpopup.magicmsgbox(None, _('%s is not a Windows partition.') % win_device, magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 if instpos == 'win' and os_type != 'winnt': magicpopup.magicmsgbox(None, _('Cannot install grldr: %s does not contain ntldr.') % win_device, magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 elif instpos == 'win': magicpopup.magicmsgbox(None, _('Windows partition is empty.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 self.backup_entrylist() return 1
def enter(self): if CF.G.pkgarr_probe_status != STAT.OP_STATUS_DONE: magicpopup.magicmsgbox(None, _('Please wait a while for the search of package arrangement information.'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) return 0 if len(CF.G.pkgarr_probe_result) == 0: magicpopup.magicmsgbox(None, _('Not any package arrangement information can be found!\nPlease return to the parted step to check your setup.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 if len(CF.G.pkgarr_probe_result) > 1: dolog("CF.G.pkgarr_probe_result: %s" % CF.G.pkgarr_probe_result) popup = 'true' if self.pa_choose: for result in CF.G.pkgarr_probe_result: if self.pa_choose == result[0]: popup = None break if popup: self.popup_srcpos_dialog() else: if not self.tryload_file(CF.G.pkgarr_probe_result[0]): magicpopup.magicmsgbox(None, _('Load the only package arrangement failed!\nPlease return to the parted step to check your step.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 return 1
def check_leave_bootlist(self): self.fetch_values(self.rootobj.values) instpos = self.get_data(self.values, 'bootloader.instpos') win_device = self.get_data(self.values, 'bootloader.win_device') if win_device: for dev, os_type in CF.G.win_probe_result: if dev == win_device: break else: magicpopup.magicmsgbox( None, _('%s is not a Windows partition.') % win_device, magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 if instpos == 'win' and os_type != 'winnt': magicpopup.magicmsgbox( None, _('Cannot install grldr: %s does not contain ntldr.') % win_device, magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 elif instpos == 'win': magicpopup.magicmsgbox(None, _('Windows partition is empty.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 self.backup_entrylist() return 1
def enter(self): if CF.G.pkgarr_probe_status != STAT.OP_STATUS_DONE: magicpopup.magicmsgbox( None, _('Please wait a while for the search of package arrangement information.' ), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) return 0 if len(CF.G.pkgarr_probe_result) == 0: magicpopup.magicmsgbox( None, _('Not any package arrangement information can be found!\nPlease return to the parted step to check your setup.' ), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 if len(CF.G.pkgarr_probe_result) > 1: popup = True if self.pa_choose: for result in CF.G.pkgarr_probe_result: if self.pa_choose == result[0]: popup = False break if popup: self.popup_srcpos_dialog() else: if not self.tryload_file(CF.G.pkgarr_probe_result[0]): magicpopup.magicmsgbox( None, _('Load the only package arrangement failed!\nPlease return to the parted step to check your step.' ), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 return 1
def edit_entry(self, widget, data): (self.model, self.iter ) = self.name_map['bootlist_treeview'].get_selection().get_selected() if not self.iter: magicpopup.magicmsgbox(None, _('Please choose an entry to edit.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return label = self.model.get_value(self.iter, 1) device = self.model.get_value(self.iter, 2) default = self.model.get_value(self.iter, 3) self.edit_values = parseString( """<?xml version="1.0"?><data> <default>%s</default><o_default>%s</o_default> <label>%s</label><o_label>%s</o_label> <device>%s</device></data>""" % (default, default, label, label, device)) self.edit_dialog = magicpopup.magicpopup( self, self.uixmldoc, _('Edit a boot entry.'), magicpopup.magicpopup.MB_OK | magicpopup.magicpopup.MB_CANCEL, 'bootentry.dialog', 'edit_') self.edit_dialog.fill_values(self.edit_values.documentElement) self.edit_dialog.name_map[CF.G.root_device].set_text(device)
def edit_entry(self, widget, data): (self.model, self.iter) = self.name_map['bootlist_treeview'].get_selection().get_selected() if not self.iter: magicpopup.magicmsgbox(None, _('Please choose an entry to edit.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return label = self.model.get_value(self.iter, 1) device = self.model.get_value(self.iter, 2) default = self.model.get_value(self.iter, 3) self.edit_values = parseString( """<?xml version="1.0"?><data> <default>%s</default><o_default>%s</o_default> <label>%s</label><o_label>%s</o_label> <device>%s</device></data>""" % (default, default, label, label, device)) self.edit_dialog = magicpopup.magicpopup(self, self.uixmldoc, _('Edit a boot entry.'), magicpopup.magicpopup.MB_OK | magicpopup.magicpopup.MB_CANCEL, 'bootentry.dialog', 'edit_') self.edit_dialog.fill_values(self.edit_values.documentElement) self.edit_dialog.name_map[CF.G.root_device].set_text(device)
def enter(self): if CF.G.skipxsetting: if not self.gen_x_settings(): magicpopup.magicmsgbox( None, _('Failed to collect the information about Xwindow configuration.' ), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) # Continue anyway. #return 0 self.rootobj.tm.add_action(_('Generate Xwindow configuration'), None, None, 'gen_x_config', self.x_settings) self.rootobj.tm.add_action(_('Backup Xwindow configuration files'), None, None, 'backup_xconfig', 0) self.rootobj.btnback_sensitive(False) self.rootobj.btnnext_sensitive(False) dolog('action_accounts\n') rootpasswd = self.get_data(self.values, 'accounts.root.password') acclist = [] accnode = self.srh_data_node(self.values, 'accounts.userlist') for node in accnode.getElementsByTagName('row'): acclist.append(( node.getAttribute('c0'), # Username. node.getAttribute('c1'), # Password. node.getAttribute('c2'), # Shell. node.getAttribute('c3'), # Home directory. node.getAttribute('c4'))) # Real UID or 'Auto'. dolog('%s\n' % 'setup_accounts') #str(('setup_accounts', rootpasswd, acclist))) self.rootobj.tm.add_action(_('Setup accounts'), self.doshort, None, 'setup_accounts', rootpasswd, acclist) return 1
def act_parted_format_result(self, tdata, data): result = tdata class CallBack(): def __init__(self, cb): self.cb = cb def ok_clicked(self, widget, data): self.cb() if result: # Error occurred. Stop it? # Yes, we should stop it, and we should stop at mount failed place too. # TOOD: we should give a stop option too. logger.info('format_result ERROR: %s\n' % str(result)) call_back = CallBack( lambda: self.act_parted_format_start(data + 1)) magicpopup.magicmsgbox(call_back, _('Format Partition Error: %s' % result), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) #self.rootobj.btnback_do() else: self.act_parted_format_start(data + 1)
def ok_clicked(self, widget, data): self.accdlg.fetch_values(self.tmpdoc) username = self.get_data(self.tmpvalues, 'username') if username == '': magicpopup.magicmsgbox(None, _('Username is not specified.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return password = self.get_data(self.tmpvalues, 'password') confirmpassword = self.get_data(self.tmpvalues, 'confirm_password') if password != confirmpassword: magicpopup.magicmsgbox( None, _('Your password is different with your confirm password.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return if password == '': magicpopup.magicmsgbox( None, _('You can not login in this user directly because you leave the password to blank' ), magicpopup.magicmsgbox.MB_WARNING, magicpopup.magicmsgbox.MB_OK) self.accdlg.topwin.destroy() shell = self.get_data(self.tmpvalues, 'shell') homedir = self.get_data(self.tmpvalues, 'homedir') if homedir == 'true': homedir = self.get_data(self.tmpvalues, 'customhomedir') else: homedir = '/home/' + username uid = self.get_data(self.tmpvalues, 'uid') if uid == 'true': uid = str(int(float(self.get_data(self.tmpvalues, 'customuid')))) else: uid = 'Auto' newrow = self.rootobj.values.createElement('row') newrow.setAttribute('c0', username) newrow.setAttribute('c1', password) newrow.setAttribute('c2', shell) newrow.setAttribute('c3', homedir) newrow.setAttribute('c4', uid) if self.iter: self.list_replace('accounts.userlist', self.iter, newrow) else: self.list_append('accounts.userlist', newrow)
def ok_clicked(self, widget, data): self.accdlg.fetch_values(self.tmpdoc) username = self.get_data(self.tmpvalues, 'username') if username == '': magicpopup.magicmsgbox(None, _('Username is not specified.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return password = self.get_data(self.tmpvalues, 'password') confirmpassword = self.get_data(self.tmpvalues, 'confirm_password') if password != confirmpassword: magicpopup.magicmsgbox(None, _('Your password is different with your confirm password.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicmsgbox.MB_OK) return if password == '': magicpopup.magicmsgbox(None, _('You can not login in this user directly because you leave the password to blank'), magicpopup.magicmsgbox.MB_WARNING, magicpopup.magicmsgbox.MB_OK) self.accdlg.topwin.destroy() shell = self.get_data(self.tmpvalues, 'shell') homedir = self.get_data(self.tmpvalues, 'homedir') if homedir == 'true': homedir = self.get_data(self.tmpvalues, 'customhomedir') else: homedir = '/home/' + username uid = self.get_data(self.tmpvalues, 'uid') if uid == 'true': uid = str(int(float(self.get_data(self.tmpvalues, 'customuid')))) else: uid = _('Auto') newrow = self.rootobj.values.createElement('row') newrow.setAttribute('c0', username) newrow.setAttribute('c1', password) newrow.setAttribute('c2', shell) newrow.setAttribute('c3', homedir) newrow.setAttribute('c4', uid) if self.iter: self.list_replace('accounts.userlist', self.iter, newrow) else: self.list_append('accounts.userlist', newrow)
def info_dialog(self, msg): dlg = magicpopup.magicmsgbox(None, msg, magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) self.popup_dialog_list.append(dlg)
def leave(self): magicpopup.magicmsgbox( None, _('You can not go back because the installation has finished.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0
def err_dialog(self, msg): dlg = magicpopup.magicmsgbox(None, msg, magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) self.popup_dialog_list.append(dlg)
def leave(self): magicpopup.magicmsgbox(None, _('You can not go back because the installation has finished.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0
def info_dialog(self, msg): dlg = magicpopup.magicmsgbox(None, msg, magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) self.popup_dialog_list.append(dlg)
def warn_dialog(self, msg): dlg = magicpopup.magicmsgbox(None, msg, magicpopup.magicmsgbox.MB_WARNING, magicpopup.magicpopup.MB_OK) self.popup_dialog_list.append(dlg)
def err_dialog(self, msg): dlg = magicpopup.magicmsgbox(None, msg, magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) self.popup_dialog_list.append(dlg)
def warn_dialog(self, msg): dlg = magicpopup.magicmsgbox(None, msg, magicpopup.magicmsgbox.MB_WARNING, magicpopup.magicpopup.MB_OK) self.popup_dialog_list.append(dlg)
def gen_x_settings(self): self.fetch_values(self.rootobj.values) self.x_settings['monitor'] = (self.get_data(self.values, 'Xwindow.monitor.name'), self.get_data( self.values, 'Xwindow.monitor.horiz_sync'), self.get_data( self.values, 'Xwindow.monitor.vert_refresh')) self.x_settings['videocard'] = (self.get_data( self.values, 'Xwindow.videocard.name'), self.get_data( self.values, 'Xwindow.videocard.driver'), self.get_data( self.values, 'Xwindow.videocard.videoram')) self.x_settings['mouse'] = (self.get_data(self.values, 'Xwindow.mouse.name'), self.get_data(self.values, 'Xwindow.mouse.protocol'), self.get_data(self.values, 'Xwindow.mouse.device'), self.get_data(self.values, 'Xwindow.mouse.xemu3'), self.get_data(self.values, 'Xwindow.mouse.shortname')) self.x_settings['modes'] = {} resmap = { 640: '640x480', 800: '800x600', 1024: '1024x768', 1280: '1280x1024' } for depth in [8, 15, 16, 24]: for res in [1280, 1024, 800, 640]: if self.get_data(self.values, 'Xwindow.modes.m%dx%d' % (res, depth)) == 'true': self.x_settings['modes'].setdefault(str(depth), []).append(resmap[res]) # wide mode widemode_x = self.get_data(self.values, 'Xwindow.modes.widemode_x') widemode_y = self.get_data(self.values, 'Xwindow.modes.widemode_y') widemode_depth = self.get_data(self.values, 'Xwindow.modes.widemode_depth') widemode_refresh = self.get_data(self.values, 'Xwindow.modes.widemode_refresh') self.x_settings['wide_mode'] = (widemode_x, widemode_y, widemode_depth, widemode_refresh) print self.x_settings if len(widemode_x) != 0 and len(widemode_y) != 0: try: widemode_x = int(widemode_x) widemode_y = int(widemode_y) widemode_refresh = int(widemode_refresh) except ValueError, e: magicpopup.magicmsgbox( None, _('Widemode resolution or refresh rate error.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 self.x_settings['modes'].setdefault(widemode_depth, []).insert( 0, "%dx%d" % (widemode_x, widemode_y))
class MIStep_Xwindow(magicstep.magicstepgroup): NAME = 'Xwindow' LABEL = _("Xwindow") def __init__(self, rootobj): magicstep.magicstepgroup.__init__( self, rootobj, 'Xwindow.xml', ['monitor', 'videocard', 'mouse', 'misc'], 'steps') m = rhpxl.monitor.MonitorInfo() self.mondb = m.monitorsDB() self.x_settings = {} def get_label(self): return self.LABEL def startup_action(self): self.rootobj.tm.add_action(_('Probe Monitor'), self.probe_monitor_ok, None, 'probe_monitor', 0) self.rootobj.tm.add_action(_('Probe VideoCard'), self.probe_videocard_ok, None, 'probe_videocard', 0) self.rootobj.tm.add_action(_('Probe Mouse'), self.probe_mouse_ok, None, 'probe_mouse', 0) def check_leave_monitor(self): self.fetch_values(self.rootobj.values) return 1 def check_leave_videocard(self): self.fetch_values(self.rootobj.values) return 1 def check_leave_mouse(self): self.fetch_values(self.rootobj.values) return 1 def leave(self): if not magicstep.magicstepgroup.leave(self): return 0 if not self.gen_x_settings(): magicpopup.magicmsgbox( None, _('Failed to collect the information about Xwindow configuration.' ), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 self.rootobj.tm.add_action(_('Generate Xwindow configuration'), None, None, 'gen_x_config', self.x_settings) return 1 def reprobe_monitor(self, widget, data): self.rootobj.tm.add_action(_('Probe Monitor'), self.probe_monitor_ok, None, 'probe_monitor', 0) def reprobe_videocard(self, widget, data): self.rootobj.tm.add_action(_('Probe VideoCard'), self.probe_videocard_ok, None, 'probe_videocard', 0) def reprobe_mouse(self, widget, data): self.rootobj.tm.add_action(_('Probe Mouse'), self.probe_mouse_ok, None, 'probe_mouse', 0) def probe_monitor_ok(self, tdata, data): (m_name, m_horiz, m_vert) = tdata self.set_data(self.rootobj.values, 'Xwindow.monitor.name', m_name) self.set_data(self.rootobj.values, 'Xwindow.monitor.horiz_sync', m_horiz) self.set_data(self.rootobj.values, 'Xwindow.monitor.vert_refresh', m_vert) self.fill_values(self.rootobj.values.documentElement) def probe_videocard_ok(self, tdata, data): vclist = tdata if len(vclist) == 0 or len(vclist[0]) == 0: return (vc0name, vc0driver, vc0vidram) = vclist[0] self.set_data(self.rootobj.values, 'Xwindow.videocard.name', vc0name) self.set_data(self.rootobj.values, 'Xwindow.videocard.driver', vc0driver) self.set_data(self.rootobj.values, 'Xwindow.videocard.videoram', str(vc0vidram)) self.fill_values(self.rootobj.values.documentElement) def probe_mouse_ok(self, tdata, data): mouse = tdata (name, protocol, device, xemu3, shortname) = mouse self.set_data(self.rootobj.values, 'Xwindow.mouse.name', name) self.set_data(self.rootobj.values, 'Xwindow.mouse.protocol', protocol) self.set_data(self.rootobj.values, 'Xwindow.mouse.device', device) self.set_data(self.rootobj.values, 'Xwindow.mouse.xemu3', xemu3) self.set_data(self.rootobj.values, 'Xwindow.mouse.shortname', shortname) self.fill_values(self.rootobj.values.documentElement) def popup_monitor_dialog(self, widget, data): def xmlesc(s): s = string.replace(s, "&", "&") s = string.replace(s, "<", "<") s = string.replace(s, ">", ">") return s (model, iter) = self.name_map['monitor_vender_list_treeview'].get_selection( ).get_selected() if not iter: return vender = model.get_value(iter, 0) if not self.mondb.has_key(vender): return xmlstr = '' for (m_name, dummy, m_vert, m_horiz) in self.mondb[vender]: xmlstr = xmlstr + '<row c0="%s" c1="%s" c2="%s"/>' % ( xmlesc(m_name), xmlesc(m_horiz), xmlesc(m_vert)) xmldoc = parseString('<?xml version="1.0"?><data><monlist>' + xmlstr + '</monlist></data>') self.mondlg = magicpopup.magicpopup( self, self.uixmldoc, _("Please choose your monitor here."), magicpopup.magicpopup.MB_OK | magicpopup.magicpopup.MB_CANCEL, "monitor.dialog", "mondlg_") self.mondlg.topwin.set_size_request(600, 400) self.mondlg.fill_values(xmldoc.documentElement) def mondlg_ok_clicked(self, widget, data): (model, iter) = self.mondlg.name_map['monitor_list_treeview'].get_selection( ).get_selected() if not iter: return name = model.get_value(iter, 0) horiz_sync = model.get_value(iter, 1) vert_refresh = model.get_value(iter, 2) self.set_data(self.rootobj.values, 'Xwindow.monitor.name', name) self.set_data(self.rootobj.values, 'Xwindow.monitor.horiz_sync', horiz_sync) self.set_data(self.rootobj.values, 'Xwindow.monitor.vert_refresh', vert_refresh) self.fill_values(self.rootobj.values.documentElement) self.mondlg.topwin.destroy() def load_videocard(self, widget, data): (model, iter) = self.name_map['videocard_list_treeview'].get_selection( ).get_selected() if iter: name = model.get_value(iter, 0) driver = model.get_value(iter, 1) self.set_data(self.rootobj.values, 'Xwindow.videocard.name', name) self.set_data(self.rootobj.values, 'Xwindow.videocard.driver', driver) self.fill_values(self.rootobj.values.documentElement) def load_mouse(self, widget, data): (model, iter) = self.name_map['mouse_list_treeview'].get_selection( ).get_selected() if iter: name = model.get_value(iter, 0) protocol = model.get_value(iter, 1) device = model.get_value(iter, 2) xemu3 = model.get_value(iter, 3) self.set_data(self.rootobj.values, 'Xwindow.mouse.name', name) self.set_data(self.rootobj.values, 'Xwindow.mouse.protocol', protocol) self.set_data(self.rootobj.values, 'Xwindow.mouse.device', device) self.set_data(self.rootobj.values, 'Xwindow.mouse.xemu3', xemu3) self.fill_values(self.rootobj.values.documentElement) def test_x_settings(self, widget, data): if not self.gen_x_settings(): return self.rootobj.tm.add_action(_('Test X Settings'), self.test_x_settings_result, None, 'test_x_settings', self.x_settings) def test_x_settings_result(self, tdata, data): result = tdata print 'test_x_settings:', result if result == 'SUCCESS': magicpopup.magicmsgbox(None, _('Success!'), magicpopup.magicmsgbox.MB_INFO, magicpopup.magicpopup.MB_OK) else: magicpopup.magicmsgbox(None, _(result), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) def widemode_res_changed(self, optmenu, data): res_om = self.name_map["widemode_res_om"] val = self.optionmenu_map[res_om][1][res_om.get_active()] x, y = val.split('x') self.name_map["widemode_x_entry"].set_text(x) self.name_map["widemode_y_entry"].set_text(y) def gen_x_settings(self): self.fetch_values(self.rootobj.values) self.x_settings['monitor'] = (self.get_data(self.values, 'Xwindow.monitor.name'), self.get_data( self.values, 'Xwindow.monitor.horiz_sync'), self.get_data( self.values, 'Xwindow.monitor.vert_refresh')) self.x_settings['videocard'] = (self.get_data( self.values, 'Xwindow.videocard.name'), self.get_data( self.values, 'Xwindow.videocard.driver'), self.get_data( self.values, 'Xwindow.videocard.videoram')) self.x_settings['mouse'] = (self.get_data(self.values, 'Xwindow.mouse.name'), self.get_data(self.values, 'Xwindow.mouse.protocol'), self.get_data(self.values, 'Xwindow.mouse.device'), self.get_data(self.values, 'Xwindow.mouse.xemu3'), self.get_data(self.values, 'Xwindow.mouse.shortname')) self.x_settings['modes'] = {} resmap = { 640: '640x480', 800: '800x600', 1024: '1024x768', 1280: '1280x1024' } for depth in [8, 15, 16, 24]: for res in [1280, 1024, 800, 640]: if self.get_data(self.values, 'Xwindow.modes.m%dx%d' % (res, depth)) == 'true': self.x_settings['modes'].setdefault(str(depth), []).append(resmap[res]) # wide mode widemode_x = self.get_data(self.values, 'Xwindow.modes.widemode_x') widemode_y = self.get_data(self.values, 'Xwindow.modes.widemode_y') widemode_depth = self.get_data(self.values, 'Xwindow.modes.widemode_depth') widemode_refresh = self.get_data(self.values, 'Xwindow.modes.widemode_refresh') self.x_settings['wide_mode'] = (widemode_x, widemode_y, widemode_depth, widemode_refresh) print self.x_settings if len(widemode_x) != 0 and len(widemode_y) != 0: try: widemode_x = int(widemode_x) widemode_y = int(widemode_y) widemode_refresh = int(widemode_refresh) except ValueError, e: magicpopup.magicmsgbox( None, _('Widemode resolution or refresh rate error.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 self.x_settings['modes'].setdefault(widemode_depth, []).insert( 0, "%dx%d" % (widemode_x, widemode_y)) if len(self.x_settings['modes']) == 0: magicpopup.magicmsgbox(None, _('At least one mode has to be chosen.'), magicpopup.magicmsgbox.MB_ERROR, magicpopup.magicpopup.MB_OK) return 0 self.x_settings['init'] = self.get_data(self.values, 'Xwindow.init') self.x_settings['FontPathes'] = [] return 1