Category Archives: Code
Recently I found myself in a position where I needed to have a bit more control over Lab computers – more specifically, normal screen sharing is a bit useless in a coding lab, and I found that students often wanted to use laptops instead of existing lab solutions.
LabHelper is a solution that runs through some central server. The client and server are pretty small. It’s a bit messy, but should be fairly extensible.
I recently needed to move some Picasa 2 albums from an old computer to a new one given only the old files and album files. I’d about had it with albums, so I wrote a Python script to convert .pal (Picasa albums) into regular folders.
It chokes on unicode, but dumps errors to a file for you to resolve them – just run this in a directory with your .pil files and it will create subfolders for each album and copy the pictures into them, as well. Use at your own risk.
#!/usr/bin/python2 from xml.dom.minidom import parse import os.path import shutil PICTURESPATH = "C:\\Users\\User\\Documents\\oldcomp\\My Pictures" ERRORS = open('errors.txt','w') def populateFolder(albumName): global PICTURESPATH global ERRORS doc = parse(albumName) title = [x for x in doc.getElementsByTagName("property") if x.getAttribute("name")=="name"] title = title.getAttribute("value") files = map(lambda x: x.childNodes.nodeValue, doc.getElementsByTagName("filename")) translated = map(lambda x: os.path.expandvars(x).replace("$My Pictures",PICTURESPATH), files) try: os.mkdir(title) except: ERRORS.write("Cant make directory " + title) for f in translated: try: shutil.copy(f, title + "/") except: ERRORS.write("Error in album %s: %s\n" % (title, f)) def main(): fileList = filter(lambda x: ".pal" in x, os.listdir(".")) for cFile in fileList: populateFolder(cFile) if __name__=="__main__": main()
multiftp is a multi-threaded (multiprocess) command-line FTP uploader that allows easy recursive uploading of directories. It provides an easy way to schedule fast FTP uploads via batch scripts.
- Easily script multithreaded FTP uploads
- Works via multiprocessing to circumvent threading problems.
- Automatic recursive uploads
- Ideal for situations where you need to upload an entire folder in script (i.e. publishing a website via FTP).
mtftp.py -h for a help file.
- Python 2.7.x+ (not currently Python 3 ready, but the changes are probably minimal)
The software is licensed under the MIT license, whose text can be viewed in the program source.
Get the code here.