From xmlrpc@opengroupware.org Fri Apr 13 16:21:19 2007 From: xmlrpc@opengroupware.org (Rick) Date: Fri, 13 Apr 2007 09:21:19 -0600 Subject: [OGo-XML-RPC] Importing contacts from delimited files Message-ID: <461F9FEF.2050309@holmestheater.com> Howdy folks! Adam from the users@ mailing list recommended I hop on over here for a few questions/help with XML-RPC scripts. I was told its possible and actually VERY easy to import a number of contacts from a delimited file using Python/XML-RPC scripts. I was wondering if someone could provide some help as to how this is actually done. Also, can someone recommend some information on 'PUT'ing contacts via Zidestore using vCard files? OS: FC3 OGO: 1.0.0-finally Thanks! From xmlrpc@opengroupware.org Fri Apr 13 18:30:25 2007 From: xmlrpc@opengroupware.org (Adam Tauno Williams) Date: Fri, 13 Apr 2007 13:30:25 -0400 Subject: [OGo-XML-RPC] Importing contacts from delimited files In-Reply-To: <461F9FEF.2050309@holmestheater.com> References: <461F9FEF.2050309@holmestheater.com> Message-ID: <1176485425.5091.17.camel@aleph.whitemice.org> --=-h1ZgKIjRL1VEIR4RnA74 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > Adam from the users@ mailing list recommended I hop on over here for a fe= w=20 > questions/help with XML-RPC scripts. > I was told its possible and actually VERY easy to import a number of cont= acts=20 > from a delimited file using Python/XML-RPC scripts. I was wondering if s= omeone > could provide some help as to how this is actually done. Here is one simple example - #!/usr/bin/env python import sys, csv, xmlrpclib, pprint server =3D xmlrpclib.Server('http://{USER}:{PASSWORD}@{HOST}/RPC2') reader =3D csv.reader(open("{FILENAME}", "rb"), delimiter=3D'|', quoting=3Dcsv.QUOTE_NONE) for row in reader: person =3D {} person['firstname'] =3D row[0] person['name'] =3D row[1] person['isPrivate'] =3D '1' person['extendedKeys'] =3D ['email1', 'title', 'other_title1'] person['extendedAttrs'] =3D {} person['extendedAttrs']['email1'] =3D row[5] person['extendedAttrs']['job_title'] =3D row[3] person['extendedAttrs']['other_title1'] =3D row[2] person['phones'] =3D {} person['phones']['01_tel'] =3D {} person['phones']['01_tel']['number'] =3D row[4] person =3D server.person.insert(person) person =3D server.person.getById(person) print person > Also, can someone recommend some information on 'PUT'ing contacts via Zid= estore using vCard files? You should be able to use any WebDAV client to PUT a vCard file to ZideStore; a URL like http://{HOST}/zidestore/dav/{USERNAME}/Contacts I mount ZideStore to the filesytsem with FUSE from my openSUSE workstation and one can navigate the tree with cd, ls, and friends. On Windows you should be able to do the same thing with WebDrive but I have never tried it. =46rom WMOGAG: The command =E2=80=9Cwdfs %LOCALFOLDER% -a http://%HOSTNAME%/zidestore/so/% USERNAME%/ -u %USERNAME% -p %PASSWORD%=E2=80=9D will mount the ZideStore fo= lder tree to the specified local folder. In order for normal users to mount folders the =E2=80=9Cwdfs=E2=80=9D binary must be set-uid. --=-h1ZgKIjRL1VEIR4RnA74 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQBGH74xLRePpNle04MRArX8AJ9ruzLjkjN5P4ijzaM9lslNFVIDZQCfbrlm VCri85rqBAPzMCVe5UoM4gQ= =AdYH -----END PGP SIGNATURE----- --=-h1ZgKIjRL1VEIR4RnA74-- From xmlrpc@opengroupware.org Fri Apr 13 18:33:54 2007 From: xmlrpc@opengroupware.org (Adam Tauno Williams) Date: Fri, 13 Apr 2007 13:33:54 -0400 Subject: [OGo-XML-RPC] Importing contacts from delimited files In-Reply-To: <1176485425.5091.17.camel@aleph.whitemice.org> References: <461F9FEF.2050309@holmestheater.com> <1176485425.5091.17.camel@aleph.whitemice.org> Message-ID: <1176485634.5091.20.camel@aleph.whitemice.org> --=-Sm4mO0+6nB2hhyvGvpLi Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2007-04-13 at 13:30 -0400, Adam Tauno Williams wrote: > > Adam from the users@ mailing list recommended I hop on over here for a = few=20 > > questions/help with XML-RPC scripts. > > I was told its possible and actually VERY easy to import a number of co= ntacts=20 > > from a delimited file using Python/XML-RPC scripts. I was wondering if= someone > > could provide some help as to how this is actually done. > Here is one simple example - > #!/usr/bin/env python >=20 > import sys, csv, xmlrpclib, pprint > server =3D xmlrpclib.Server('http://{USER}:{PASSWORD}@{HOST}/RPC2') > reader =3D csv.reader(open("{FILENAME}", "rb"), delimiter=3D'|', > quoting=3Dcsv.QUOTE_NONE) Here is a more complicated example that creates both contacts and enterprises, breaking enterprises by changes in the ZIP+4, and it sets the permissions on all created objects to specific teams - #!/usr/bin/env python import sys, csv, xmlrpclib, pprint server =3D xmlrpclib.Server('http://adam:********@gourd-amber/RPC2') reader =3D csv.reader(open("MECustomerListforOGoLoad.aaaf.csv", "rb"), delimiter=3D'|', quoting=3Dcsv.QUOTE_NONE) previousZIP =3D '' for row in reader: currentZIP =3D row[5] if currentZIP !=3D previousZIP or len(currentZIP) =3D=3D 5: print "%s: ZIP code changed" %row[0] result =3D {} if len(row[14]) > 0: fSpec =3D {} fSpec['qualifier'] =3D "bankCode =3D '%s' " % row[14] result =3D server.enterprise.fetch(fSpec) if len(result) =3D=3D 0: print "Creating new enterprise" enterprise =3D {} enterprise['name'] =3D row[1] enterprise['bankCode'] =3D row[14] enterprise['url'] =3D row[9] enterprise['addresses'] =3D {} enterprise['addresses']['ship'] =3D {} enterprise['addresses']['ship']['name1'] =3D row[1] enterprise['addresses']['ship']['street'] =3D row[2] enterprise['addresses']['ship']['city'] =3D row[3] enterprise['addresses']['ship']['state'] =3D row[4] enterprise['addresses']['ship']['zip'] =3D row[5] enterprise['addresses']['ship']['country'] =3D 'USA' enterprise['addresses']['ship']['type'] =3D 'ship' enterprise['extendedKeys'] =3D ['salesperson', 'division', 'mailmktco= de'] enterprise['extendedAttrs'] =3D {} enterprise['extendedAttrs']['salesperson'] =3D row[16] enterprise['extendedAttrs']['division'] =3D row[17] enterprise['extendedAttrs']['mailmktcode'] =3D row[15] enterprise['phones'] =3D {} enterprise['phones']['01_tel'] =3D {} enterprise['phones']['01_tel']['number'] =3D row[7] enterprise['phones']['01_tel']['info'] =3D '' enterprise['phones']['01_tel']['type'] =3D '01_tel' enterprise['phones']['10_fax'] =3D {} enterprise['phones']['10_fax']['number'] =3D row[8] enterprise['phones']['10_fax']['info'] =3D '' enterprise['phones']['10_fax']['type'] =3D '10_fax' enterpriseId =3D server.enterprise.insert(enterprise) print "Enterprise Id %s created " % enterpriseId server.access.setOperationOnObjectForAccess('rw', enterpriseId, 95524= 0); server.access.setOperationOnObjectForAccess('rw', enterpriseId, 11530= ); print " Permission applied to enterprise." else: print "Enterprise with bankCode already exists" enterpriseId =3D result[0]['id'].split('/')[4] print "Enterprise Id %s " % enterpriseId else: print "%s: ZIP code unchanged" %row[0] previousZIP =3D currentZIP if len(row[10]) > 0: contact =3D {} contact['firstname'] =3D row[11] contact['name'] =3D row[12] contact['nickname'] =3D row[10] contact['isPrivate'] =3D '0' contact['extendedKeys'] =3D ['organization', 'job_title', 'mailmktcode'= , 'salesperson', 'division'] contact['extendedAttrs'] =3D {} contact['extendedAttrs']['organization'] =3D row[1] contact['extendedAttrs']['job_title'] =3D row[13] contact['extendedAttrs']['mailmktcode'] =3D row[15] contact['extendedAttrs']['salesperson'] =3D row[16] contact['extendedAttrs']['division'] =3D row[17] contact['phones'] =3D {} contact['phones']['01_tel'] =3D {} contact['phones']['01_tel']['number'] =3D row[7] contact['phones']['01_tel']['info'] =3D '' contact['phones']['01_tel']['type'] =3D '01_tel' contact['phones']['10_fax'] =3D {} contact['phones']['10_fax']['number'] =3D row[8] contact['phones']['10_fax']['info'] =3D '' contact['phones']['10_fax']['type'] =3D '10_fax' contact['addresses'] =3D {} contact['addresses']['mailing'] =3D {} contact['addresses']['mailing']['name1'] =3D row[1] contact['addresses']['mailing']['name2'] =3D row[10] contact['addresses']['mailing']['street'] =3D row[2] contact['addresses']['mailing']['city'] =3D row[3] contact['addresses']['mailing']['state'] =3D row[4] contact['addresses']['mailing']['zip'] =3D row[5] contact['addresses']['mailing']['country'] =3D 'USA' contact['addresses']['mailing']['type'] =3D 'mailing' contactId =3D server.person.insert(contact) print " Contact Id %s created " % contactId server.enterprise.insertPerson(enterpriseId, contactId); print " Contact Id %s added to Enterprise Id %s " % (contactId, enterpriseId) server.access.setOperationOnObjectForAccess('rw', contactId, 955240); server.access.setOperationOnObjectForAccess('rw', contactId, 11530); print " Permissions applied to contact." --=-Sm4mO0+6nB2hhyvGvpLi Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQBGH78CLRePpNle04MRAprAAJ0bhpbK3PbTESPq4wv3z/Vy88EBHACfVDf1 xKlcPPaLyYLUHDcV6aM7DIQ= =OTdL -----END PGP SIGNATURE----- --=-Sm4mO0+6nB2hhyvGvpLi-- From xmlrpc@opengroupware.org Fri Apr 13 22:10:50 2007 From: xmlrpc@opengroupware.org (chris h) Date: Fri, 13 Apr 2007 17:10:50 -0400 Subject: [OGo-XML-RPC] Importing contacts from delimited files In-Reply-To: <1176485425.5091.17.camel@aleph.whitemice.org> References: <461F9FEF.2050309@holmestheater.com> <1176485425.5091.17.camel@aleph.whitemice.org> Message-ID: <200704131710.50463.chris123@magma.ca> On Friday 13 April 2007 13:30, Adam Tauno Williams wrote: > On > Windows you should be able to do the same thing with WebDrive but I have > never tried it. Webdrive can be very broken and not dav compliant. There can be issues. What works well is Novell's Netdrive available from here: http://ftp.pub.citic74.fr/pub/win9x/webdav/Novell-NetDrive/4.1/ Novell can no longer distribute this due to license issues, however it remains available on the net for free Works flawlessly on windows up to XP. Enjoy -- /ch From xmlrpc@opengroupware.org Fri Apr 13 23:54:06 2007 From: xmlrpc@opengroupware.org (Rick) Date: Fri, 13 Apr 2007 16:54:06 -0600 Subject: [OGo-XML-RPC] Importing contacts from delimited files In-Reply-To: <200704131710.50463.chris123@magma.ca> References: <461F9FEF.2050309@holmestheater.com> <1176485425.5091.17.camel@aleph.whitemice.org> <200704131710.50463.chris123@magma.ca> Message-ID: <46200A0E.5000201@holmestheater.com> Adam: Thank you very much for the scripts, I will be trying them over the weekend/next week. Chris: Thanks for the DAV client! chris h wrote: > On Friday 13 April 2007 13:30, Adam Tauno Williams wrote: > > >> On >> Windows you should be able to do the same thing with WebDrive but I have >> never tried it. >> > > Webdrive can be very broken and not dav compliant. There can be issues. What > works well is Novell's Netdrive available from here: > > http://ftp.pub.citic74.fr/pub/win9x/webdav/Novell-NetDrive/4.1/ > > Novell can no longer distribute this due to license issues, however it remains > available on the net for free > > Works flawlessly on windows up to XP. Enjoy > >