Thursday, December 10, 2009

Extract ISO Files to Local Directory

If you would like to extract ISO files into a directory on your local machine, please do the following (should work on all *NIX machines, but I run Ubuntu).

mkdir /home/raja/extract
sudo mount -o loop -t iso9660 "location of ur iso" /home/raja/extract

This should extract your ISO into /home/raja/extract.

For the tech-savvy readers, "loop" option will make the source file read as a block device. You would typically need to give a location where it can be mounted (say, /dev/loop2) but if you dont give any, its picks up the first free loop file.
ISO9660 is the standard for CD files. Wikipedia has a nice entry about this.

Sunday, December 6, 2009

Eclipse Pydev for Django with autoreload

In an attempt to use Eclipse for Django, I was looking around to find how I can maximize productivity. IDE provides a few good things like auto completion and debug but if you were to work around it even with an IDE, then its probably not worth it.

Found "How to debug django webapp with autoreload" . That was a smart hack to hook into the autoreload mechanism to set up pydevd.settrace. Its a real pain without that to put in a

    import pydevd

in all places that you want to debug. With an IDE, you should be able to setup a breakpoint, hit the code , let it stop where you set the breakpoint and move on.

The post above indicated how things probably worked for Django pre 1.0 and dint work for me with the 1.1 codebase, Here is the modified code for that worked with Django 1.1

command = None
if len(sys.argv) != 1:
    command = sys.argv[1]
if settings.DEBUG and (command == 'runserver' or command == 'testserver'):
        import pydevd
        inEclipse = True
    except ImportError:
        inEclipse = False

    if inEclipse:
        from django.utils import autoreload
        m = autoreload.main
        def main(main_func):
            import os
            if os.environ.get("RUN_MAIN") == 'true':
                def pydevdDecorator(func):
                    def wrap(*args, **kws):
                        pydevd.settrace(suspend = False)
                        return func()
                    return wrap
                main_func = pydevdDecorator(main_func)
            return m(main_func)
        autoreload.main = main

Placing the above code in after importing the "settings" module seems to allow debugging with autoreload option on.

I also added some logic to check if Im running in Eclipse or not. I dont use Eclipse when Im not using my laptop -- vim is my friend. Its not a robust check, but works to check if we are in Eclipse or not. The idea is to not go into the auto-debug block if you are not running in Eclipse (for e.g. when you are running with vim and a command line).