Symlink Mirror – A Useful Python Script

Just wanted to share a useful little python script I crafted. I creates symlinks from the top level directories in a specified source folder to a target folder. Its a neat little tool for linking between two distant directories under UNIX. Share and enjoy!

#! /usr/bin/env python
"""    Symlink Mirror -----------------------------------------------------------
       Author: Dorian Pula    Version: 0.1    Date: 2008 May 29
       --------------------------------------------------------------------------
       Creates symlinks in the current directory to the top level folders inside
       a specified directory.  Its a great utility for linking a user's home
       directory with a directory holding files shared between users on the same
       system.

       Usage: python symlink_mirror.py [source of links] [target for links]
      --------------------------------------------------------------------------
       This program is free software: you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published by
       the Free Software Foundation, either version 3 of the License, or
       (at your option) any later version.

       This program is distributed in the hope that it will be useful,
       but WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       GNU General Public License for more details.

      You should have received a copy of the GNU General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>"""

import re, os, sys, stat

verbose = "True"

def main():
    """ The main function of the program. """

    'Check if there are enough arguments supplied.'
    if checkNumberOfArgs():
         'Make the path directories.'
         sourceDir = os.path.abspath(sys.argv[1])
         targetDir = os.path.abspath(sys.argv[2])

         'Get all the names of the directories.
         sourceEntries = os.listdir(sourceDir)

         for toLink in sourceEntries:
             source = os.path.join(sourceDir, toLink)
             target = os.path.join(targetDir, toLink)
             dirCheck = os.path.isdir(source)

             if((os.path.isdir(source)) and not (os.path.islink(source)) and not (os.path.exists(target))):
                  os.symlink(source, target)
                  if(verbose == "True"):
                        print "Linking " + source + " to " + target + "."

def checkNumberOfArgs():
    """
    Checks if there are enough arguments to work on.  There should be two
    arguments, the directory from which we generate the links from, and
    the directory in which the links appear. """

    argNum = len(sys.argv)
    if argNum < 1:
        print("I need a source directory to mirror.")

    elif argNum < 2:
        print("I need the directory to store the created symlinks.")

    if argNum < 2:
        print("nUsage:")
        print("python symlink_mirror.py [source of links] [target for links]n")
        return False

    else:
        return True

if __name__ == "__main__": main()

My Head in the Clouds – Cloud Computing

After much resistance, I extended part of my life on-line.

The reality is that technology plays an important role in my life. I organize, communicate, create, distribute and entertain through computing. But even with Palm, a decent Linux workstation and the web to my disposal much of this technology and its benefits are separate. While I can connect remotely to my desktop and let my groupware, Kontact handle my e-mails, RSS feeds, etc., its not convenient.

Here is where Google enters in. They have the storage and online applications that keep me and my data connected. Its not perfect. I rather using the Internet as a conduit, and maintaining everything locally. But its not realistic for me to do so. In theory, I could produce, store and transmit electricity myself (obviously with the right equipment) too. In practise, I pay a utility company to do so.

So why not do the same with computing? Thats the promise of cloud computing. Think of it as hosted web applications on steroids. Cloud computing would change computing into a utility. Use only as much as you need. Have it accessible all the time, everywhere. Imagine your desktop, mobile device, workstations and servers all communicating seamlessly with each other.

Of course, Google is not exactly cloud computing. Its close. But Google serves you and me, so that we are a captivated audience for advertisers. But I can’t complain about Google… they do host this blog after all… and a bunch of my data. However a number of companies are moving forward with utility/cloud computing: Amazon, Salesforce.com and Sun Microsystems to name a few. Exactly in what form, how and who will create a stable platform in the Internet cloud, remains to be seen. We do live in times with interesting possibilities.

Task Oriented Architecture

As neotechnophiliac (a.k.a. person crazy enough to run alpha releases of software), I love to experiment with different technology. And these tests are often for the pursuit of pointless knowledge and killing time. Technology and engineering are a lifestyle for me.

Most people don’t see technology that way. Technology comes in two flavours: toys and tools. Developing a tool is a challenge of engineering. However users don’t care about tools. (How many people care about carpentry tools?) Users want tasks done. The challenge of usability design is to create task-oriented user interfaces.

Simplicity is important in UIs. The Palm OS (IMHO) designers created one of the best UIs out there. Practically everyone (except Microsoft) in the smartphone, handheld and ultraportable market copied their design. The Zen of Palm, as a primary “pamphlet” for Palm programmers, emphasizes the importance of using a simple UI for getting a particular task done. Compare that with the desktop world, with applications looking like something out of configuration and accessibility hell. The cockpit of a jetliner often looks less daunting than a desktop office suite.

Efficient and reusable workflow helps users greatly getting their work done. A UI that lets you perform a task with 3 interactions works better than one with 5. Burning a CD under Nero, requires you either to click-through 8 screens on a wizard or navigate a massively clustered UI. Under K3B it takes a drap and drop, clicking the “Burn” button, throwing in a CD and you’re done. Neither you have to crawl through a wizard ever time. Nor do you have to deal with a clustered, non-trivial UI.

Remarkably, the most usable UI I’ve worked with, originated in the software libre world. Thats because the end-users of the programs, built those programs. Also open source, allows people to “fork” software. Forking let you take a software libre application that doesn’t meet your requirements, and built something that does from the same code base. In such an environment, software components such as UIs evolve much faster than in the proprietary world.

With my own life, I prefer using open source applications because they give me more freedom, and hence work better for me. Its amazing how much simpler, streamlined and usable most free software is. And it only gets better. I like my KDE 3 applications, but the KDE 4 applications once stablized will work even better for me. Thats because usability designers such as Celeste Lyn Paul work with the KDE developers on making better task-oriented UIs. A big thank you to all the KDE 4 developers, designers and contributers.

Blogging the Busy Life

Its funny actually. I imagined that with work, I’d have more money and time to do the things I want. Money is not the issue after all. Time on the other hand, is the ultimate scarce resource. Hence I blog less than I want to.

Fortunately as I fall into the rhythm of work, free time seems to increase slowly again. However, somethings may fall to the wayside. Like gaming. Unfortunate, but necessary. Then again I always considered gaming as a philosophy and as a thing-to-do in case of everyone else in the world being too busy.

Its funny actually. The name of this blog… I hoped to examine the seamy underbelly of open source gaming. Yet, while my blogging schedule is unreliable as most readers know, I consistently do not talk about open source gaming. One of those inside jokes, that the great machine of the universe plays on us. Or rather that the maker of said machinery, enriches our lives with.

Its funny actually. I feel that I possess more freedom to do see friends. But that too many reveal itself an illusion. Perhaps. Perhaps…

OK. Must stop slacking off and get back to doing productive… err… stuff.

(And the answer is yes. I am trying to out-do one of my blogging friends, with all this stream of consciousness. Was I successful?)