[4] | 1 | #!/usr/bin/env python |
---|
| 2 | ############################################################################ |
---|
| 3 | # |
---|
| 4 | # Copyright (C) 2005 Electronic Visualization Laboratory, |
---|
| 5 | # University of Illinois at Chicago |
---|
| 6 | # |
---|
| 7 | # All rights reserved. |
---|
| 8 | # |
---|
| 9 | # Redistribution and use in source and binary forms, with or without |
---|
| 10 | # modification, are permitted provided that the following conditions are met: |
---|
| 11 | # |
---|
| 12 | # * Redistributions of source code must retain the above copyright |
---|
| 13 | # notice, this list of conditions and the following disclaimer. |
---|
| 14 | # * Redistributions in binary form must reproduce the above |
---|
| 15 | # copyright notice, this list of conditions and the following disclaimer |
---|
| 16 | # in the documentation and/or other materials provided with the distribution. |
---|
| 17 | # * Neither the name of the University of Illinois at Chicago nor |
---|
| 18 | # the names of its contributors may be used to endorse or promote |
---|
| 19 | # products derived from this software without specific prior written permission. |
---|
| 20 | # |
---|
| 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
| 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
| 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
| 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
| 25 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
| 26 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 27 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
| 28 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
| 29 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
| 30 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
| 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | # |
---|
| 33 | # Direct questions, comments etc to www.evl.uic.edu/cavern/forum |
---|
| 34 | # |
---|
| 35 | # Author: Ratko Jagodic |
---|
| 36 | # |
---|
| 37 | ############################################################################ |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | # |
---|
| 41 | # Processes all the images in the passed in directory name and converts |
---|
| 42 | # them to DXT using a imgToDxt |
---|
| 43 | # |
---|
| 44 | # Call with: python dirToDxt.py dirName |
---|
| 45 | # |
---|
| 46 | # Author: Ratko Jagodic |
---|
| 47 | # |
---|
| 48 | |
---|
| 49 | import os, sys, os.path |
---|
| 50 | |
---|
| 51 | if len(sys.argv) < 2: |
---|
| 52 | print "\nUsage: python dirToDxt.py directoryName\n" |
---|
| 53 | sys.exit(0) |
---|
| 54 | |
---|
| 55 | count = 0 |
---|
| 56 | skippedDirs = [] |
---|
| 57 | for root, dirs, files in os.walk(sys.argv[1]): |
---|
| 58 | |
---|
| 59 | # skip dir if we have no write permissions |
---|
| 60 | if not os.access(root, os.W_OK): |
---|
| 61 | skippedDirs.append(root) |
---|
| 62 | print "\n***** No write permissions. Skipping ", root |
---|
| 63 | continue |
---|
| 64 | |
---|
| 65 | for name in files: |
---|
| 66 | # skip existing dxt files |
---|
| 67 | if name.endswith(".dxt"): |
---|
| 68 | continue |
---|
| 69 | |
---|
| 70 | count += 1 |
---|
| 71 | filePath = os.path.abspath(os.path.join(root, name)) |
---|
| 72 | print "\n\n#",count, " -------------- ", filePath, " ---------------" |
---|
| 73 | cmd = "imgToDxt '%s'" % filePath |
---|
| 74 | os.system(cmd) |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | print "\n\n", 10 * "------" |
---|
| 78 | print "Directories skipped due to insufficient write permissions:\n" |
---|
| 79 | for d in skippedDirs: |
---|
| 80 | print d |
---|
| 81 | print "\n" |
---|
| 82 | |
---|