Tag Archives: python

How to manage Google AppEngine maintenance periods

AppEngine logoHere is a small snippet of code that I use on applications deployed on Google AppEngine to inform users that the application is in maintenance mode.

It usually happen when the AppEngine team put the datastore in read-only mode for maintenance purpose but other capabilities can be tested as well.

This is a python decorator and you can use it to decorate views that require write access to the datastore. For example:

You will need to create a Django template named maintenance.html to display a warning to your users. Mine looks like this:

Properly uploading files to Amazon S3

Here is a little script I wrote and I though ought to be shared. I use it to upload static files like images, css and javascript so that they can be served by Amazon S3 instead of the main application server (like Google App Engine).

It’s written in Python and does interesting things like compressing and minifying what needs to be. It takes 3 arguments and as 2 options:

src_folder
path to the local folder containing the static files to upload
destination_bucket_name
name of the S3 bucket to upload to (e.g. static.example.com)
prefix
a prefix to use for the destination key (kind of a folder on the destination bucket, I use it to specify a release version to defeat browser caching)
x
if set, the script will set a far future expiry for all files, otherwise the S3 default will be used (one day if I remember well)
m
if set, the script will minify css and javascript files

First you will have to install some dependencies, namely boto, jsmin and cssmin. Installation procedure will depend on your OS but on my Mac I do the following:

And here is the script itself:

Thanks to Nico for the expiry trick :)

A year in review

As this year in coming to an end I though I should do a post-mortem, like at the end of a project, to see what went well and what did not.

  • I left the office I was renting downtown and started working from home: It was a good move from work perspective, being alone at home allows me to be really productive. However, as the second part of the year was getting busier it became difficult to put limits and my work/life balance suffered.
  • I worked the map editor of the DITA-OP but did not finish it: Not good at all, I have not been able to do a release this year. The other problem with the DITA-OP is that I don’t know my users. I know they are here, somewhere and I really need to find a way to gather the community.
  • I started two toys projects, SidewikiRSS.com and a Facebook application for LibraryThing: SidewikiRSS.com is rolling on its own, it does not cost me anything beside the domain name (thanks Google App Engine), it’s used regularly and bring some traffic here. fbLibraryThing is slowly but steadily growing but I am wondering if I will be able to add new features – I am completely dependent on the LibraryThing API and I will need help from the LibraryThing team if I want to go farther.
  • I completely put aside my super-secret Babelizr project: That’s not a good thing, for sure, but at least it was because of too much paid work. A positive thing is that I greatly improved my Python and Django skills with other projects and it will payoff for Babelizr.
  • I can now consider myself an Amazon Web Services and Google App Engine expert: And that’s a tremendous addition to my curriculum. I need now to dedicate more time to their respective communities.
  • I accepted too many projects in the second part of the year: The beginning of the year had been slow and I though I needed as many contacts as possible to build a sustainable business. Overall this is a good thing – especially since I exceeded my financial goals. The other positive side is that I only accepted interesting projects and that I met really nice people. But I really had a lot of pressure in the last quarter and this was definitely not the purpose of being a freelancer – “Working more to earn more” is not my moto.
  • I did not blogged enough: Especially since I gained a lot of experience in many fields and with many tools, I should have definitely written more about these.

And last, but not least:

  • I swam with sharks: Biggest thrill ever! I swam with two Oceanic Whitetip (Carcharhinus longimanus) in the Red Sea. My only regret is that I have been totally unable to take a descent picture or make a video of this event.
  • I skied almost every week-end of the winter season and hiked almost every week-end of the summer season: This prepared me really well for our 2 weeks vacation in Peru.
  • I have been more than 80 times to the movie theater: Thanks to the Pathé Pass Yang offered me last Christmas. It allowed me to see movies (good and bad) that I would not have seen otherwise.

I think I can say it was a good year, tiring, a bit stressful near the end but a good year. However, I must say it did not bring me any closer to my biggest goal that is to find ways to automate my revenue stream, so I really need to work that out next year.

The other planned features of next year are:

  • Releasing the latest version of the DITA-OP and finding a way to build and animate the community.
  • More blogging (like everyblogger else) and tweeting. Find a better organization of my Facebook presence.
  • Connecting with the LibraryThing team, although this proved to be difficult so far.
  • Coming back to Babelizr, may be starting with building external interest around the project first in order to force commitment.
  • Dedicating more time to online communities: Google App Engine, AWS, Drupal, Django, etc. May be through Stack Overflow.
  • Planning of a 4 weeks vacation dedicated to hiking or diving.
  • Watch as many movies as possible with my renewed Pathé Pass.

And, of course, keeping my clients happy :)

I only worked for two public projects this year (others are either private or still in stealth mode, so I cannot talk about them):

  • Fontself, a startup company which provides a revolutionary new experience of text, through digital text personalization. It provides digital fonts that preserves the gestures of a given handwriting and the original look of the drawing appliance (ball-point pen, pencil, ink, paper, etc.). I participated in the design of the font distribution system and its implementation on the Amazon’s cloud infrastructure using Python and Django.
  • nouvo.ch, the multimedia magazine from the Swiss Romand Television channel asked me to redevelop their website using the Drupal CMS and various media management modules.