Approval Client
Lesson learned: Ubiquity is not the ideal platform for the approval client. At least not the way I was trying to use it. I spent a few hours working to figure out a way to implement the client in ubiquity but it was not meant to be.
So, Prism to the rescue. I created a webpage locally that could interface with AWS. I like the way my client works but I’m sure that it’s not as impressive as some of the clients created by other students. After spending so long on the dead end that was Ubiquity I wanted to approach it in a way that I was fairly sure of the time requirements to finish it. One of the benefits of doing it with Prism is that I had a chance to become more familiar with jQuery.
Lab 5 – Processing Server
As everyone has been saying the lab wasn’t too difficult after doing lab 4. The most difficult part was figuring out the image processing. Fortunately, python has PIL which does most functions without too much trouble.
I spent the most time figuring out how to add text to the image and make it slightly transparent so the background could show through. In the end I had to create a new transparent image with PIL, draw the text to that image, and paste that image onto the main image.
Lab 4 – So it goes on
I spent a little more time researching before diving into coding for this lab and I think it paid off. I found a recipe for how to daemonize a python script and a decent example of how to use SQS with boto.
I’ve encountered an odd issue with sqs messages. I can write to the “commentprocess” queue and read what I write but can’t seem to see any other messages and the TA approval client doesn’t seem to see what I’ve put on the message queue. I’ve triple checked that I have the queue name correct. The only thing I can imagine it might be is that I am running from outside of the AWS network (doing testing from my machinge) and so I can only see messages I place on it and not the others. Unfortunately, at the moment all instances are filled so I am unable to test it from within AWS.
Update: It seems that it had to do with RawMessage vs. Message objects. If I made sure I was reading and writing RawMessages to the queue things seem to work.
Using the recipe above, creating a daemon ended up being really easy. I had a few bugs to work out but nothing big. The dumbest thing I tended to do with great frequency was forget to actually connect to SDB, SQS, or S3 before trying to use them. Yeah, it does help to connect before use.
Lab 3 – Implementation Notes
The first thing I had to overcome in Lab 3 was figuring out how to use boto correctly. For some reason I forgot that you need to use the AWS key and the AWS secret key to connect. Somehow I thought it would magically know who I was and what I wanted. Once I added the following variables to my script and used them, it worked great.
AWSKey=AWS_Access_Key_ID AWSSecret=AWS_Secret_Access_Key
Second issue was in calculating the correct return value for /ratesubmit. Unfortunately, just using the provided formula results in an answer that is different from that given by the TA’s implementation. Unless I am missing something really obvious, the formula provided is not the same one used by the TA implementation.
Other fun stuff to work out included getting used to the SimpleDB query language (which wasn’t too hard considering the examples given by Devlin) and working through lists, dictionaries, and json in python.
I found a couple of small display issues with my lab 2 while working on this lab. The first is that I display the rating on /list/recent even though the TA server does not. The second is that the rating isn’t truncated to 2 decimal places on /list/popular. Minor errors but errors just the same.
Lab2 – Webserver Notes
First hurdle: Reconfiguring apache to allow .css stylesheets to be served up. Turns out I needed to add a directive to the <Directory> section of httpd.conf to send .css files to the default handler.
<FilesMatch "\.(htm|html|css|js|png|jpe?g|gif)$"> SetHandler default-handler </FilesMatch>
Useful commands and paths for local development on Ubuntu:
sudo /etc/init.d/apache2 restart /etc/apache2/ /var/www/
I spent a lot of time trying to find a way to post a file without using pycurl but after searching for and trying several different things just gave up and decided it wasn’t worth the effort. Pycurl took a little getting used to but worked great once I gave up on the idea of being able to receive a file and post it back out without saving it to the disk in between. It looks like libcurl has support for sending a buffer into the function but I couldn’t find a way to recreate the behavior in pycurl.
Lab 1 – Other Issues
Zip File Password – Resolved
I had thought about using the system zip command but was hoping for a python solution. After discussing it with other students before class I decided the system zip command would probably be the quickest and least painful way to accomplish the task.
S3 Connectivity from AMI – Resolved
I didn’t think about the fact that I needed to install the boto s3 libraries on the AMI in order to be able to use them in the user data retrieval script. Up to version 3 of my AMI. Hopefully the last for this lab.
Bootstrapping Not Working for Lab Script – Resolved
Okay, this is odd. I have a test user data script that downloads google’s front page and saves it to a text file in the root directory. This works great. I have a second user data script that downloads the package from S3, unzips it and runs a secondary script. This script doesn’t work when used in the user data field but works great if run from the commandline within the instance. I can copy it over into a new file and it runs, I can run it from the saved file in tmp that the bootstrapper creates and it runs, but it won’t run on its own. No clue. Doesn’t make sense to me.
Update (23 Jan): I forgot to include full paths in the user data script. Once I put in full paths, the script worked like a champ.
Hello, World!
The title was the default for the first post but I thought it appropriate given the lab assignment.
For reference, here is some information that I found to be useful while working on this lab last night:
- httpd -k {start|stop|restart} – Changes state of apache
- ZipFile.setpassword(pwd) – allows for setting password (untested as of yet, but seems like it’ll work)
- /var/www/html – default directory for apache webserver
- /etc/httpd/conf – directory with apache configuration files
- ps aux | grep httpd – check if apache daemon is running
- http://webpython.codepoint.net/mod_python_tutorial – tutorial for getting mod_python up and running
- pg. 225-226 in book for setup of services
The most important configuration for apache after getting mod_python installed is adding
SetHandler mod_python PythonHandler mod_python.publisher PythonDebug On
to the Directory section of apache.conf.
Also, when adding bootstrapping code to the server, remember it’s
chmod +x
not
chmod -x
Wasted a few minutes finding that error. I should have just copied the text given instead of retyping it.
Leave a Comment