Navigation Menu

Skip to content

Commit

Permalink
shutil.move: Guard against IOError and print warnings instead of cras…
Browse files Browse the repository at this point in the history
…hing.
  • Loading branch information
mgiuca-google committed Apr 16, 2013
1 parent 9e477b3 commit 8083f25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/matplotlib/__init__.py
Expand Up @@ -642,7 +642,10 @@ def matplotlib_fname():
WARNING: Old rc filename ".matplotlibrc" found in working dir
and and renamed to new default rc file name "matplotlibrc"
(no leading"dot"). """, file=sys.stderr)
shutil.move('.matplotlibrc', 'matplotlibrc')
try:
shutil.move('.matplotlibrc', 'matplotlibrc')
except IOError as e:
print("WARNING: File could not be renamed: %s" % e, file=sys.stderr)

home = get_home()
oldname = os.path.join( home, '.matplotlibrc')
Expand All @@ -653,7 +656,10 @@ def matplotlib_fname():
WARNING: Old rc filename "%s" found and renamed to
new default rc file name "%s"."""%(oldname, newname), file=sys.stderr)

shutil.move(oldname, newname)
try:
shutil.move(oldname, newname)
except IOError as e:
print("WARNING: File could not be renamed: %s" % e, file=sys.stderr)


fname = os.path.join( os.getcwd(), 'matplotlibrc')
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/texmanager.py
Expand Up @@ -102,7 +102,10 @@ class TexManager:
WARNING: found a TeX cache dir in the deprecated location "%s".
Moving it to the new default location "%s".""" % (oldcache, texcache),
file=sys.stderr)
shutil.move(oldcache, texcache)
try:
shutil.move(oldcache, texcache)
except IOError as e:
print("WARNING: File could not be renamed: %s" % e, file=sys.stderr)
mkdirs(texcache)

_dvipng_hack_alpha = None
Expand Down

0 comments on commit 8083f25

Please sign in to comment.