16 July 2012

No more skype4py, SkypeKit is here

App developers looking to leverage the Skype platform had a wonderful solution in Skype4Py, the open source python wrapper library. Skype4Py connected to the current Skype installation on the desktop enabling developers to make bots and applications.

Unfortunately, Skype4Py has not been in active development for quite sometime (the last checkin to the codebase was in 2009). At the time of this writing, Skype4Py was verified to be working on Windows 7, and is bound to work fine on OSX and *NIX but there is no saying how long it will continue to do so.

This leaves us with one alternative to continue developing applications and bots on the Skype platform, SkypeKit. In this post, we'll take a look at how get sign up for the skype developer program and also to download and use the skypekit for making a sample app to demonstrate the functionality.


Skypekit is, as their website says, a collection of software and APIs that allows internet-connected devices or applications to offer Skype voice and video calls. Skypekit is basically a headless Skype client that runs independently and without any user interface. Developer’s can make apps that will plug into Skypekit and make use of the intended text / audio / video functionality.

Getting in

While Skype4Py was free to download and use, Skype4Py will set you back 5$ each for the desktop and the embedded versions. Head to your projects page to join the Skype developer program by paying _US $5_.

There are 4 programs listed there

* Desktop API for Hardware
>This is for just the documentation and reference.
* SkypeKit for Desktop
>Members can read the documentation and also downlod the SDK, runtimes (OSX, *NIX and Windows)and keypairs and forum access.
* Desktop API for Software
>This is for just the documentation and reference.
* SkypeKit for Embedded
>Members can read the documentation and also downlod the SDK, runtimes (Embedded devices, android, iOS, etc.)and keypairs and forum access.

For this post, We will look at the Skype for Desktop program as we'll be concentrating on writing apps / bots using the Python language on OSX.


Once you're done signing in, you need to download the SDK. You need to agree to the Skype Terms and conditions before the download starts.

The SDK is a multi-platform SDK that lets you develop apps for skype using C++, Java or Python as your language. The SDK also packs the API documentation _AND_ examples for these three languages.

The SDK downloads as a zipped file. Just fire up a terminal and extract the archive into a folder.

`$ tar -zxvf skypekit-sdk_sdk-`

`$ cd skypekit-sdk_sdk-`

Hunt through the folders to see what they contain… You will notice that the `bin` folder is virtually empty. It just has a bunch of `netlogger` executables. As of Skypekit SDK version 3.2, the runtime which was previously in the bin folder has been removed.

As mentioned previously, the documentation for each wrapper library is present in the `/interfaces/skype/{cpp_embedded|python|java}/documentation/index.html`.

The tutorial code for each of these wrapper libraries is also present in `/examples/{language}/tutorial` folder.

Moving on...

The Runtime

The Skype Runtime no longer exists in the bin folder. I just was informed this morning by Skype's Development Support team that in the latest release a generic runtime is included in the SDK download so you won't need to generate one anymore.

The Runtime is the headless Skype instance that you use to connect your app with the skype network. This application apes most of the desktop app functionality but since it does not have a User Interface, developers are free to customize the look and feel of their application and interact with runtime using the language specific wrappers provided.

According to Skype, this runtime can be used by anyone in your organization's account.

The Keypairs

The keypairs are the last piece of the puzzle in the Skypekit tool before we head into the code. Each application registered on the skype developer page is bound to a unique key-pair of `Base64-encoded X.509 certificates` that authorize the application to interact with the skype services.

Obtaining a key pair is pretty straight forward:

* Head into your project page and click on the **Distribution key pair** link. Speficy a label and the CAPTCHA text.

* Click on **Request key pair** and save your certificate. You will get a `.pem` file to download and use in your application.

A Sample application

Now that we've done with the setup of our SDK and the skype runtime, lets go look at some of the examples provided…

The pem file

For the sake of simplicity in this sample, the first thing to do is to drop your key (the `.pem` file) into the `/examples/python/tutorial` folder.

Open up `keypair.py` in your favourite editor and change

`keyFileName = '';` to `keyFileName = '.pem';`

Startup the skypekit runtime by heading into the folder where you extracted the runtime.

`$ cd mac-x86-skypekit_4.2.1.870_1793622/bin/mac-x86/`

`$ ./mac-x86-skypekit`

Once the runtime kicks in, you'll see it print some messages like so:

SkypeRuntime Copyright (C) 2003-2012 Skype Technologies S.A.
SkypeRuntime Version: 4.2/mac-x86-skypekit_4.2.1.870_1793622
Proprietary and confidential, do not share this application.

and will continue to wait for programs to connect to it.

Open another terminal instance and head into the `/examples/python/tutorial` folder.

Lets start with a simple login script thats provided.

`$ python login.py `

This is what you're going to be seeing:

SkypeKit Python Wrapper Tutorial: Account Login
Logging in with
Login sequence: CONNECTING_TO_P2P
Login sequence: LOGGING_IN
Login sequence: INITIALIZING
Login sequence: LOGGED_IN
You should now be able to see this account as online from other Skype instances.
Press ENTER to log out

You will also notice that the runtime has emitted some messages during the same process indicating that there has been communication.

In the same manner, to place a call to another skype user, the example code provided does so:

`$ python call.py `

And there comes to end the post on SkypeKit.

For further documentation and support, head to the forums on the Skype developer page.

The API reference for using python on skypekit is available here.

Have fun making great apps!!!

And thanks to

Super affordable standing workstation built from IKEA parts - less than $50

I've been reading a lot about the health and productivity benefits of working at a standing desk for months now and today finally decided to head down to IKEA and grab the parts to build one. The inspiration came from an article about how to build a $22 IKEA standing desk. This seemed the most sensible way to go about getting what I wanted.

  • (2) Lack side tables - $19.98
  • (1) Ekby Viktor 11" shelf - $5.99
  • (2) Ekby Valter shelf brackets - $8

From Home Depot
  • (4) 5/16" x 3" hex bolts - $1.24
  • (8) 1/4" washers - $0.88
  • (4) 1/4" hex nuts - $0.24

The only difference from the article I read was that I used the bolts to attach the brackets since the table legs are hollow and I didn't attach the shelf to the brackets. Total was a touch over $60 with tax and gas to get there and back ($40 if you live close to an IKEA). I love this setup and the only thing I'm gonna change is to drop the bracket down about an inch and a half somehow to get the keyboard surface at a more comfortable level. I also found that I needed to put something about 1/4" thick under my keyboard to get it to be comfortable to type on; having the keyboard at an angle was hard on my wrists.

26 May 2012

Find out where files were downloaded from with Python and xattr

Ever forget where you downloaded a file from? On OS X you can use HFS extended attributes to figure it out. Linux and Windows also support extended attributes but I don't know much about their implementations.

To find out where we downloaded a particular file from we can execute this command:
% xattr -p com.apple.metadata:kMDItemWhereFroms

The results will look like:
nya:~/Downloads % xattr -p com.apple.metadata:kMDItemWhereFroms CentOS-5.8-i386-netinstall.iso
62 70 6C 69 73 74 30 30 A2 01 02 5F 10 4C 68 74
74 70 3A 2F 2F 79 75 6D 2E 73 69 6E 67 6C 65 68
6F 70 2E 63 6F 6D 2F 43 65 6E 74 4F 53 2F 35 2E
38 2F 69 73 6F 73 2F 69 33 38 36 2F 43 65 6E 74
4F 53 2D 35 2E 38 2D 69 33 38 36 2D 6E 65 74 69
6E 73 74 61 6C 6C 2E 69 73 6F 5F 10 2E 68 74 74
70 3A 2F 2F 79 75 6D 2E 73 69 6E 67 6C 65 68 6F
70 2E 63 6F 6D 2F 43 65 6E 74 4F 53 2F 35 2E 38
2F 69 73 6F 73 2F 69 33 38 36 2F 08 0B 5A 00 00
00 00 00 00 01 01 00 00 00 00 00 00 00 03 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 8B

Attribute values are usually returned by the -p flag as strings; however, when the value contains nulls the information will be returned in hex instead. This info isn't terribly useful so let's hop over into the Python REPL and take a look.

>>> import xattr
>>> xattr.getxattr('CentOS-5.8-i386-netinstall.iso', 'com.apple.metadata:kMDItemWhereFroms')