gnome_connection_manager.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:gnome-connection-manager 作者: mjun 项目源码 文件源码
def on_importar_servidores1_activate(self, widget, *args):
        filename = show_open_dialog(parent=self.wMain, title=_("Abrir"), action=gtk.FILE_CHOOSER_ACTION_OPEN)
        if filename != None:            
            password = inputbox(_('Importar Servidores'), _('Ingrese clave: '), password=True)
            if password == None:
                return                                                

            #abrir archivo con lista de servers y cargarlos en el arbol
            try:
                cp= ConfigParser.RawConfigParser( )
                cp.read( filename )

                #validar el pass
                s = decrypt(password, cp.get("gcm", "gcm"))
                if (s != password[::-1]):
                    msgbox(_("Clave invalida"))
                    return

                if msgconfirm(_(u'Se sobreescribirá la lista de servidores, continuar?')) != gtk.RESPONSE_OK:
                    return

                grupos={}
                for section in cp.sections():
                    if not section.startswith("host "):
                        continue                    
                    host = HostUtils.load_host_from_ini(cp, section, password)

                    if not grupos.has_key(host.group):                    
                        grupos[host.group]=[]  

                    grupos[host.group].append( host )
            except:                
                msgbox(_("Archivo invalido"))
                return
            #sobreescribir lista de hosts
            global groups
            groups=grupos

            self.updateTree()
    #-- Wmain.on_importar_servidores1_activate }

    #-- Wmain.on_exportar_servidores1_activate {
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号