[Tutor] Pixelize ubuntu python script acting odd.

Timothy Sikes trs5678 at hotmail.com
Thu Feb 7 05:26:56 CET 2008


so I recently installed ubuntu and started messing around with some of the programs.  Pixelize takes a  picture, then using a database of other pictures, makes a picture out of the database. The only way I know of to add pictures to the database is through the command 'make_db '  It doesn't seem to accept folders, only files.

So I made this script in order to get a large number of files into it without having to type them all manually.

 def runThrough():
    walk = os.walk("/media/sda1/Documents/Pictures/2007") #location of the pics I want to use
    count = 0
    for root, dirs, files in walk:
        try:
            for x in files:
                if x.lower().find(".jpg")> -1: #If it's a .jpg...
                    count = count + 1
                    operation = 'make_db ' + root + '/' +  x
                    os.system(operation) # Call the command line with the operation above
                    print root + '/' + x #This is optional, I did this for debugging
            print str(count) + " files done"
        except OSError:
            print root + "/" + x + " was not included in the list"
        #This was run to get rid of all the obnoxious spaces in the file names
        #try:
        #    for x in files:
        #        loc = root + '/' + x
        #        pic = loc.replace(' ', "_")
        #        os.rename(loc, pic)
        #        count = count + 1
        #    print str(count) + "files done"
        #except OSError:
        #    print root + '/' + x + " was not included"

But here's the problem... My computer has randomly restarted (or logged me off possibly) every I have run the program, about thirty seconds into the program.  os.system('make_db ' + ) manually works in python, I tried it. Note: the same thing with double quotes does not work.  I have changed some stuff since I last ran this, but I haven't run it again, because my computer randomly logging me off kinda bothers me.

I am using Gusty Gibbons Ubuntu.

Thanks.
_________________________________________________________________
Shed those extra pounds with MSN and The Biggest Loser!
http://biggestloser.msn.com/


More information about the Tutor mailing list