Skip to content

Commit

Permalink
Catch exception if shape file does not include a thumbnail.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Dec 4, 2020
1 parent 074ad40 commit b7a356c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Mod/Path/PathScripts/PathToolBit.py
Expand Up @@ -322,11 +322,14 @@ def getBitThumbnail(self, obj):
path = findShape(obj.BitShape)
if path:
with open(path, 'rb') as fd:
zf = zipfile.ZipFile(fd)
pf = zf.open('thumbnails/Thumbnail.png', 'r')
data = pf.read()
pf.close()
return data
try:
zf = zipfile.ZipFile(fd)
pf = zf.open('thumbnails/Thumbnail.png', 'r')
data = pf.read()
pf.close()
return data
except KeyError:
pass
return None

def saveToFile(self, obj, path, setFile=True):
Expand Down

0 comments on commit b7a356c

Please sign in to comment.