Skip to content

Commit

Permalink
Merge pull request #286 from minrk/no-sticky-darwin
Browse files Browse the repository at this point in the history
Soften and suppress warnings about sticky bits
  • Loading branch information
takluyver authored Aug 10, 2017
2 parents af1b570 + 02bd877 commit 1c506c0
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions jupyter_client/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from __future__ import absolute_import

import errno
import glob
import json
import os
Expand Down Expand Up @@ -148,14 +149,19 @@ def write_connection_file(fname=None, shell_port=0, iopub_port=0, stdin_port=0,
new_permissions = permissions | stat.S_ISVTX
if new_permissions != permissions:
try:
os.chmod(path, permissions)
os.chmod(path, new_permissions)
except OSError as e:
# failed to set sticky bit,
# probably not a big deal
warnings.warn(
"Failed to set sticky bit on %r: %s" % (path, e),
RuntimeWarning,
)
if e.errno == errno.EPERM and path == runtime_dir:
# suppress permission errors setting sticky bit on runtime_dir,
# which we may not own.
pass
else:
# failed to set sticky bit, probably not a big deal
warnings.warn(
"Failed to set sticky bit on %r: %s"
"\nProbably not a big deal, but runtime files may be cleaned up periodically." % (path, e),
RuntimeWarning,
)

return fname, cfg

Expand Down

0 comments on commit 1c506c0

Please sign in to comment.