u1ftp: a demonstration of the Ubuntu One API
One of the projects I’ve been working on has been to improve aspects of the Ubuntu One Developer Documentation web site. While there are still some layout problems we are working on, it is now in a state where it is a lot easier for us to update.
I have been working on updating our authentication/authorisation documentation and revising some of the file storage documentation (the API used by the mobile Ubuntu One clients). To help verify that the documentation was useful, I wrote a small program to exercise those APIs. The result is u1ftp: a program that exposes a user’s files via an FTP daemon running on localhost. In conjunction with the OS file manager or a dedicated FTP client, this can be used to conveniently access your files on a system without the full Ubuntu One client installed.
You can download the program from:
https://launchpad.net/u1ftp/trunk/0.1/+download/u1ftp-0.1.zip
To make it easy to run on as many systems as possible, I packaged it up as a runnable zip file so can be run directly by the Python interpreter. As well as a Python interpreter, you will need the following installed to run it:
- On Linux systems, either the gnomekeyring extension (if you are using a GNOME derived desktop), or PyKDE4 (if you have a KDE derived desktop).
- On Windows, you will need pywin32.
- On MacOS X, you shouldn’t need any additional modules.
These could not be included in the zip file because they are extension modules rather than pure Python.
Once you’ve downloaded the program, you can run it with the following command:
python u1ftp-0.1.zip
This will start the FTP server listening at ftp://localhost:2121/. Pointing a file manager at that URL should prompt you to log in, where you can use your standard Ubuntu One credentials and start browsing your files. It will verify the credentials against the Ubuntu SSO service and issue an OAuth token that it stores in the keyring. The OAuth token is then used to authenticate requests to the file storage REST API.
While I expect this program to be useful on its own, it was also intended to act as an example of how the Ubuntu One API can be used. One way to browse the source is to simply unzip the package and poke around. Alternatively, you can check out the source directly from Launchpad:
bzr branch lp:u1ftp
If you come up with an interesting extension to u1ftp, feel free to upload your changes as a branch on Launchpad.