Showing posts with label projects. Show all posts
Showing posts with label projects. Show all posts

Monday, May 19, 2008

lxml on OSX -- again

Hi folks :)

Today, I've again tried to install lxml on OS X. For a project I do for a customer (migrating featurecreep CMS sites to Plone), I use the lxml parser. I get regular segfaults, this time using python 2.4 (I use macport for python 2.4).
I investigated again, and came along this post. The scoop is:
after blood, sweat, and some tears (kidding) this is *all* I needed, it seems:

export CFLAGS="-flat_namespace"

...no static builds libxml2 libs, no buildout recipe. I just set that and ran:

python setup.py bdist_egg
--with-xml2-config=/opt/local/bin/xml2-config
--with-xslt-config=/opt/local/bin/xslt-config

which uses the libxml2 and etc. installed by ports. In fact, as long
as /opt/local/bin is on my path that should work without having to set
paths (i.e. from easy_install). All my tests that were segfaulting
are now passing. This appears to be the exact same behavior I got by
setting DYLD_FORCE_FLAT_NAMESPACE at runtime but without the side
affect of applying itself to anything else running in my shell ;)

so, I'm thinking this is just two lines of code added to cflags() ...

if sys.platform in ('darwin',):
result.append('-flat_namespace')


Well. What can I say. Interesting poinst so far for OS X development:
  • no -rpath supported
  • no static libraries (Yup! No joke)

Wednesday, October 25, 2006

Success!

Yeee-haaa!

I've just connected to Skype using Python and the Skype API Framework. I get notifications, and can send commands:


seletz@yeti:~/develop/python/pyskype/test $python skypeapi-test-osx.py
2006-10-25 01:05:55.934 Python[14094] running event loop
2006-10-25 01:05:56.935 Python[14094] connecting to skype
2006-10-25 01:05:56.941 Python[14094] waiting ....
2006-10-25 01:06:00.547 Python[14094] skypeAttachResponse: 1
2006-10-25 01:06:00.576 Python[14094] skypeNotificationReceived: CONNSTATUS ONLINE
2006-10-25 01:06:00.578 Python[14094] skypeNotificationReceived: CURRENTUSERHANDLE seletz29
2006-10-25 01:06:00.578 Python[14094] skypeNotificationReceived: USERSTATUS ONLINE
2006-10-25 01:06:06.942 Python[14094] sending
2006-10-25 01:06:06.942 Python[14094] got answer: None
2006-10-25 01:06:06.943 Python[14094] skypeNotificationReceived: PROTOCOL 1



I've started a new project at Google Code, where I try to create a platform-independent Python wrapper for the Skype API.

The trick was, of course, RTFM. I just needed to use PyObjC to create a informal protocol for the delegate class I use to connect with the Skype API. It's rather byzantine how Apple encodes type information.

Saturday, October 21, 2006

Skype API

I just discovered the Skype API. I know, Skype is not open-source, but hey ...

The API is quite cool. Apart from the pretty obvious API access to the voice call and chat stuff, there's an API for transparently sending raw streams between programs. So, one could use the Skype API to use a pretty nifty transparent channel to send data between applications. They call this the Application2Application Protocol.

This could be the last building block I need for a pet project I have, the Personal Information Server. There I need a method to communicate with different PIS in a P2P manner, no DNS name resolution and stuff. Transparent "just works" type of communication.

Using the PIS one would mark certain types of information managed by the PIS as "public", and other PIS (those from your friends, co-workers, company , ...) would
query any "new" stuff and incorporate this new stuff into their own information store.

Using the Skype API, this could work out pretty nifty:

  • You start up your PIS instance
  • the PIS instance checks whether or not you're online with Skype
  • if you're online:
  • check if my buddies are online and have their PIS started
  • fetch the new stuff (contact info's, phone numbers, events, blogs, ...)

So, in theory, if you start up your PIS, it begins to sync with your peer PIS from your friends. That way, contacts and events stay synchronized, even if you're not online all the time, and even if you're behind a firewall.

You could also have more than one PIS, one on the road on your laptop, one at home, etc.

Nifty.

I think I'll play around with this stuff a bit. I've found no python bindings yet, but hey, at last we all have ctypes now with python 2.5, don't we ;)

Google's GData API

I'm currently investigating the use of the GData API when it comes to create a command line blog posting tool written in pure python.

Well, it seems that there's no Python API for the pure Google Data stuff yet (I know about the Google Base Data API).

But from what I've understood this is all pure HTML POST and GET using an extended version of the ATOM XML schema. Using urllib and ElementTree in python its just plain simple to actually get your blog feeds. They've even built in some sort of query language.

Unfortunately, to authenticate with Google using your Google account, there's a bit more involved. The Java guys have it better here: There's a nice high-level API. Doh.

Authentication is, as far as I understood, needed to post blog entries.

Note to myself:
  • Investigate Google Authentication wrt. Plone PAS
  • provide a pure python script which posts to a blog
  • hook script into a plone work flow to publish atricles from plone to blogs. Create a new content type for that, track blog post IDs we got back from google inside plone. Use Five and notifiers to update blog if Plone document changes. This would be a PIS module.