Beispiel #1
0
def convert_pst(pstfile):
    """Convierte el archivo .pst que se le pasa y lo integra en Evolution"""
    if os.path.exists(pstfile):
        readpst = os.path.join(__DIR_PST2MBX__, 'readpst')
        account = os.path.splitext(os.path.split(pstfile)[1])[0]
        temp = folder(os.path.join('/tmp', account))
        dest = folder(
            os.path.join(os.path.expanduser('~'), '.evolution', 'mail',
                         'local'))
        com = '%s -w %s -o %s' % (readpst, pstfile.replace(
            ' ', "\ "), temp.path.replace(' ', "\ "))
        try:
            f = os.popen(com)
            if f.read().find("Outlook 2003 PST file") != -1:
                return "Encontrado PST de Outlook 2003"
        except:
            error("Failed to convert mailboxes")
        else:
            for mbox in os.listdir(temp.path):
                try:
                    mbox_size = os.stat(os.path.join(temp.path, mbox))[6]
                    if mbox_size:
                        shutil.copy2(
                            os.path.join(temp.path, mbox),
                            os.path.join(dest.path, account + ' - ' + mbox))
                except:
                    error("Failed to import mailboxes")
                    shutil.rmtree(temp.path)
	def get_mailbox(self, localdata):
		"""Importa y convierte los correos almacenados (OBSOLETO)"""
		pstpath = os.path.join(localdata,'Microsoft','Outlook')
		print pstpath
		if os.path.exists(pstpath):
			for e in os.listdir(pstpath):
				if e.find(self.get_account_name()) != -1:
					orig = os.path.join(pstpath, e)
					readpst = os.path.join(__DIR_PST2MBX__,'readpst')
					temp = folder(os.path.join('/tmp',e))
					dest = folder(os.path.join(os.path.expanduser('~'),'.evolution','mail','local'))
					com = '%s -w %s -o %s' % (readpst, orig.replace(' ',"\ "), temp.path.replace(' ',"\ "))
					try:
						os.system (com)
					except:
						error("Failed to convert mailboxes")
					else:
						for mbox in os.listdir(temp.path):
							try:
								mbox_size = os.stat(os.path.join(temp.path,mbox))[6]
								if mbox_size:
									shutil.copy2(os.path.join(temp.path,mbox), os.path.join(dest.path, self.get_account_name() + ' - ' + mbox))
							except:
								error("Failed to import mailboxes")
								shutil.rmtree(temp.path)
Beispiel #3
0
 def config_aMule(self):
     """Configura el programa de P2P aMule con la configuración del programa eMule en Windows"""
     amule = folder(os.path.join(os.path.expanduser('~'), '.aMule'))
     emule = folder(os.path.join(self.folders['eMule'].path, 'config'),
                    False)
     if amule and emule:
         # copy edonkey config files
         emule.copy(amule.path, extension=['.ini', '.dat', '.met'])
         # copy edonkey temporary files
         conf = os.path.join(amule.path, 'amule.conf')
         bak = backup(conf)
         try:
             emupref = open(os.path.join(amule.path, 'preferences.ini'),
                            'r')
             amuconf = open(conf, 'w')
             for l in emupref.readlines():
                 if l.find("IncomingDir") != -1:
                     l = "IncomingDir=%s\n" % os.path.join(
                         amule.path, 'Incoming')
                 if l.find("TempDir") != -1:
                     l = "TempDir=%s\n" % os.path.join(amule.path, 'Temp')
                 amuconf.write(l)
             amuconf.close()
             emupref.close()
         except:
             amuconf.close()
             emupref.close()
             if bak:
                 restore_backup(bak)
             self.error('Fallo al configurar aMule')
     else:
         self.error("aMule no ha sido configurado")
Beispiel #4
0
 def __init__(self):
     """Constructor de la clase"""
     self.errors = []
     self.config_file = os.path.join(os.path.expanduser('~'), '.kde',
                                     'share', 'config', 'kopeterc')
     folder(os.path.join(os.path.expanduser('~'), '.kde', 'share',
                         'config'))
Beispiel #5
0
 def get_mailbox(self, localdata):
     """Importa y convierte los correos almacenados (OBSOLETO)"""
     pstpath = os.path.join(localdata, 'Microsoft', 'Outlook')
     print pstpath
     if os.path.exists(pstpath):
         for e in os.listdir(pstpath):
             if e.find(self.get_account_name()) != -1:
                 orig = os.path.join(pstpath, e)
                 readpst = os.path.join(__DIR_PST2MBX__, 'readpst')
                 temp = folder(os.path.join('/tmp', e))
                 dest = folder(
                     os.path.join(os.path.expanduser('~'), '.evolution',
                                  'mail', 'local'))
                 com = '%s -w %s -o %s' % (readpst, orig.replace(
                     ' ', "\ "), temp.path.replace(' ', "\ "))
                 try:
                     os.system(com)
                 except:
                     error("Failed to convert mailboxes")
                 else:
                     for mbox in os.listdir(temp.path):
                         try:
                             mbox_size = os.stat(
                                 os.path.join(temp.path, mbox))[6]
                             if mbox_size:
                                 shutil.copy2(
                                     os.path.join(temp.path, mbox),
                                     os.path.join(
                                         dest.path,
                                         self.get_account_name() + ' - ' +
                                         mbox))
                         except:
                             error("Failed to import mailboxes")
                             shutil.rmtree(temp.path)
 def config_aMule(self):
     """Configura el programa de P2P aMule con la configuración del programa eMule en Windows"""
     amule = folder(os.path.join(os.path.expanduser("~"), ".aMule"))
     emule = folder(os.path.join(self.folders["eMule"].path, "config"), False)
     if amule and emule:
         # copy edonkey config files
         emule.copy(amule.path, extension=[".ini", ".dat", ".met"])
         # copy edonkey temporary files
         conf = os.path.join(amule.path, "amule.conf")
         bak = backup(conf)
         try:
             emupref = open(os.path.join(amule.path, "preferences.ini"), "r")
             amuconf = open(conf, "w")
             for l in emupref.readlines():
                 if l.find("IncomingDir") != -1:
                     l = "IncomingDir=%s\n" % os.path.join(amule.path, "Incoming")
                 if l.find("TempDir") != -1:
                     l = "TempDir=%s\n" % os.path.join(amule.path, "Temp")
                 amuconf.write(l)
             amuconf.close()
             emupref.close()
         except:
             amuconf.close()
             emupref.close()
             if bak:
                 restore_backup(bak)
             self.error("Fallo al configurar aMule")
     else:
         self.error("aMule no ha sido configurado")
 def import_eMule_files(self):
     """Importa los archivos descargados con eMule"""
     amule = folder(os.path.join(os.path.expanduser("~"), ".aMule"))
     amule_inc = folder(os.path.join(amule.path, "Incoming"))
     emule_inc = self.get_incoming_path()
     if amule and emule_inc and amule_inc:
         # copy edonkey downloaded files
         emule_inc.copy(amule_inc.path)
     else:
         self.error("Archivos Descargados de eMule no copiados")
 def import_eMule_temp(self):
     """Importa los archivos temporales con eMule"""
     amule = folder(os.path.join(os.path.expanduser("~"), ".aMule"))
     amule_temp = folder(os.path.join(amule.path, "Temp"))
     emule_temp = self.get_temp_path()
     if amule and emule_temp and amule_temp:
         # copy edonkey temporary files
         emule_temp.copy(amule_temp.path, extension=[".part", ".met", ",part.met"])
     else:
         self.error("Archivos Temporales de eMule no copiados")
Beispiel #9
0
 def import_eMule_files(self):
     """Importa los archivos descargados con eMule"""
     amule = folder(os.path.join(os.path.expanduser('~'), '.aMule'))
     amule_inc = folder(os.path.join(amule.path, 'Incoming'))
     emule_inc = self.get_incoming_path()
     if amule and emule_inc and amule_inc:
         # copy edonkey downloaded files
         emule_inc.copy(amule_inc.path)
     else:
         self.error("Archivos Descargados de eMule no copiados")
Beispiel #10
0
 def import_eMule_temp(self):
     """Importa los archivos temporales con eMule"""
     amule = folder(os.path.join(os.path.expanduser('~'), '.aMule'))
     amule_temp = folder(os.path.join(amule.path, 'Temp'))
     emule_temp = self.get_temp_path()
     if amule and emule_temp and amule_temp:
         # copy edonkey temporary files
         emule_temp.copy(amule_temp.path,
                         extension=['.part', '.met', ',part.met'])
     else:
         self.error("Archivos Temporales de eMule no copiados")
Beispiel #11
0
	def __init__(self):
		"""Constructor de la clase"""
		self.errors = []
		self.config_file = os.path.join(os.path.expanduser('~'), '.gaim', 'accounts.xml')
		if not os.path.exists(self.config_file):
			folder(os.path.join(os.path.expanduser("~"),'.gaim'))
			try:
				f = open (self.config_file, "w")
				f.write('<?xml version=\'1.0\' encoding=\'UTF-8\' ?>\n')
				f.write('<account version=\'1.0\'>\n')
				f.write('</account>')
				f.close()
			except:
				self.error('Failed to create %s' % config_file)
				return 0
	def __init__(self):
		"""Constructor de la clase"""
		self.errors = []
		self.config_file = os.path.join(os.path.expanduser('~'), '.gaim', 'accounts.xml')
		if not os.path.exists(self.config_file):
			folder(os.path.join(os.path.expanduser("~"),'.gaim'))
			try:
				f = open (self.config_file, "w")
				f.write('<?xml version=\'1.0\' encoding=\'UTF-8\' ?>\n')
				f.write('<account version=\'1.0\'>\n')
				f.write('</account>')
				f.close()
			except:
				self.error('Failed to create %s' % config_file)
				return 0
	def get_user_folders(self):
		"""Devuelve las carpetas de archivos, confifguraciones y programas del usuario"""
		r = self.search_key("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
		e = self.search_key("Software\eMule")
		w =  self.search_key("Control Panel\Desktop")
		if e:
			r["eMule"] = e["Install Path"]
		if w:
			r["Wallpaper"] = w["Wallpaper"]
		if r:
			self.mount_points = search_win_units(r)
			print "\nGetting shell folders..."
			for k, v in r.iteritems():
				if v:
					unit = v[:2]
					try:
						if not k == 'Wallpaper':
							r[k] = folder(v.replace(unit, self.mount_points[unit]), False)
							print "%s: %s --> %s" % (k, v, r[k].path)
						else:
							r[k] = v.replace(unit, self.mount_points[unit])
							print "%s: %s --> %s" % (k, v, r[k])
						
					except:
						r = 0
						print "Unknown partition: %s" % unit
						break
			print "\n"		
			return r
Beispiel #14
0
    def get_user_folders(self):
        """Devuelve las carpetas de archivos, confifguraciones y programas del usuario"""
        r = self.search_key(
            "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
        e = self.search_key("Software\eMule")
        w = self.search_key("Control Panel\Desktop")
        if e:
            r["eMule"] = e["Install Path"]
        if w:
            r["Wallpaper"] = w["Wallpaper"]
        if r:
            self.mount_points = search_win_units(r)
            print "\nGetting shell folders..."
            for k, v in r.iteritems():
                if v:
                    unit = v[:2]
                    try:
                        if not k == 'Wallpaper':
                            r[k] = folder(
                                v.replace(unit, self.mount_points[unit]),
                                False)
                            print "%s: %s --> %s" % (k, v, r[k].path)
                        else:
                            r[k] = v.replace(unit, self.mount_points[unit])
                            print "%s: %s --> %s" % (k, v, r[k])

                    except:
                        r = 0
                        print "Unknown partition: %s" % unit
                        break
            print "\n"
            return r
 def get_messenger_accounts(self):
     """Devuelve las cuentas de mensajería de Windows Live Messenger"""
     accounts = []
     live_msn = folder(os.path.join(self.folders["Local AppData"].path, "Microsoft", "Messenger"), False)
     if live_msn.path and os.path.exists(live_msn.path):
         for m in os.listdir(live_msn.path):
             if m.find("@") != -1:
                 accounts.append(m)
     return accounts
def convert_dbx(dbxfile):
	"""Convierte el archivo .dbx que se le pasa y lo integra en Evolution"""
	if os.path.exists(dbxfile):
		readdbx = os.path.join(__DIR_DBX2MBX__,'readoe')
		dest = folder(os.path.join(os.path.expanduser('~'),'.evolution','mail','local'))
		com = '%s -i %s -o %s' % (readdbx, os.path.split(dbxfile)[0].replace(' ',"\ "),dest.path)
		try:
			os.system (com)
		except:
			error("Failed to convert mailboxes")
Beispiel #17
0
 def get_messenger_accounts(self):
     """Devuelve las cuentas de mensajería de Windows Live Messenger"""
     accounts = []
     live_msn = folder(
         os.path.join(self.folders['Local AppData'].path, 'Microsoft',
                      'Messenger'), False)
     if live_msn.path and os.path.exists(live_msn.path):
         for m in os.listdir(live_msn.path):
             if m.find('@') != -1:
                 accounts.append(m)
     return accounts
Beispiel #18
0
def convert_dbx(dbxfile):
    """Convierte el archivo .dbx que se le pasa y lo integra en Evolution"""
    if os.path.exists(dbxfile):
        readdbx = os.path.join(__DIR_DBX2MBX__, 'readoe')
        dest = folder(
            os.path.join(os.path.expanduser('~'), '.evolution', 'mail',
                         'local'))
        com = '%s -i %s -o %s' % (readdbx, os.path.split(dbxfile)[0].replace(
            ' ', "\ "), dest.path)
        try:
            os.system(com)
        except:
            error("Failed to convert mailboxes")
def convert_pst(pstfile):
	"""Convierte el archivo .pst que se le pasa y lo integra en Evolution"""
	if os.path.exists(pstfile):
		readpst = os.path.join(__DIR_PST2MBX__,'readpst')
		account = os.path.splitext(os.path.split(pstfile)[1])[0]
		temp = folder(os.path.join('/tmp',account))
		dest = folder(os.path.join(os.path.expanduser('~'),'.evolution','mail','local'))
		com = '%s -w %s -o %s' % (readpst, pstfile.replace(' ',"\ "), temp.path.replace(' ',"\ "))
		try:
			f = os.popen (com)
			if f.read().find("Outlook 2003 PST file") != -1:
				return "Encontrado PST de Outlook 2003"
		except:
			error("Failed to convert mailboxes")
		else:
			for mbox in os.listdir(temp.path):
				try:
					mbox_size = os.stat(os.path.join(temp.path,mbox))[6]
					if mbox_size:
						shutil.copy2(os.path.join(temp.path,mbox), os.path.join(dest.path, account + ' - ' + mbox))
				except:
					error("Failed to import mailboxes")
					shutil.rmtree(temp.path)
	def __init__(self,folders):
		"""Contructor de la clase.
		Recibe un diccionario con las rutas obtenidas del registro"""
		webbrowser.__init__(self, folders)
		konqueror = folder(os.path.join(os.path.expanduser('~'),'.kde','share','apps','konqueror'))
		self.bookmarks_file = os.path.join(konqueror.path,'bookmarks.xml')
		#create bookmark.xml if not exists
		if not os.path.exists(self.bookmarks_file):
			try:
				b = open(self.bookmarks_file, 'w')
				b.write ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE xbel>\n<xbel>\n</xbel>")
				b.close()
			except:
				self.error("Unable to create bookmarks.xml for Konqueror")
 def get_incoming_path(self):
     """Devuelve la ruta del directorio de descargas"""
     try:
         a = open(os.path.join(self.folders["eMule"].path, "config", "preferences.ini"), "r")
         l = " "
         inc = os.path.join(self.folders["eMule"].path, "Incoming")
         for l in a.readlines():
             l = l.replace("\r\n", "")
             if l.find("IncomingDir") != -1:
                 inc = l.split("=")[1]
                 inc = inc.replace("\\", "/")
                 inc = self.mount_points[inc[:2]] + inc[2:]
                 a.close()
                 return folder(inc)
     except:
         self.error("Failed to detect eMule paths")
         a.close()
 def get_temp_path(self):
     """Devuelve la ruta del directorio de temporales"""
     try:
         a = open(os.path.join(self.folders["eMule"].path, "config", "preferences.ini"), "r")
         l = " "
         temp = os.path.join(self.folders["eMule"].path, "Temp")
         for l in a.readlines():
             l = l.replace("\r\n", "")
             if l.find("TempDir") != -1:
                 temp = l.split("=")[1]
                 temp = temp.replace("\\", "/")
                 temp = self.mount_points[temp[:2]] + temp[2:]
                 a.close()
                 return folder(temp)
     except:
         self.error("Failed to detect eMule paths")
         a.close()
Beispiel #23
0
    def __init__(self, folders):
        """Contructor de la clase.
		Recibe un diccionario con las rutas obtenidas del registro"""
        webbrowser.__init__(self, folders)
        konqueror = folder(
            os.path.join(os.path.expanduser('~'), '.kde', 'share', 'apps',
                         'konqueror'))
        self.bookmarks_file = os.path.join(konqueror.path, 'bookmarks.xml')
        #create bookmark.xml if not exists
        if not os.path.exists(self.bookmarks_file):
            try:
                b = open(self.bookmarks_file, 'w')
                b.write(
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE xbel>\n<xbel>\n</xbel>"
                )
                b.close()
            except:
                self.error("Unable to create bookmarks.xml for Konqueror")
	def import_windows_settings(self, AppData):
		"""Importa la configuración de Thunderbird en Windows. SOBREESCRIBE LA INFORMACIÓN EXISTENTE"""
		winprofile = folder(self.get_thunderbird_profile(os.path.join(AppData, 'Thunderbird')))
		if winprofile:
			# copy all files from the winprofile
			winprofile.copy(self.profile)
			# modify prefs.js
			try:
				wp = open (os.path.join(winprofile.path, 'prefs.js'), 'r')
				p = open (self.config_file, 'w')
				for l in wp.readlines():
					if l.find(':\\') == -1:
						p.write(l)
			except:
				self.error("Failed to copy Thunderbird profile")
			wp.close()
			p.close()
		return 0
Beispiel #25
0
 def get_incoming_path(self):
     """Devuelve la ruta del directorio de descargas"""
     try:
         a = open(
             os.path.join(self.folders['eMule'].path, 'config',
                          'preferences.ini'), 'r')
         l = " "
         inc = os.path.join(self.folders['eMule'].path, 'Incoming')
         for l in a.readlines():
             l = l.replace('\r\n', '')
             if l.find("IncomingDir") != -1:
                 inc = l.split('=')[1]
                 inc = inc.replace('\\', '/')
                 inc = self.mount_points[inc[:2]] + inc[2:]
                 a.close()
                 return folder(inc)
     except:
         self.error("Failed to detect eMule paths")
         a.close()
Beispiel #26
0
 def get_temp_path(self):
     """Devuelve la ruta del directorio de temporales"""
     try:
         a = open(
             os.path.join(self.folders['eMule'].path, 'config',
                          'preferences.ini'), 'r')
         l = " "
         temp = os.path.join(self.folders['eMule'].path, 'Temp')
         for l in a.readlines():
             l = l.replace('\r\n', '')
             if l.find("TempDir") != -1:
                 temp = l.split('=')[1]
                 temp = temp.replace('\\', '/')
                 temp = self.mount_points[temp[:2]] + temp[2:]
                 a.close()
                 return folder(temp)
     except:
         self.error("Failed to detect eMule paths")
         a.close()
Beispiel #27
0
 def import_windows_settings(self, AppData):
     """Importa la configuración de Thunderbird en Windows. SOBREESCRIBE LA INFORMACIÓN EXISTENTE"""
     winprofile = folder(
         self.get_thunderbird_profile(os.path.join(AppData, 'Thunderbird')))
     if winprofile:
         # copy all files from the winprofile
         winprofile.copy(self.profile)
         # modify prefs.js
         try:
             wp = open(os.path.join(winprofile.path, 'prefs.js'), 'r')
             p = open(self.config_file, 'w')
             for l in wp.readlines():
                 if l.find(':\\') == -1:
                     p.write(l)
         except:
             self.error("Failed to copy Thunderbird profile")
         wp.close()
         p.close()
     return 0
	def __init__(self):
		"""Constructor de la clase"""
		thunderbird = folder(os.path.join(os.path.expanduser('~'),'.mozilla-thunderbird'))
		self.profile = self.get_thunderbird_profile(thunderbird.path)
		self.errors = []
		if not self.profile and thunderbird.path:
			try:
				prof = open(os.path.join(thunderbird.path,'profiles.ini'), 'w')
				prof.write("[General]\n")
				prof.write("StartWithLastProfile=1\n\n")
				prof.write("[Profile0]\n")
				prof.write("Name=migrated\n")
				prof.write("IsRelative=1\n")
				prof.write("Path=m1gra73d.default\n")
				prof.close()
				self.profile = thunderbird.create_subfolder("m1gra73d.default")
			except:
				self.error("Unable to create Mozilla Thunderbird profile")
				return 0
		self.config_file  = os.path.join(self.get_thunderbird_profile(thunderbird.path), 'prefs.js')
	def __init__(self,folders):
		"""Contructor de la clase.
		Recibe un diccionario con las rutas obtenidas del registro"""
		webbrowser.__init__(self, folders)
		firefox = folder(os.path.join(os.path.expanduser('~'),'.mozilla','firefox'))
		if not os.path.exists(os.path.join(firefox.path, 'profiles.ini')) and firefox:
			try:
				prof = open(os.path.join(firefox.path,'profiles.ini'), 'w')
				prof.write("[General]\n")
				prof.write("StartWithLastProfile=1\n\n")
				prof.write("[Profile0]\n")
				prof.write("Name=migrated\n")
				prof.write("IsRelative=1\n")
				prof.write("Path=m1gra73d.default\n")
				prof.close()
				path_profile = firefox.create_subfolder("m1gra73d.default")
				shutil.copy('/etc/firefox/profile/bookmarks.html',path_profile)
			except:
				self.error("Unable to create Mozilla Firefox profile")
				return 0
		self.bookmarks_file = self.get_firefox_bookmarks('linux')
Beispiel #30
0
 def __init__(self):
     """Constructor de la clase"""
     thunderbird = folder(
         os.path.join(os.path.expanduser('~'), '.mozilla-thunderbird'))
     self.profile = self.get_thunderbird_profile(thunderbird.path)
     self.errors = []
     if not self.profile and thunderbird.path:
         try:
             prof = open(os.path.join(thunderbird.path, 'profiles.ini'),
                         'w')
             prof.write("[General]\n")
             prof.write("StartWithLastProfile=1\n\n")
             prof.write("[Profile0]\n")
             prof.write("Name=migrated\n")
             prof.write("IsRelative=1\n")
             prof.write("Path=m1gra73d.default\n")
             prof.close()
             self.profile = thunderbird.create_subfolder("m1gra73d.default")
         except:
             self.error("Unable to create Mozilla Thunderbird profile")
             return 0
     self.config_file = os.path.join(
         self.get_thunderbird_profile(thunderbird.path), 'prefs.js')
Beispiel #31
0
def msn2amsn(cuenta):
    """Configura la cuenta de MSN que se le pasa en aMSN"""
    destino = folder(os.path.join(os.path.expanduser("~"), '.amsn'))
    if destino:
        if os.path.exists(os.path.join(destino.path, 'profiles')):
            bak = backup(os.path.join(destino.path, 'profiles'))
            try:
                f = open(os.path.join(destino.path, 'profiles'), "a")
                #insert at the bottom, the program automatically will reorder the file
                f.write(cuenta + ' 0\n')
                f.close()
            except:
                f.close()
                error("Config aMSN failed")
                restore_backup(bak)
        else:
            try:
                f = open(os.path.join(destino.path, 'profiles'), "w")
                f.write('amsn_profiles_version 1\n')
                f.write(cuenta + ' 0\n')
                f.close()
            except:
                f.close()
                error("Config aMSN failed")
Beispiel #32
0
    def __init__(self, folders):
        """Contructor de la clase.
		Recibe un diccionario con las rutas obtenidas del registro"""
        webbrowser.__init__(self, folders)
        firefox = folder(
            os.path.join(os.path.expanduser('~'), '.mozilla', 'firefox'))
        if not os.path.exists(os.path.join(firefox.path,
                                           'profiles.ini')) and firefox:
            try:
                prof = open(os.path.join(firefox.path, 'profiles.ini'), 'w')
                prof.write("[General]\n")
                prof.write("StartWithLastProfile=1\n\n")
                prof.write("[Profile0]\n")
                prof.write("Name=migrated\n")
                prof.write("IsRelative=1\n")
                prof.write("Path=m1gra73d.default\n")
                prof.close()
                path_profile = firefox.create_subfolder("m1gra73d.default")
                shutil.copy('/etc/firefox/profile/bookmarks.html',
                            path_profile)
            except:
                self.error("Unable to create Mozilla Firefox profile")
                return 0
        self.bookmarks_file = self.get_firefox_bookmarks('linux')
def msn2amsn(cuenta):
	"""Configura la cuenta de MSN que se le pasa en aMSN"""
	destino = folder(os.path.join(os.path.expanduser("~"),'.amsn'))
	if destino:
		if os.path.exists(os.path.join(destino.path, 'profiles')):
			bak = backup(os.path.join(destino.path, 'profiles'))
			try:
				f = open (os.path.join(destino.path, 'profiles'), "a")
				#insert at the bottom, the program automatically will reorder the file
				f.write(cuenta + ' 0\n')
				f.close()
			except:
				f.close()
				error("Config aMSN failed")
				restore_backup(bak)
		else:
			try:
				f = open (os.path.join(destino.path, 'profiles'), "w")
				f.write('amsn_profiles_version 1\n')
				f.write(cuenta + ' 0\n')
				f.close()
			except:
				f.close()
				error("Config aMSN failed")
def import_fonts(fontsdir):
	"""Copia las fuentes ttf del directorio que se le pasa"""
	dest = folder(os.path.join(os.path.expanduser('~'),'.fonts','ttf-windows'))
	fontsdir.copy(dest.path, '.ttf')
	def __init__(self):
		"""Constructor de la interfaz"""
		self.previous_excepthook = sys.excepthook
        	sys.excepthook = self.excepthook
		
		# Main Window
		self.window = gtk.Window()
		self.window.set_title(_("Asistente de Migración a Guadalinex"))
		self.window.set_default_size(700, 570)
		self.window.set_border_width(0)
		self.window.move(150, 50)
		self.window.connect("destroy", self.destroy)
		self.window.set_icon_from_file(os.path.join(dir_imagenes, "icon_paginacion.png"))
		#self.window.set_icon_from_file('/home/fernando/Desktop/paquetes/amigu-0.5.3/imagenes/icon_paginacion.gif')
		# Atributos
		self.paso = 1
		self.usuarios = {}
		self.selected_user = None
		self.resumen = []
		self.tasks = []
		self.detalles = ""
		self.url = "http://forja.guadalinex.org/webs/amigu/"
		self.watch = gtk.gdk.Cursor(gtk.gdk.WATCH)
		gtk.about_dialog_set_url_hook(self.open_url, self.url)
		try:
			gtk.link_button_set_uri_hook(self.open_url, self.url)
		except:
			print _("Está usando una versión anterior a python-gtk2 2.10")
		# ventana principal
		contenedor = gtk.VBox(False, 1)#Creo la caja vertical principal
		self.inicio = gtk.VBox(False, 1)
		self.segunda = gtk.VBox(False, 1)
		self.tercera = gtk.HBox(False, 1)
		self.cuarta = gtk.VBox(False, 1)
		self.quinta = gtk.VBox(False, 1)
		separador1 = gtk.HSeparator()
		separador2 = gtk.HSeparator()
		self.tooltips = gtk.Tooltips()
		principal = gtk.HBox(False, 1)#Creo lo que se va a quedar siempre en la ventana
		principal0 = gtk.HBox(False, 1)#Creo lo que se va a quedar siempre en la ventana
		principal1 = gtk.VBox(False, 1)#Creo lo que va a ir variando
		principal2 = gtk.HBox(False, 1)#Creo lo que se va a quedar siempre en la ventana
		principal2ver1 = gtk.HBox(False, 1)
		principal2ver2 = gtk.HBox(True, 1)
		principal2ver2.set_size_request(550,60)
		principal2ver2.set_border_width(10)
		image = gtk.Image()
		image.set_from_file(os.path.join(dir_imagenes, "cab_amigu.png"))
		#image.set_from_file('/home/fernando/Desktop/paquetes/amigu-0.5.3/imagenes/cab_amigu.jpg')
		image1 = gtk.Image()
		image1.set_from_file(os.path.join(dir_imagenes, "icon_paginacion.png"))
		#image1.set_from_file('/home/fernando/Desktop/paquetes/amigu-0.5.3/imagenes/icon_paginacion.gif')

		# botones
		self.boton = gtk.Button(stock = gtk.STOCK_CANCEL)
		self.boton1 = gtk.Button(stock = gtk.STOCK_GO_BACK)
		self.boton2 = gtk.Button(stock = gtk.STOCK_GO_FORWARD)
		self.boton3 = gtk.Button(stock = gtk.STOCK_APPLY)
		self.boton4 = gtk.Button(stock = gtk.STOCK_QUIT)
		self.boton5 = gtk.Button(label=_("Acerca de"))
		
		self.etapa = gtk.Label()
		self.etapa.set_use_markup(True)
		self.etapa.set_markup("<span face = \"arial\" size = \"8000\" foreground = \"chocolate\"><b>Paso %d de 5</b></span>"%self.paso)

		# añadir
		self.labelpri = gtk.Label("")
		espacio = gtk.Label()
		self.labelpri.set_line_wrap(True)
		self.labelpri.set_justify(gtk.JUSTIFY_LEFT)
		self.labelpri.set_use_markup(True)
		principal.pack_start(image, False, False, 0)
		principal0.pack_start(self.labelpri, False, False, 10)
		principal1.pack_start(self.inicio, True, False, 0)
		principal2.pack_start(principal2ver1, False, False, 0)
		principal2.pack_start(principal2ver2, True, False, 0)
		principal2ver1.pack_start(image1, True, True, 0)
		principal2ver1.pack_start(self.etapa, False, False, 1)
		principal2ver2.pack_start(self.boton1, False, False, 0)
		principal2ver2.pack_start(self.boton2, False, False, 0)
		principal2ver2.pack_start(self.boton3, False, False, 0)
		principal2ver2.pack_start(self.boton4, False, False, 0)
		principal2ver2.pack_start(self.boton5, False, False, 0)
		principal2ver2.pack_start(espacio, True, True, 2)
		principal2ver2.pack_start(self.boton, True, False, 5)
		contenedor.pack_start(principal, False, False, 1)
		contenedor.pack_start(separador1, False, True, 10)
		contenedor.pack_start(principal0, False, False, 1)
		contenedor.pack_start(principal1, True, True, 1)
		contenedor.pack_start(separador2, False, True, 10)
		contenedor.pack_start(principal2, False, True, 1)
		principal1.pack_start(self.segunda, True, False, 1)
		principal1.pack_start(self.tercera, True, False, 1)
		principal1.pack_start(self.cuarta, True, False, 1)
		principal1.pack_start(self.quinta, True, False, 1)
		self.window.add(contenedor)#Añado a la ventana el contenedor
		
		# eventos
		self.boton1.connect("clicked", self.etapa_anterior)
		self.boton2.connect("clicked", self.etapa_siguiente)
		self.boton3.connect("clicked", self.dialogo_confirmacion)
		self.boton4.connect("clicked", self.destroy)
		self.boton.connect_object("clicked", self.dialogo_cancelacion, self.window)
		self.boton5.connect_object("clicked", self.about, self.window)
		
		# mostrar ventana
		self.window.show_all()
		self.boton3.hide()
		self.boton4.hide()


################Primera Ventana	

		# crear
		label1 = gtk.Label()
		label1.set_use_markup(True)
		label1.set_line_wrap(True)
		label1.set_justify(gtk.JUSTIFY_CENTER)
		label1.set_markup('<b>'+_('Bienvenido al Asistente de MIgración de GUadalinex - AMIGU') + '\n\n' + _('Este asistente le guiará durante el proceso de migración de sus documentos y configuraciones de su sistema operativo Windows.') + '\n' + _('Pulse el botón Adelante para comenzar.') + '</b>')

		# añadir
		self.inicio.pack_start(label1, True, True, 10)
		
		# mostrar
		self.boton1.hide_all()
		self.inicio.show_all()


################Segunda Ventana

		#crear
		self.segundahor1 = gtk.HBox(False, 10)
		self.segundahor2 = gtk.HBox(False, 10)
		label2 = gtk.Label()
		label2.set_use_markup(True)
		label2.set_markup('<b>'+_('Seleccione uno de los usuarios de Windows')+'</b>')
		frame1 = gtk.Frame(_("Información"))
		sw = gtk.ScrolledWindow()
		sw.set_size_request(600, 175)
		sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		textview = gtk.TextView()
		textview.set_editable(False)
		self.textbuffer = textview.get_buffer()
		self.combo = gtk.combo_box_new_text()
		self.combo.append_text(_('Usuarios de Windows:'))
		self.combo.set_active(0)
		self.combo.connect("changed", self.actualizar_info)
		

		# añadir
		sw.add(textview)
		frame1.add(sw)
		self.segundahor1.pack_start(label2, False, True, 10)
		self.segundahor1.pack_start(self.combo, False, False, 10)
		self.segundahor2.pack_start(frame1, True, True, 10)
		self.segunda.pack_start(self.segundahor2, True, False, 10)
		self.segunda.pack_start(self.segundahor1, True, True, 10)
		
	


###############################Tercera Ventana

		# crear
		self.terceraver1 = gtk.HBox(False, 10)
		self.terceraver2 = gtk.HBox(False, 10)
		self.tercerahor1 = gtk.VBox(False, 10)
		self.tercerahor2 = gtk.VBox(False, 10)
		frame2 = gtk.Frame(_("Destino"))
		self.entry = gtk.Entry()
		self.entry.set_max_length(50)
		f = folder(os.path.expanduser('~'))
		self.required_space = 0
		self.espaciolib = gtk.Label(_("Espacio libre en disco") + ": %dKB" % f.get_free_space())
		self.espacioreq = gtk.Label(_("Espacio requerido") + ": %dKB" % self.required_space)
		self.entry.connect("activate", self.actualizar_espacio_libre, self.entry)
		self.entry.set_text(os.path.expanduser('~'))
		boton22 = gtk.Button(label = _("Seleccionar otra carpeta"), stock = None)
		frame5 = gtk.Frame(_("Opciones de migración"))
		self.arbol_inicializado = False
		self.tree_options = gtk.TreeStore( gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
		self.sw3 = gtk.ScrolledWindow()
		self.sw3.set_size_request(280, 200)
		self.sw3.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		self.sw3.add(self.generar_vista(self.tree_options))
		
		# añadir
		self.tercera.pack_start(self.terceraver1, False, False, 0)
		self.tercera.pack_start(self.terceraver2, True, True, 0)
		self.terceraver1.pack_start(self.tercerahor1, False, False, 10)
		self.terceraver2.pack_start(self.tercerahor2, True, True, 10)
		frame5.add(self.sw3)
		frame2.add(self.entry)
		self.tercerahor1.pack_start(frame2, True, False, 0)
		self.tercerahor1.pack_start(boton22, True, False, 0)
		self.tooltips.set_tip(boton22, _("Elija la carpeta Destino donde quiere guardar los archivos"))
		boton22.connect_object("clicked", self.buscar, self.window)
		self.tercerahor1.pack_start(self.espaciolib, True, True, 5)
		self.tercerahor1.pack_start(self.espacioreq, True, True, 5)
		self.tercerahor2.pack_start(frame5, True, False, 0)


################Cuarta Ventana

		# crear
		self.cuartahor1 = gtk.HBox(False, 10)
		frame3 = gtk.Frame(_("Tareas a realizar"))
		sw1 = gtk.ScrolledWindow()
		sw1.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		sw1.set_size_request(600, 225)
		textview1 = gtk.TextView()
		self.textbuffer1 = textview1.get_buffer()
		textview1.set_editable(False)

		#añadir
		self.cuarta.pack_start(self.cuartahor1, True, True, 0)
		self.cuartahor1.pack_start(frame3, True, True, 10)
		frame3.add(sw1)
		sw1.add(textview1)


################Quinta Ventana
		
		# crear
		self.quintahor1 = gtk.VBox(False, 10)
		frame4 = gtk.Frame(_("Detalles de tareas"))
		sw4 = gtk.ScrolledWindow()
		sw4.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		sw4.set_size_request(580, 200)
		textview4 = gtk.TextView()
		self.textbuffer4 = textview4.get_buffer()
		self.textbuffer4.set_text(_('Comenzando el proceso de migración...') + '\n ' + _('Esto puede llevar cierto tiempo en función del tamaño de los archivos y de la velocidad de su equipo.') + '\n ' + _('Por favor espere...'))
		textview4.set_editable(False)
		self.progreso = gtk.ProgressBar(None)
		self.progreso.set_fraction(0.0)
		self.progreso.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT)
		self.progreso.set_text(_("Realizando las tareas solicitadas..."))
		
		# añadir
		self.quinta.pack_start(self.quintahor1, True, False, 10)
		self.quintahor1.pack_start(frame4, True, True, 10)
		self.quintahor1.pack_start(self.progreso, False, False, 5)
		frame4.add(sw4)
		sw4.add(textview4)
		global barra
		barra = self.progreso
		global text_view
		text_view = textview4	
		global detalle
		detalle = self.textbuffer4
		try:
			child = gtk.EventBox()
			b =  gtk.LinkButton(self.url, label=_("Más información sobre Amigu"))
			child.add(b)
			text_view.add_child_in_window(child, gtk.TEXT_WINDOW_TEXT, 480, 173)
		except: 
			pass
	def actualizar_espacio_libre(self, widget, entry):
		"""Actualiza el espacio libre en disco"""
		destino = entry.get_text()
		if os.path.exists(destino):
			d = folder(destino)
			self.espaciolib.set_text(_("Espacio libre en disco: %dKB") % d.get_free_space())
	def __init__(self):
		"""Constructor de la clase"""
		self.errors = []
		self.config_file = os.path.join(os.path.expanduser('~'), '.kde', 'share', 'config', 'kopeterc')
		folder(os.path.join(os.path.expanduser('~'), '.kde', 'share', 'config'))
	def mostrar_paso(self):
		"""Actualiza el contenido del asistente en función del paso actual"""
		# Ocultar todo
		self.inicio.hide()
		self.segunda.hide()
		self.tercera.hide()
		self.cuarta.hide()
		self.quinta.hide()
		self.boton1.show_all()
		self.boton1.set_sensitive(True)
		self.boton2.show()
		self.boton2.set_sensitive(False)
		self.boton3.hide()
		self.boton5.hide()
		self.etapa.set_markup("<span face=\"arial\" size=\"8000\" foreground=\"chocolate\"><b>"+_('Paso %d de 5')%self.paso+"</b></span>")
		
		if self.paso == 1:
			self.inicio.show()
			self.labelpri.set_markup('')
			self.boton1.hide_all()
			self.boton2.set_sensitive(True)

		elif self.paso == 2:
			self.segunda.show_all()
			self.labelpri.set_markup('<span face="arial" size="12000" foreground="chocolate"><b>'+_('SELECCIÓN DE USUARIO')+'</b></span>')
			if self.selected_user:
				self.boton2.set_sensitive(True)
			if not self.usuarios:
				self.textbuffer.set_text(_('Buscando usuarios de Windows. Por favor espere...'))
				self.boton.window.set_cursor(self.watch)
				gobject.idle_add(self.buscar_usuarios)

		elif self.paso == 3:
			self.labelpri.set_markup('<span face="arial" size="12000" foreground="chocolate"><b>'+_('OPCIONES DE MIGRACIÓN')+'</b></span>')
			if not self.arbol_inicializado:
				self.generar_arbol()
				self.arbol_inicializado = True
			self.boton2.set_sensitive(True)
			self.tercera.show_all()

		elif self.paso == 4:
			self.destino = self.entry.get_text()
			self.boton2.set_sensitive(True)
			if self.destino:
				f = folder(self.destino)
				if not f or not f.path:
					self.paso = 3
					self.dialogo_advertencia(_("Ruta de destino no válida"))
					self.tercera.show()
				elif not f.is_writable():
					self.paso = 3
					self.dialogo_advertencia(_("No dispone de permiso de escritura para la ubicación seleccionada"))
					self.tercera.show()
				elif f.get_free_space < self.required_space:
					self.paso = 3
					self.dialogo_advertencia(_("Espacio en disco insuficiente.") + '\n' + _('Seleccione otra ubicación de destino o cambie sus opciones de migración'))
					self.tercera.show()
				else:
					self.labelpri.set_markup('<span face="arial" size="12000" foreground="chocolate"><b>'+_('RESUMEN DE TAREAS')+'</b></span>')
					self.generar_resumen(self.tree_options)
					self.boton2.hide()
					self.boton3.show_all()
					self.cuarta.show_all()
			else:
				self.paso = 3
				self.dialogo_advertencia(_("Introduzca una ubicación de destino"))
				self.tercera.show()

		elif self.paso == 5:
			self.labelpri.set_markup('<span face="arial" size="12000" foreground="chocolate"><b>'+_('DETALLES DE LA MIGRACIÓN')+'</b></span>')
			self.quinta.show_all()
			self.boton1.hide_all()
			self.boton2.hide_all()
			self.boton5.show()
			time.sleep(0.2)
			gobject.idle_add(self.aplicar)
		self.boton.window.set_cursor(None)
Beispiel #39
0
def import_fonts(fontsdir):
    """Copia las fuentes ttf del directorio que se le pasa"""
    dest = folder(
        os.path.join(os.path.expanduser('~'), '.fonts', 'ttf-windows'))
    fontsdir.copy(dest.path, '.ttf')
Beispiel #40
0
        '~'
    )  #for GNOME should be /usr/share/bankgrounds and for KDE /usr/share/themes but it requires toot privileges
    if os.path.exists(img):
        (folder, filename) = os.path.split(img)
        wallpaper = os.path.join(dest, filename)
        if not os.path.exists(wallpaper):
            try:
                shutil.copy2(img, dest)
            except:
                error("Wallpaper not installed")
        if os.path.exists('/usr/bin/gconftool'):  # for GNOME
            os.system(
                "gconftool --type string --set /desktop/gnome/background/picture_filename %s"
                % wallpaper.replace(' ', '\ '))
        if os.path.exists('/usr/bin/dcop'):  # for KDE
            os.system('dcop kdesktop KBackgroundIface setWallpaper  %s 4' %
                      wallpaper.replace(' ', '\ '))
        print "Wallpaper installed succesfully"


def import_fonts(fontsdir):
    """Copia las fuentes ttf del directorio que se le pasa"""
    dest = folder(
        os.path.join(os.path.expanduser('~'), '.fonts', 'ttf-windows'))
    fontsdir.copy(dest.path, '.ttf')


if __name__ == "__main__":
    set_wallpaper("/usr/share/backgrounds/ubuntu-smooth-chocolate.png")
    import_fonts(folder("/usr/share/fonts/truetype"))
	def generar_arbol(self):
		"""Genera el árbol de opciones para el usario seleccionado"""
		print _("Generando opciones de migración...")
		# limpiar variables
		self.tree_options.clear() 
		self.tasks = []
		self.resumen = []
		# Generar vista
		self.view = self.generar_vista(self.tree_options)
		name_usr = self.tree_options.append(None, [self.selected_user.get_name(), None, None, _('Usuario seleccionado'), None])
		
		# Files
		parent = self.tree_options.append(name_usr , [_("Archivos"), None, None, _('Migrar archivos'), None] )
		self.tree_options.append( parent, [_("Mis documentos"), None, str(self.selected_user.folders['Personal'].get_size()), _('Archivos personales: ')+ self.selected_user.folders['Personal'].get_info(), 'documentos'] )
		self.tree_options.append( parent, [_("Escritorio"), None, str(self.selected_user.folders['Desktop'].get_size()), _('Archivos del escritorio: ')+self.selected_user.folders['Desktop'].get_info(), 'escritorio'] )
		
		# eMule
		if 'eMule' in self.selected_user.folders.keys():
			emule_inc = self.selected_user.get_incoming_path()
			emule_temp = self.selected_user.get_temp_path()
			self.tree_options.append( parent, [_("Descargados eMule"), None, str(emule_inc.get_size()), _('Archivos descargados: ')+ emule_inc.get_info(), 'descargados'] )
			self.tree_options.append( parent, [_("Temporales eMule"), None, str(emule_temp.get_size()), _('Archivos temporales: ')+ emule_temp.get_info(), 'temporales'] )
		parent = self.tree_options.append(name_usr , [_("Configuraciones"), None, None, _('Migrar configuraciones'), None] )
		
		# Thundebird
		t = mail.thunderbird()
		if t.is_installed_on_Windows(self.selected_user.folders['AppData']):
			mthun = self.tree_options.append(parent, [_("Mozilla-Thunderbird"), None, None, _('Cuentas de correo y libreta de direcciones (sobreescribirá la configuración existente)'), 'thunderbird'] )
			
		# Outlook
		#print _('Buscando cuentas de correo...')
		n_ou, n_oue = self.selected_user.num_OUTLOOK_accounts()
		self.buzones_ou, self.buzones_oue, oue = None, None, None
		pstpath = folder(os.path.join(self.selected_user.folders['Local AppData'].path, 'Microsoft', 'Outlook'), False)
		dbxpath = folder(os.path.join(self.selected_user.folders['Local AppData'].path, 'Identities'), False)
		if pstpath.path: 
			self.buzones_ou = pstpath.search_by_ext('.pst') + self.selected_user.folders['Personal'].search_by_ext('.pst')
		if dbxpath.path:
			self.buzones_oue = dbxpath.search_by_ext('.dbx')
		if n_oue or self.buzones_oue: oue = self.tree_options.append(parent, [_("OutlookExpress"), None, None, _('Cuentas de correo'), None] )
		if n_ou or self.buzones_ou: ou = self.tree_options.append(parent, [_("Outlook"), None, None, _('Cuentas de correo'), None] )
		# Mailboxes
		if self.buzones_ou:
			tam = 0
			for b in self.buzones_ou:
				try:
					tam = tam + os.stat(b)[stat.ST_SIZE]
				except: 
					pass
			self.tree_options.append(ou, [_('Carpetas de correo'), None, tam/1024, _('Carpetas de correo de Outlook'), 'oumails'])
		if self.buzones_oue:
			tam = 0
			for b in self.buzones_oue:
				try:
					tam = tam + os.stat(b)[stat.ST_SIZE]
				except: 
					pass
			self.tree_options.append(oue, [_('Carpetas de correo'), None, tam/1024, _('Carpetas de correo de Outlook Express'), 'ouemails'])
		#Addressbook
		self.adbook = os.path.join(self.selected_user.folders['AppData'].path, 'Microsoft', 'Address Book', self.selected_user.get_name()+'.wab')
		#print self.adbook
		tam = 0
		if os.path.exists(self.adbook) and oue:
			try:
				tam = tam + os.stat(self.adbook)[stat.ST_SIZE]
			except: 
				pass
			self.tree_options.append(oue, [_('Libreta de direcciones'), None, tam/1024, _('Libreta de direcciones de Outlook Express'), 'oueaddressbook'])
		#Accounts
		seguir_buscando, i = True, 0
		while seguir_buscando:
			i = i + 1
			if n_oue:
				account = self.selected_user.get_OUTLOOKexpress_account(i)
				if account: n_oue = n_oue - 1
				if account and 'Account Name' in account.keys():
					self.tree_options.append(oue, [account['Account Name'], None, None, _('Cuenta de correo <' + account['SMTP Email Address'] + '> de MS-OutlookExpress'), 'express'+str(i)] )	
					#self.tree_options.append(mthun, [account['Account Name'], None, None, _('Importar cuenta de correo de MS-OutlookExpress a Thunderbird'), 'oue2thun'+str(i)] )	
			if n_ou:
				account = self.selected_user.get_OUTLOOK_account(i)
				if account: n_ou = n_ou -1
				if account and 'Account Name' in account.keys():
					self.tree_options.append(ou, [account['Account Name'], None, None, _('Cuenta de correo <' + account['SMTP Email Address'] + '> de MS-Outlook'), 'outlook'+str(i)] )
					#self.tree_options.append(mthun, [account['Account Name'], None, None, _('Importar cuenta de correo de MS-Outlook a Thunderbird'), 'ou2thun'+str(i)] )
			seguir_buscando = (n_ou or n_oue) and (i<20)
			
		# Bookmarks
		self.tree_options.append(parent, [_("IExplorer"), None, None, _('Favoritos de Internet Explorer'), 'iexplorer'] )
		if os.path.exists(os.path.join(self.selected_user.folders['AppData'].path, 'Opera', 'Opera', 'profile', 'opera6.adr')):
			self.tree_options.append(parent, [_("Opera"), None, None, _('Marcadores de Opera'), 'opera'] )
		if os.path.exists(os.path.join(self.selected_user.folders['AppData'].path, 'Mozilla', 'Firefox')):
			self.tree_options.append(parent, [_("Mozilla-Firefox"), None, None, _('Marcadores de Mozilla-Firefox'), 'firefox'] )
		# Instant Messenger
		messenger = self.selected_user.get_messenger_accounts()
		msn = self.selected_user.get_MSN_account()
		yahoo = self.selected_user.get_YAHOO_account()
		gtalk = self.selected_user.get_GTALK_account()
		aol = self.selected_user.get_AOL_accounts()
		if msn or yahoo or gtalk or aol or messenger:
			im = self.tree_options.append(parent, [_("Mensajeria Instantanea"), None, None, _('Cuentas de IM'), None] )
		for m in messenger:
			self.tree_options.append(im, [m, None, None, _('Cuenta de MSN Messenger'), m] )
		if msn:
			self.tree_options.append(im, [msn, None, None, _('Cuenta de MSN Messenger'), 'msn'] )
		if yahoo:
			self.tree_options.append(im, [yahoo, None, None, _('Cuenta de Yahoo! Messenger'), 'yahoo'] )
		if gtalk:
			self.tree_options.append(im, [gtalk, None, None, _('Cuenta de Gtalk'), 'gtalk'] )
		for a in aol:
			self.tree_options.append(im, [a, None, None, _('Cuenta de American On-Line'), None] )
			
		# eMule Config	
		if 'eMule' in self.selected_user.folders.keys():
			self.tree_options.append(parent, [_("eMule"), None, None, _('Configuracion del eMule'), 'emule'] )

		#Fonts
		if self.selected_user.folders['Fonts'].path:
			self.tree_options.append(parent, [_("Fuentes"), None, str(self.selected_user.folders['Fonts'].get_size()), _('Fuentes True-Type'), 'fuentes'] )

		#Wallpaper
		if 'Wallpaper' in self.selected_user.folders.keys():
			self.tree_options.append(parent, [_("Fondo de Escritorio"), None, None, _('Imagen de fondo de escritorio'), 'wallpaper'] )
		print _("Opciones de migración generadas")
	def tarea(self, task):
		"""Ejecuta la tarea seleccionada
		
		Returns String"""
		
		if task == 'documentos':
			# copy Personal (My documents) folder
			mensaje_progreso =_('Copiando archivos personales...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			self.selected_user.folders['Personal'].copy(self.destino, exclude = ['.lnk','.ini'])
			return ( _("\tCopiados Documentos personales\n"))
			
		elif task == 'escritorio':
			# copy Desktop folder
			mensaje_progreso = _('Copiando archivos personales...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			escritorio = folder(os.path.join(self.destino, 'Desktop'))
			self.selected_user.folders['Desktop'].copy(escritorio.path, exclude = ['.lnk','.ini'])
			return ( _("\tCopiados Documentos del escritorio\n"))

		elif task == 'temporales':

			mensaje_progreso= _('Copiando descargas incompletas...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			self.selected_user.import_eMule_temp()
			return ( _("\tCopiados Archivos temporales\n"))
			
		elif task == 'descargados':
		
			mensaje_progreso = _('Copiando descargas finalizadas...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			self.selected_user.import_eMule_files()
			return ( _("\tCopiados Archivos descargados\n"))
			
		elif task == 'wallpaper':
			
			mensaje_progreso = _('Configurando fondo de escritorio...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			settings.set_wallpaper(self.selected_user.folders['Wallpaper'])
			return ( _("\tInstalado el fondo de escritorio\n"))
			
		elif task == 'fuentes':
			
			mensaje_progreso = _('Copiando fuentes tipograficas...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			settings.import_fonts(self.selected_user.folders['Fonts'])
			return ( _("\tCopiadas fuentes tipograficas\n"))
			
		elif task == 'emule':
			
			mensaje_progreso = _('Importando configuracion del eMule...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			self.selected_user.config_aMule()
			return (_( "\tImportada configuracion del eMule\n"))
			
		elif task == 'iexplorer':
			
			mensaje_progreso = _('Importando favoritos de Internet Explorer...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			f = webbrowser.firefox(self.selected_user.folders)
			f.import_favorites_IE()
			return ( _("\tImportados favoritos de Internet Explorer\n"))
			
		elif task == 'opera':
			
			mensaje_progreso = _('Importando marcadores de Opera...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			f = webbrowser.firefox(self.selected_user.folders)
			f.import_bookmarks_opera()
			return (_( "\tImportados marcadores de Opera\n"))
			
		elif task == 'firefox':
			
			mensaje_progreso = _('Importando marcadores de Firefox...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			f = webbrowser.firefox(self.selected_user.folders)
			f.import_bookmarks_firefox()
			return ( _("\tImportados marcadores de Firefox\n"))
			
		elif task == 'msn':
			
			mensaje_progreso = _('Configurando cuentas de mensajeria instantanea...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			msn = self.selected_user.get_MSN_account()
			gaim = messenger.gaim()
			gaim.config_msn(msn)
			messenger.msn2amsn(msn)
			return ( _("\tConfigurada cuenta de MSN\n"))
			
		elif task == 'yahoo':
			
			mensaje_progreso = _('Configurando cuentas de mensajeria instantanea...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			yahoo = self.selected_user.get_YAHOO_account()
			gaim = messenger.gaim()
			gaim.config_yahoo(yahoo)
			return ( _("\tConfigurada cuenta de Yahoo!\n"))
			
		elif task == 'gtalk':
			
			mensaje_progreso = _('Configurando cuentas de mensajeria instantanea...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			gtalk = self.selected_user.get_GTALK_account()
			gaim = messenger.gaim()
			gaim.config_gtalk(gtalk)
			return ( _("\tConfigurada cuenta de Gtalk\n"))
			
		elif task == 'thunderbird':
			
			mensaje_progreso = _('Importando configuracion de Mozilla-Thunderbird...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			t = mail.thunderbird()
			t.import_windows_settings(self.selected_user.folders['AppData'].path)
			return ( _("\tImportada configuracion de Mozilla-Thunderbird\n"))
			
		elif task.find('express') != -1:
			
			mensaje_progreso = _('Importando cuenta de correo de Outlook Express...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			account = self.selected_user.get_OUTLOOKexpress_account(int(task.replace('express', '')))
			if account:
				mail.config_EVOLUTION(account)
				t = mail.thunderbird()
				t.config_account(account)
				return (_( "\tImportada cuenta de Outlook-Express\n"))
			
		elif task.find('outlook') != -1:
			
			mensaje_progreso = _('Importando cuenta de correo de Outlook...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			account = self.selected_user.get_OUTLOOK_account(int(task.replace('outlook', '')))
			if account:
				mail.config_EVOLUTION(account)
				t = mail.thunderbird()
				t.config_account(account)
				return ( _("\tImportada cuenta de Outlook\n"))
			
		elif task.find('oumails') != -1:
			mensaje_progreso = _('Importando correos de Outlook...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			aviso = ""
			for b in self.buzones_ou:
				if mail.convert_pst(b):
					aviso = _("AVISO: Se ha detectado que alguno de sus buzones de correo están en formato de Outlook 2003.") + '\n ' + _("Debido a incompatibilidades con dicho formato no se han podido importar dichos correos.") + '\n ' + _("Por favor, visite la página web de Amigu para ver las alternativas posibles. Disculpen las molestias") + '\n'
					try:
						shutil.copy2('/usr/share/amigu/AMIGU y Outlook 2003.url', self.selected_user.folders['Desktop'].path)
					except:
						pass
			return '\t' + _('Importados correos de Outlook') + '\n ' + aviso
			
		elif task.find('ouemails') != -1:
			mensaje_progreso = _('Importando correos de Outlook Express...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			for b in self.buzones_oue:
				if b.find('Folders.dbx') != -1:
					mail.convert_dbx(b)
			return ( _("\tImportados correos de Outlook Express\n"))
				
		elif task.find('@') != -1:
			
			mensaje_progreso = _('Configurando cuentas de mensajeria instantanea...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			gaim = messenger.gaim()
			gaim.config_msn(task)
			messenger.msn2amsn(task)
			return ( _("\tConfigurada cuenta de MSN\n"))
		
		elif task.find('2thun') != -1:
			
			mensaje_progreso = _('Importando cuentas de correo a Thunderbird...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			t = mail.thunderbird()
			account = None
			if task.find('oue2') != -1:
				account = self.selected_user.get_OUTLOOKexpress_account(int(task.replace('oue2thun', '')))
			elif task.find('ou2') != -1:
				account = self.selected_user.get_OUTLOOK_account(int(task.replace('ou2thun', '')))
			if account:
				t.config_account(account)
				return ( _("\tConfigurada cuenta de correo en Thunderbird\n"))
		
		elif task == 'oueaddressbook':
			
			mensaje_progreso = _('Importando libreta de direcciones...')
			os.write(self.pipe_w, mensaje_progreso)
			time.sleep(0.5)
			adlist = mail.get_outlook_addressbook(self.adbook)
			mail.generate_csv(adlist)
			mail.generate_html(adlist)
			t = mail.thunderbird()
			t.generate_impab(adlist)
			return ( _("\tImportada libreta de direcciones\n"))
def set_wallpaper(img):
	"""Copia y configura la imagen que se le pasa como fondo de escritorio.
	Válido para GNOME y KDE"""
	dest = os.path.expanduser('~') #for GNOME should be /usr/share/bankgrounds and for KDE /usr/share/themes but it requires toot privileges
	if os.path.exists(img):
		(folder, filename) = os.path.split(img)
		wallpaper = os.path.join(dest, filename)
		if not os.path.exists(wallpaper):
			try:
				shutil.copy2(img, dest)
			except:
				error("Wallpaper not installed")
		if os.path.exists('/usr/bin/gconftool'): # for GNOME
			os.system("gconftool --type string --set /desktop/gnome/background/picture_filename %s" % wallpaper.replace(' ','\ '))
		if os.path.exists('/usr/bin/dcop'): # for KDE
			os.system('dcop kdesktop KBackgroundIface setWallpaper  %s 4' % wallpaper.replace(' ','\ '))
		print "Wallpaper installed succesfully"
		
			
def import_fonts(fontsdir):
	"""Copia las fuentes ttf del directorio que se le pasa"""
	dest = folder(os.path.join(os.path.expanduser('~'),'.fonts','ttf-windows'))
	fontsdir.copy(dest.path, '.ttf')


if __name__ == "__main__":
	set_wallpaper("/usr/share/backgrounds/ubuntu-smooth-chocolate.png")
	import_fonts(folder("/usr/share/fonts/truetype"))