Commit ddfad4f1760548dfc2c5277854790abb6f62843c
1 parent
ab56d6b9
Exists in
master
and in
6 other branches
FIX: Save project using relative path
Showing
5 changed files
with
19 additions
and
12 deletions
Show diff stats
invesalius/control.py
invesalius/data/mask.py
... | ... | @@ -43,12 +43,13 @@ class Mask(): |
43 | 43 | def SavePlist(self, filename): |
44 | 44 | mask = {} |
45 | 45 | filename = '%s$%s$%d' % (filename, 'mask', self.index) |
46 | + | |
46 | 47 | d = self.__dict__ |
47 | 48 | for key in d: |
48 | 49 | if isinstance(d[key], vtk.vtkImageData): |
49 | 50 | img_name = '%s_%s.vti' % (filename, key) |
50 | 51 | iu.Export(d[key], img_name, bin=True) |
51 | - mask[key] = {'$vti': img_name} | |
52 | + mask[key] = {'$vti': os.path.split(img_name)[1]} | |
52 | 53 | elif key == 'edited_points': |
53 | 54 | edited_points = {} |
54 | 55 | for p in self.edited_points: |
... | ... | @@ -57,7 +58,7 @@ class Mask(): |
57 | 58 | else: |
58 | 59 | mask[key] = d[key] |
59 | 60 | plistlib.writePlist(mask, filename + '.plist') |
60 | - return filename + '.plist' | |
61 | + return os.path.split(filename)[1] + '.plist' | |
61 | 62 | |
62 | 63 | def OpenPList(self, filename): |
63 | 64 | mask = plistlib.readPlist(filename) | ... | ... |
invesalius/data/surface.py
... | ... | @@ -54,11 +54,13 @@ class Surface(): |
54 | 54 | if isinstance(d[key], vtk.vtkPolyData): |
55 | 55 | img_name = '%s_%s.vtp' % (filename, key) |
56 | 56 | pu.Export(d[key], img_name, bin=True) |
57 | - surface[key] = {'$vtp': img_name} | |
57 | + surface[key] = {'$vtp': os.path.split(img_name)[1]} | |
58 | 58 | else: |
59 | 59 | surface[key] = d[key] |
60 | + | |
61 | + | |
60 | 62 | plistlib.writePlist(surface, filename + '.plist') |
61 | - return filename + '.plist' | |
63 | + return os.path.split(filename)[1] + '.plist' | |
62 | 64 | |
63 | 65 | def OpenPList(self, filename): |
64 | 66 | surface = plistlib.readPlist(filename) | ... | ... |
invesalius/presets.py
... | ... | @@ -102,7 +102,7 @@ class Presets(): |
102 | 102 | preset['thresh_mri'] = self.thresh_mri.copy() |
103 | 103 | preset['thresh_ct'] = self.thresh_ct.copy() |
104 | 104 | plistlib.writePlist(preset, filename) |
105 | - return filename | |
105 | + return os.path.split(filename)[1] | |
106 | 106 | |
107 | 107 | def OpenPlist(self, filename): |
108 | 108 | p = plistlib.readPlist(filename) | ... | ... |
invesalius/project.py
... | ... | @@ -185,12 +185,10 @@ class Project(object): |
185 | 185 | project['mask_dict'] = masks |
186 | 186 | img_file = '%s_%s.vti' % (filename_tmp, 'imagedata') |
187 | 187 | iu.Export(self.imagedata, img_file, bin=True) |
188 | - project['imagedata'] = {'$vti':img_file} | |
189 | - print project | |
188 | + project['imagedata'] = {'$vti':os.path.split(img_file)[1]} | |
190 | 189 | plistlib.writePlist(project, filename_tmp + '.plist') |
191 | 190 | |
192 | 191 | path = os.path.join(dir_,filename) |
193 | - print path | |
194 | 192 | Compress(dir_temp, path)#os.path.join("~/Desktop/","teste.inv3")) |
195 | 193 | shutil.rmtree(dir_temp) |
196 | 194 | |
... | ... | @@ -248,12 +246,18 @@ class Project(object): |
248 | 246 | |
249 | 247 | |
250 | 248 | def Compress(folder, filename): |
251 | - file_list = glob.glob(os.path.join(folder,"*")) | |
252 | - tar = tarfile.open(filename, "w:gz") | |
249 | + tmpdir, tmpdir_ = os.path.split(folder) | |
250 | + current_dir = os.path.abspath(".") | |
251 | + os.chdir(tmpdir) | |
252 | + file_list = glob.glob(os.path.join(tmpdir_,"*")) | |
253 | + | |
254 | + tar = tarfile.open(tmpdir_ + ".inv3", "w:gz") | |
253 | 255 | for name in file_list: |
254 | 256 | tar.add(name) |
255 | 257 | tar.close() |
256 | - | |
258 | + shutil.move(tmpdir_+ ".inv3", filename) | |
259 | + os.chdir(current_dir) | |
260 | + | |
257 | 261 | def Extract(filename, folder): |
258 | 262 | tar = tarfile.open(filename, "r:gz") |
259 | 263 | #tar.list(verbose=True) | ... | ... |