Due to a number of requests I have cleaned up and decided to release the code for FT2JSON under the Apache license so others can make use of the software for specific applications.
The code can be found here:
https://github.com/jordoncm/ft2json
The main app engine site will of course always be hosted:
http://ft2json.appspot.com/
I have been messing around with Google Fusion Tables a lot over the past few months and I really like the service. However it really bothered me that the only format that the response data came in was CSV. I also wanted to be able to work with Fusion Tables query data entirely on the browser/client side. So I spent part of the weekend writing an application that proxies Fusion Tables API queries and transforms them from CSV into JSON. I also added a simple Javascript that you can embed on your page and then make Fusion Table queries directly from Javascript.
I posted the application on App Engine and you can find it here: http://ft2json.appspot.com
I wrote it in Python and used Tornado Web Server to help parse requests. Tornado works quite well within App Engine.
I wrote this script over a year ago because I needed a way to set the UUID of a VirtualBox hard disk (VDI) to a specific value. It will allow you to set the UUID in the headers of a VDI to a specific value.
To use this script:
./set-uuid.py {6918cef1-d9c4-4420-b0ef-01920c992a25} path/to/virtual-disk.vdi
The dashes and brackets are not required.
The script is available on my GitHub site: https://github.com/jordoncm/misc/blob/master/set-uuid.py
We had been distributing a VDI as the only file on a second physical hard drive on a dual hard drive Windows system and we wanted to be able to upgrade systems by simply removing the second hard drive with the VDI on it and putting in a new one. However the UUID of the new VDI we created did not match the UUID of the virtual hard disk record in the XML configuration of the virtual machine. So I read up on the binary header block of a VirtualBox VDI and wrote a Python script that will allow you to change the UUID to whatever you want.
It seems that VirtualBox may now have some internal commands to do this now as well, although I am not sure they are released or officially supported.
http://forums.virtualbox.org/viewtopic.php?f=6&t=4821&start=15
I was looking to learn about the Google Data Protocol so I wrote a quick Python script that will fetch Youtube videos by their playlist.
This utility allows you to download all the videos from a playlist on Youtube. It creates a folder in the current directory (or in the specified path) named after the playlist name and then downloads each video in order and places it within the folder.
If the script fails in the middle of the playlist you can restart it with the same options and should pick up where it left off.
The script depends on youtube-dl for the actual downloading of videos. It is also an easy to install Python script.
The script can be found on GitHub: https://github.com/jordoncm/youtube-dl-playlist
You can also get more details on the project page.
I actually don't work with Zope as much as I used to but I was going through some old notes and found this gem to backup a Zope instance's Data.fs file while the server is still running. Between the Data.fs file and the Products and Extensions folders you fundamentally have a full backup of your Zope instance.
/usr/lib/zope2.9/bin/repozo.py -BvzQ -r ./ -f /var/lib/zope2.9/instance/instance_name/var/Data.fs
Depending on where Zope is installed the repozo.py script may be in a different place. The -BvzQ is a basic options set (see the man page for details). The -r is where you are backing up to; in this example it is the current directory. And finally the -f is where the Zope instance's Data.fs is.
I am working on a project in Python and I want to be able to save files to other servers across a network. I did a little research and it seems like paramiko is the way to go.
This link has a good code sample of paramiko in action.
http://stackoverflow.com/questions/68335/how-do-i-copy-a-file-to-a-remote-server-in-python-using-scp-or-ssh
Here is a function to make sending email a little easier in Python.
import smtplib
import os
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
def send_mail(to, subject, text, from="", files=[], cc=[], bcc=[], server="localhost"):
assert type(to)==list
assert type(files)==list
assert type(cc)==list
assert type(bcc)==list
message = MIMEMultipart()
message['From'] = from
message['To'] = COMMASPACE.join(to)
message['Date'] = formatdate(localtime=True)
message['Subject'] = subject
message['Cc'] = COMMASPACE.join(cc)
message.attach(MIMEText(text))
for f in files:
part = MIMEBase('application', 'octet-stream')
part.set_payload(open(f, 'rb').read())
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
message.attach(part)
addresses = []
for x in to:
addresses.append(x)
for x in cc:
addresses.append(x)
for x in bcc:
addresses.append(x)
smtp = smtplib.SMTP(server)
smtp.sendmail(from, addresses, message.as_string())
smtp.close()
I got most of this code from the link below. I just cleaned it up a bit, re-prioritized the arguments and added support for both carbon copy (Cc) and blind carbon copy (Bcc).
http://snippets.dzone.com/posts/show/2038