|
@@ -20,7 +20,13 @@ class labkeyURIHandler(slicer.vtkURIHandler):
|
|
|
slicer.vtkURIHandler.__init__(self)
|
|
|
self.className="labkeyURIHandler"
|
|
|
slicer.mrmlScene.AddURIHandler(self)
|
|
|
- self.localCacheDirectory=os.path.join(os.environ["HOME"],"labkeyCache")
|
|
|
+ try:
|
|
|
+ self.localCacheDirectory=os.path.join(
|
|
|
+ os.environ["HOME"],"labkeyCache")
|
|
|
+ except:
|
|
|
+ #in windows, the variable is called HOMEPATH
|
|
|
+ fhome=os.environ['HOMEDRIVE']+os.environ['HOMEPATH']
|
|
|
+ self.localCacheDirectory=os.path.join(fhome,"labkeyCache")
|
|
|
|
|
|
def CanHandleURI(self,uri):
|
|
|
print "labkeyURIHandler::CanHandleURI({0})".format(uri)
|
|
@@ -45,7 +51,9 @@ class labkeyURIHandler(slicer.vtkURIHandler):
|
|
|
|
|
|
def GetLocalPath(self,source):
|
|
|
relativePath=re.sub('labkey://','',source)
|
|
|
- relativePath=re.sub('/',os.sep,relativePath)
|
|
|
+ sp=os.sep.encode('string-escape')
|
|
|
+ print "Substituting / with {0} in {1}".format(sp,relativePath)
|
|
|
+ relativePath=re.sub('/',sp,relativePath)
|
|
|
return os.path.join(self.localCacheDirectory,relativePath)
|
|
|
|
|
|
def GetFile(self,source):
|
|
@@ -65,7 +73,7 @@ class labkeyURIHandler(slicer.vtkURIHandler):
|
|
|
path=os.path.dirname(dest)
|
|
|
try:
|
|
|
os.makedirs(path)
|
|
|
- except OSError:
|
|
|
+ except:
|
|
|
if not os.path.isdir(path):
|
|
|
raise
|
|
|
local=open(dest,'w')
|