Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fbd82bd

Browse files
committed
Prevents crash on some systems where chmod fails (e.g. sshfs on Windows).
Also make ProfileDir a LoggingConfigurable, so it can log the new message closes gh-773
1 parent df951f4 commit fbd82bd

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

IPython/core/profiledir.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import shutil
2626
import sys
2727

28-
from IPython.config.configurable import Configurable
28+
from IPython.config.configurable import LoggingConfigurable
2929
from IPython.config.loader import Config
3030
from IPython.utils.path import get_ipython_package_dir, expand_path
3131
from IPython.utils.traitlets import List, Unicode, Bool
@@ -47,7 +47,7 @@ class ProfileDirError(Exception):
4747
# Class for managing profile directories
4848
#-----------------------------------------------------------------------------
4949

50-
class ProfileDir(Configurable):
50+
class ProfileDir(LoggingConfigurable):
5151
"""An object to manage the profile directory and its resources.
5252
5353
The profile directory is used by all IPython applications, to manage
@@ -98,7 +98,10 @@ def check_security_dir(self):
9898
if not os.path.isdir(self.security_dir):
9999
os.mkdir(self.security_dir, 0700)
100100
else:
101-
os.chmod(self.security_dir, 0700)
101+
try:
102+
os.chmod(self.security_dir, 0700)
103+
except OSError:
104+
self.log.warn("Could not set security dir permissions to private.")
102105

103106
def _pid_dir_changed(self, name, old, new):
104107
self.check_pid_dir()
@@ -107,7 +110,10 @@ def check_pid_dir(self):
107110
if not os.path.isdir(self.pid_dir):
108111
os.mkdir(self.pid_dir, 0700)
109112
else:
110-
os.chmod(self.pid_dir, 0700)
113+
try:
114+
os.chmod(self.pid_dir, 0700)
115+
except OSError:
116+
self.log.warn("Could not set pid dir permissions to private.")
111117

112118
def check_dirs(self):
113119
self.check_security_dir()

0 commit comments

Comments
 (0)