Eudora Light -> Imp Webmail Addressbook Converter
Steven M. Castellotti
scastell@sas.upenn.edu
Wed, 03 Jan 2001 17:01:42 -0500
---------------------- multipart/mixed attachment
Attached to this message is a quick python program I have written which
will take in a eudora light "nndbase.txt" address book, parse out all of
the extraneous and non-usable data (such as notes and contact lists) and
insert the data directely into Imp's MySQL database.
I hope others may find this program useful; it is released under the
GPL.
--
Steve Castellotti
Systems Programmer
School of Arts and Sciences, University of Pennsylvania
---------------------- multipart/mixed attachment
#!/usr/bin/env python
#
# Eudora Light -> Imp Webmail Address Book Converter
#
# Copyright Steven M. Castellotti (2001)
# The author can be reached at: SteveC@innocent.com
# This code is released under the GNU Pulic License (GPL)
# For more information please refer to http://www.gnu.org/copyleft/gpl.html
#
# Version 1.0
# Last Update: 2001.01.03
#
# This program will take in a username and a eudora light addressbook file,
# parse out extraneous and non-usable information (such as notes and
# group lists), and insert the addresses into IMP's MySQL database.
# It will attempt to format the user's entries as best
# as possible, but depending on what conventions the individual user
# employed when setting up their addressbook in eudora light, some
# names may get mangled, and some addresses might get lost.
#
#
# Calling example:
#
# ./eudora2imp.py <username> nndbase.txt
#
#
#####################################################################
import sys, string, MySQLdb
#####################################################################
# Global Variables
#####################################################################
addressbook_input_file = sys.argv[-1]
username = sys.argv[-2]
# The following database settings MUST be customized!
db_server='localhost' # This is the hostname of the MySQL server
db_port=3306 # This is the port of the MySQL server
db_username='hordemgr' # This is the username of the MySQL user
db_password='hordemgr' # This is the password of the MySQL user
db_name='horde' # This is the MySQL database's name
addressbook_username=username # This is the imp user's username
addressbook_host='localhost' # This is the imap host referred to in the horde database
#####################################################################
# Functions
#####################################################################
def parse_addressbook(input_file):
# This function will read in the eudora light addressbook file for a given
# user, strip out the unusable information, store name:address pairs
# into a dictionary, and finally returns that dictionary
addressbook = {}
input = open(input_file, 'r')
for line in input.readlines():
templine = string.strip(line)
templine = string.replace(templine, '\n', '')
if (string.find(templine, '"') != -1): # quotation marks in this file indictate email
# address nicknames, not actual addresses,
# so we drop them.
continue # "continue" tells the for loop to begin again (with the next line).
fields = string.split(templine, ' ')
if (fields[0] != 'alias'): # we drop all "notes" from the eudora addressbook
continue
if (len(fields) != 3): # we drop all blank email addresses
continue
name = fields[1]
address = fields[2]
if (address[-1] == ','): # sometimes address entries end with a comma, for no apparant reason
address = address[:-1]
if (string.find(address, ',') != -1): # if an address still contains a comma,
# it's probably a list and not an address,
# so it also gets dropped.
continue
if (string.find(name, '.') != -1): # if a name contains a period, we will check to see
# if the entry looks like a last name followed by an
# initial or first name
left = string.split(name, '.')[0]
right = string.split(name, '.')[1]
#left[0] = string.upper(left[0]) # Capitalize first character of left part of name
if (len(right) == 1): # It looks like we have an initial here
right = string.upper(right)
name = right + '. ' + left
elif ((len(right) == 2) and (right[0] == string.upper(right[0])) and \
(right[1] == string.upper(right[1]))):
# We appear to have two initials, a first and middle name
name = right[0] + '. ' + right[1] + '. ' + left
else:
name = right + ' ' + left
name = string.replace(name, '\'', '\\\'') # escape any single quotes in the name
addressbook[name] = address
return(addressbook)
#####################################################################
def insert_info_into_database(addressbook):
# This function accepts the addressbook dictionary and performs connections
# to the MySQL database, adding each of the user's email addresses
import __main__ # imports global variables, and technically re-imports addressbook
db_link = MySQLdb.connect(host=db_server, \
port=db_port, \
db=db_name, \
user=db_username, \
passwd=db_password)
db_connection = db_link.cursor() # I don't actually know what this does, but it works
for each in addressbook.keys():
sql = "INSERT INTO imp_addr VALUES('%s@%s', '%s', '%s', '%s');" \
% (addressbook_username, addressbook_host, addressbook[each], each, each)
#print sql
db_connection.execute(sql)
#####################################################################
# Main
#####################################################################
addressbook = parse_addressbook(addressbook_input_file)
# These next two lines are useful when debugging
#
#for each in addressbook.keys():
# print '%s:%s' % (each, addressbook[each])
insert_info_into_database(addressbook)
# EOF
---------------------- multipart/mixed attachment--
>From chuck@horde.org Date: Wed, 3 Jan 2001 18:56:13 -0500
Return-Path: <chuck@horde.org>
Mailing-List: contact imp-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list imp@lists.horde.org
Received: (qmail 69435 invoked from network); 3 Jan 2001 23:57:01 -0000
Received: from r93aag000369.sbo-smr.ma.cable.rcn.com (HELO marina.horde.org) (209.6.192.126)
by horde.org with SMTP; 3 Jan 2001 23:57:01 -0000
Received: by marina.horde.org (Postfix, from userid 33)
id BF2F83975; Wed, 3 Jan 2001 18:56:13 -0500 (EST)
Received: from 206.243.191.252 ( [206.243.191.252])
as user chuck@marina by marina.horde.org with HTTP;
Wed, 3 Jan 2001 18:56:13 -0500
Message-ID: <978566173.3a53bc1db4cce@marina.horde.org>
Date: Wed, 3 Jan 2001 18:56:13 -0500
From: Chuck Hagenbuch <chuck@horde.org>
To: imp@lists.horde.org
References: <3A5381A3.15C4F64C@ednet.ns.ca> <978551889.3a5384512da82@marina.horde.org> <3A5387E0.E70F3080@ednet.ns.ca>
In-Reply-To: <3A5387E0.E70F3080@ednet.ns.ca>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 2.3.6-cvs
Subject: Re: [imp] Can't login to IMP 2.3
Quoting Patrick Boutilier <boutilpj@ednet.ns.ca>:
> When I click the login button I get one POST and one GET in the apache logs
> so no help there.
Okay. Nothing is jumping out at me, so since this is development code, you get
to have the ball dropped on you. =) It'd be helpful to know where exactly the
login is failing. For instance, inside IMP::createSession(), does it error out
because of missing variables? Later on? Etc...
-chuck
--
Charles Hagenbuch, <chuck@horde.org>
"If you can't stand the heat, get out of the chicken!" - Baby Blues