I tend to test my REST services using curl. Most of the time the JSON responses are not pretty-printed, which makes testing larger documents a pain. Copy pasting the results in online JSON formatters was really getting annoying. So I wrote a few lines of python to do that job for me. Note that this is a two-minute-hack and by no means very generic. It works for me, and with curl. The handling for Headers is especially eerie 😛 But maybe you will still find it useful.
The last hour or so I have been struggling with an “extern” definition using closurebuilder.py. When running the compiler manually, you specify externs like this:
My next step was to verify this by running the compiler manually. And it worked. So, without a doubt, it had something to do with closurebuilder.py. Suspecting a bug, I updated to the latest SVN revision. No luck. Still getting the same error.
So I dug into the code of closurebuilder, and the problem was obvious:
Each additional command-line flag --compiler_flags gets appended to a list. This list is then used as-is in the subprocess call. The subprocess API however expects each argument as a new item in the list. And technically --externs myexterns.js are two arguments. The first is --externs, the second is myexterns.js. The usual --compiler_flags="--compilation_level=ADVANCED_OPTIMIZATIONS" works because it is considered as one argument (it does not contain white-space).
So to get it working properly, you will have to modify the above line to the following:
Whether it makes sense to fix this inside closurebuilder.py is debatable. The arguments need to be passed as a list for security reasons (to be able to do proper shell escaping). Personally I don’t care that I have to specify my compiler flags in this wonky fashion. It’s in a makefile afterall…
Just today I needed to remove files from a package. And I realised that I forgot to mention that removing files from the MANIFEST.in files has a small gotcha… Here’s the small note I added to the original article:
When running the setup script, it will create a folder with the extension .egg-info. If you make changes to your MANIFEST.in file, you should delete this folder. It contains a file named SOURCES.txt which contains all the file in the package. If you remove files from your manifest, the will only disappear when that file is changes as well. So the easiest way is to delete the egg-info folder and let the setup script re-create it!
I just realized that we’ve got plenty of spam comments in our moderation queue. I did my best to clean it up. I appologize if any comments were lost in the process.
At least now We’ve got a nice collection of links to sites where I can buy cheap viagra, find adult friends, and even buy some designer luis vuitton purses! Good stuff….. -__-