Permalink
Browse files

Hotfix 1.0.2: Windows doesn't work!

Some fixes I thought had made it in to 1.0 hadn't.  One of them
concerns tar files which require '/' (hopefully zip will, haven't yet
tested *that*) and the other replaces '*/*.tif' in buildvrt().
  • Loading branch information...
1 parent 66dbe9f commit 97dc972412dd8a192328c9c36738283d1a670b96 @mathuin committed Oct 16, 2012
Showing with 11 additions and 7 deletions.
  1. +4 −6 region.py
  2. +7 −1 utils.py
View
@@ -12,7 +12,7 @@
from time import sleep
import zipfile
import tarfile
-from utils import cleanmkdir
+from utils import cleanmkdir, locate
from terrain import Terrain
from pymclevel import mclevel
@@ -472,7 +472,8 @@ def buildvrts(self):
(compbase, compext) = os.path.splitext(compfile)
fullfile = os.path.join(layerdir, compfile)
datasubdir = os.path.join(layerdir, compbase)
- compimage = os.path.join(compbase, "%s.%s" % (compbase, iType))
+ # tar (at least) expects Unix pathnames
+ compimage = '/'.join([compbase, "%s.%s" % (compbase, iType)])
cleanmkdir(datasubdir)
if (Region.zipfileBroken == False):
if (cType == "tgz"):
@@ -493,10 +494,7 @@ def buildvrts(self):
os.rename(os.path.join(datasubdir, omfgcompimage), os.path.join(layerdir, compimage))
cFile.close()
vrtfile = '%s.vrt' % layerID
- #buildvrtcmd = 'gdalbuildvrt %s */*.%s >/dev/null' % (vrtfile, iType)
- # NB: make this work on Windows too!
- wildcard = '*'
- buildvrtcmd = 'gdalbuildvrt %s %s' % (vrtfile, os.path.join(wildcard, '%s.%s' % (wildcard, iType)))
+ buildvrtcmd = 'gdalbuildvrt %s %s' % (vrtfile, ' '.join(['"%s"' % x for x in locate('*.%s' % iType, layerdir)]))
os.system('cd %s && %s' % (layerdir, buildvrtcmd))
def getfiles(self):
View
@@ -1,5 +1,5 @@
# utils module
-import os
+import os, fnmatch
import shutil
from memoize import memoize
from pymclevel.materials import alphaMaterials
@@ -51,3 +51,9 @@ def height(column):
retval = sum([pair[0] for pair in pairs])
return retval
+# http://code.activestate.com/recipes/499305-locating-files-throughout-a-directory-tree/
+def locate(pattern, root=os.curdir):
+ '''Locate all files matching supplied filename pattern in and below supplied root directory.'''
+ for path, dirs, files in os.walk(os.path.abspath(root)):
+ for filename in fnmatch.filter(files, pattern):
+ yield os.path.join(path, filename)

0 comments on commit 97dc972

Please sign in to comment.