Monthly Archives: March 2008

Restoring lost Modification Date/Time on My Macintosh Using Python

If you are an avid Dr. Chuck Blog reader – you recall on November 9, 2007 when I upgraded to Leopard for the second time and lost my modification dates on my files. I was too lazy to re-do the upgrade so I was left with a bunch of files with November 9, 2007 modification dates making ls -l look yucky.

http://www.dr-chuck.com/csev-blog/000139.html

I made a mistake of not reading my own earlier blog entry telling me how to properly backup and restore my home directory over a Mac OS upgrade.

http://www.dr-chuck.com/csev-blog/000381.html

Apparently I am not such an avid reader of the Dr. Chuck Blog.

Well today I rectified the situation and have my files dating back to 2004 and earlier – I don’t have a bunch of files tantalizingly telling me “November 9, 2007” – teasing me and telling me that the actual date was much earlier. I also figured I should do some Python coding this week to get up on my game as I go to Pycon 08 in Chicago next week – and hang out with none other than Steven Githens- the official badge maker of Pycon 2008!

I had saved that backup from November 2007 and vowed to write some code that would scan my current home directory and look for files with suspect modification dates (right around November 9, 2007) and grab the modification dates form the backup and patch my current home directory.

Then and only then would I be willing to “let that backup file go”. It was keeping me from reformatting a nice 320GB USB drive that I had orther uses for…

So I wrote some Python – below that uses the nice Python os.walk() capability along with the os.stat() capability, and os.utime() capability.

It turned out to be surprisingly elegant and simple in Python.

It ran pretty quickly in about 5 minutes (even reading off USB) and ended up patching about 110,000 files with the right modification date in my laptop home directory. I had a couple copies of my home directory (Mac Air, Mac Pro, and my 320GB extended home directory on USB drive) – and I patched them all.

I include the code below – with the utime() call commented out – so it does a dry run until you are happy with the results and then uncomment the utime(). It nicely can be run over and over – it only patches files in the suspect date range – once the files are moved to their proper earlier time, they are no longer candidates for patching. You can even run it live decide to freak out – press CTRL-C and start over – it will silently glide right past the already patched files.

Continue reading

Fun with JSR-168 Portlets – Google Portlet in Sakai

I was reading the uPortal lists and Cris Holdorph of Unicon made the following post:
The google portlet code is here:
http://code.google.com/p/googleportlet/
I will answer questions about the code here, but a more appropriate place would probably be: portlet-user@lists.ja-sig.org which I am also subscribed to.
All of that being said, the googleportlet does not do any web proxying at all. I think the code is interesting, in it’s simplicity, but it is not a general purpose solution to the problem of proxying.
You can also check out all of the articles and blog posts on www.unicon.net. I have several other portlet examples there.
—- Cris J H
So I went to his code site and downloaded the war file. I dropped the war file into a Sakai I had – initially it did not come up because of an empty web.xml. So I put in a stock Pluto 1.1 style web.xml (below) into the file and restarted.
Up it came and worked flawlessly – and of course with no frames.
Screen Shot of Cris Holdorph’s Google Portlet in Sakai
Another nice quick test of Sakai’s JSR-168 support.

Continue reading