Skip to content

Commit

Permalink
more rubustness when user dir is not writable (see #54
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Dec 17, 2014
1 parent ef7783b commit b76f6fb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions imageio/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def appdata_dir(appname=None, roaming=False):
path = os.path.join(path, appname)
if not os.path.isdir(path): # pragma: no cover
os.mkdir(path)


# Done
return path
Expand Down
6 changes: 5 additions & 1 deletion imageio/plugins/_freeimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,11 @@ def _load_freeimage(self):

# todo: we want to load from location relative to exe in frozen apps
# Get lib dirs
lib_dirs = [appdata_dir('imageio')]
lib_dirs = []
try:
lib_dirs.append(appdata_dir('imageio'))
except Exception:
pass # The home dir may not be writable

# Make sure that we have our binary version of the libary
lib_filename = get_freeimage_lib() or 'notavalidlibname'
Expand Down
17 changes: 12 additions & 5 deletions imageio/plugins/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,18 @@ def get_exe():
plat = get_platform()

if plat and plat in FNAME_PER_PLATFORM:
exe = get_remote_file('ffmpeg/' + FNAME_PER_PLATFORM[plat])
os.chmod(exe, os.stat(exe).st_mode | stat.S_IEXEC) # executable
return exe
else:
return 'ffmpeg' # Let's hope the system has ffmpeg
try:
exe = get_remote_file('ffmpeg/' + FNAME_PER_PLATFORM[plat])
os.chmod(exe, os.stat(exe).st_mode | stat.S_IEXEC) # executable
return exe
except OSError: # pragma: no cover
print("Warning: could not load imageio's ffmpeg library.")
e_type, e_value, e_tb = sys.exc_info()
del e_tb
print(str(e_value))

# Fallback, let's hope the system has ffmpeg
return 'ffmpeg'


# Get camera format
Expand Down

0 comments on commit b76f6fb

Please sign in to comment.