当前位置: 首页>>代码示例>>Python>>正文


Python utils._函数代码示例

本文整理汇总了Python中mi.client.utils._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: try_format

 def try_format(devn, id_):
     # Wait for device block appear.
     fblk = False
     time.sleep(1)
     # We attemp to detect device file whether exists
     for trycnt in range(10):
         # os.path.exists cannot detect file exists real time
         #if os.path.exists(devn):
         if os.system('ls %s' % devn) == 0:
             fblk = True
             break
         else:
             time.sleep(1)
             
     if not fblk:
         msg = _('Not exists device block on %s: \ntry time: %d\n') % (devpath, trycnt)
         logger.w(msg)
         return msg
     else:
         logger.d('try_format %s ls device %s time' % (id_, trycnt))
     # Run command to format partition
     cmd_format = CF.D.FSTYPE_MAP[fstype][1]
     cmd_f_list = cmd_format.split()
     cmd = cmd_f_list[0]
     argv = cmd_f_list[1:]
     argv.append(devn)
     cmdres = run_bash(cmd, argv)
     logger.d('%s %s' % (cmd, ' '.join(argv)))
     logger.d(' '.join(cmdres['out']))
     if cmdres['ret'] != 0:
         errmsg = _('Run "%s %s" failed: %s\ntry time: %d\n')
         return  errmsg % ( cmd, ' '.join(argv), str(cmdres['err']), trycnt )
     else:
         return  0
开发者ID:MagicGroup,项目名称:magicinstaller2,代码行数:34,代码来源:partition.py

示例2: format_partition

def format_partition(mia, operid, devpath, part_start, fstype):
    logger.d('format_partition device: %s partition start: %s fstype: %s' % (devpath, part_start, fstype))
    mia.set_step(operid, 0, -1)
    if not CF.D.FSTYPE_MAP.has_key(fstype):
        errmsg = _('Unrecoginzed filesystem %s.')
        return errmsg % fstype
    if CF.D.FSTYPE_MAP[fstype][1] == '':
        errmsg = _('Format %s is not supported.')
        return errmsg % fstype
    if not CF.S.all_harddisks.has_key(devpath):
        return _('No such device: ') + devpath
    disk = CF.S.all_harddisks[devpath][1]
    if not disk:
        return _('Not any partition table found on: ') + devpath

    part = disk.getFirstPartition()
    while part:
        if part.geometry.start != part_start:
            part = part.nextPartition()
            continue
        if CF.D.FSTYPE_MAP[fstype][1] == 'internal':
            parted_fstype = parted.fileSystemType[revision_fstype(fstype)]
            try:
                part.getPedPartition().set_system(parted_fstype)
                logger.d('Create internal fstype %s on device %s partition start %s' % (fstype, devpath, part_start))
                part.fileSystem.create()
                disk.commit()
                logger.d('Create internal partition complete!')
            except NotImplementedError, errmsg:
                return  str(errmsg)
            except parted.DiskException as errmsg:
                return  str(errmsg)
            return  0
开发者ID:MagicGroup,项目名称:magicinstaller2,代码行数:33,代码来源:partition.py

示例3: __init__

    def __init__(self, sself, *args, **kw):
        gtk.HBox.__init__(self, *args, **kw)
        self.sself = sself
        
        self.logger = gtk.Button()
        self.logger.add(self.img_label_box('images/stock_help_24.png', _('Logger')))
        self.theme = gtk.Button()
        self.theme.add(self.img_label_box('images/gnome-ccthemes-24.png', _('Theme')))
        self.help = gtk.Button()
        self.help.add(self.img_label_box('images/stock_help_24.png', _('Help')))
        self.back = gtk.Button()
        self.back.add(self.img_label_box('images/stock_left_arrow_24.png', _('Back')))
        self.next = gtk.Button()
        self.next.add(self.img_label_box('images/stock_right_arrow_24.png', _('Next')))

        self.set_border_width(4)
        self.set_spacing(4)
        self.pack_start(self.logger, False, True)
        self.pack_start(self.theme, False, True)
        self.pack_start(self.help, False, True)
        
        self.pack_end(self.next, False, True)
        self.pack_end(self.back, False, True)
        
        self.logger.connect('clicked', self.on_logger_clicked, None)
        self.theme.connect('clicked', self.on_theme_clicked, None)
        self.help.connect('clicked', self.on_help_clicked, None)
        self.back.connect('clicked', self.on_back_clicked, None)
        self.next.connect('clicked', self.on_next_clicked, None)
开发者ID:kissthink,项目名称:magicinstaller2,代码行数:29,代码来源:buttonbar.py

示例4: remove_entry

 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)
开发者ID:MagicGroup,项目名称:magicinstaller2,代码行数:27,代码来源:bootloader.py

示例5: enter

    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
开发者ID:MagicGroup,项目名称:magicinstaller2,代码行数:33,代码来源:dosetup.py

示例6: check_leave_bootlist

 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
开发者ID:MagicGroup,项目名称:magicinstaller2,代码行数:29,代码来源:bootloader.py

示例7: act_instpkg_disc_start

 def act_instpkg_disc_start(self, tdata, disc_no):
     if tdata != 0:
         pass #### occur error, tdata is the error msg
     if self.discdlg_open_time > 0:
         # Do adjustment to omit the influence of replace disc.
         self.starttime = self.starttime + \
                          (time.time() - self.discdlg_open_time)
         self.discdlg_open_time = -1
     (pafile, dev, fstype, reldir, bootiso_relpath) =  CF.G.choosed_patuple
     while disc_no < len(CF.G.arrangement):
         if not self.install_allpkg and not self.disk_map.has_key(disc_no):
             # Skip the disc which is not needed.
             disc_no = disc_no + 1
             continue
         dolog("probe_all_disc_result: %s" % self.probe_all_disc_result)
         if disc_no >= len(self.probe_all_disc_result) \
                or not self.probe_all_disc_result[disc_no]:
             #### multi disc, whether it can get here???
             self.cur_disc_no = disc_no
             msgtxt = _("Can't find packages in disc %d.\nIf you are using CDROM to install system, it is the chance to eject the original disc and insert the %d disc.")
             msgtxt = msgtxt % (disc_no + 1, disc_no + 1)
             self.discdlg_open_time = time.time()
             DiscDialog(self, self.uixmldoc, msgtxt, 'disc.dialog')
             return
         bootiso_relpath = self.probe_all_disc_result[disc_no][0]
         self.add_action(None,
                         self.act_instpkg_pkg_start, (disc_no, 0),
                         'instpkg_disc_prep', dev, reldir, fstype, bootiso_relpath)
         return
     self.add_action(_('Last operations for package installation'),
                     self.nextop, None,
                     'instpkg_post', dev, reldir, fstype)
开发者ID:kissthink,项目名称:magicinstaller2,代码行数:32,代码来源:takeactions.py

示例8: check_leave_others

 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
开发者ID:kissthink,项目名称:magicinstaller2,代码行数:28,代码来源:accounts.py

示例9: enter

 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
开发者ID:kissthink,项目名称:magicinstaller2,代码行数:29,代码来源:pkgselect.py

示例10: startup_action

 def startup_action(self):
     self.rootobj.tm.add_action(_('Probe windows partition', None, None, 'pkgarr_probe', ''))
     
     CF.G.pkgarr_probe_status = STAT.OP_STATUS_DOING
     if not os.path.isdir(CF.G.path_allpa):
         os.makedirs(CF.G.path_allpa)
     self.rootobj.tm.add_action(_('Search package information'),
                                self.got_pkgarr_probe_result, None,
                                'pkgarr_probe', CF.G.all_orig_part)
开发者ID:kissthink,项目名称:magicinstaller2,代码行数:9,代码来源:pkgselect.py

示例11: startup_action

 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)
开发者ID:MagicGroup,项目名称:magicinstaller2,代码行数:10,代码来源:Xwindow.py

示例12: leave

 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
开发者ID:MagicGroup,项目名称:magicinstaller2,代码行数:11,代码来源:Xwindow.py

示例13: test_x_settings_result

 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)
开发者ID:MagicGroup,项目名称:magicinstaller2,代码行数:11,代码来源:Xwindow.py

示例14: act_start_mkinitrd

 def act_start_mkinitrd(self):
     self.tadlg.name_map['frame_other'].set_sensitive(True)
     self.rootobj.tm.push_progress(self.tadlg.name_map['otprog'],
                                   self.tadlg.name_map['otname'])
     scsi_module_list = self.get_data(self.values, 'scsi.modules')
     if scsi_module_list == None or scsi_module_list == '':
         dolog('No scsi driver has to be written into modprobe.conf.\n')
     else:
         dolog('scsi_modprobe_conf(%s)\n' % scsi_module_list)
         self.add_action(_("Generate modprobe.conf"), None, None,
                         'scsi_modprobe_conf', scsi_module_list)
     dolog('action_mkinitrd\n')
     self.add_action(_('Make initrd'), self.nextop, None, 'do_mkinitrd', 0)
开发者ID:kissthink,项目名称:magicinstaller2,代码行数:13,代码来源:takeactions.py

示例15: startup_action

 def startup_action(self):
     # If we skip X Setting, we should auto detect the hardware, and copy
     # the generated Xorg.conf to target system.
     if 0:#CF.G.skipxsetting:
         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)
开发者ID:MagicGroup,项目名称:magicinstaller2,代码行数:13,代码来源:dosetup.py


注:本文中的mi.client.utils._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。