Skip to content

Commit

Permalink
#6652 chmod replaced with osopen
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz Mitusinski committed Jan 15, 2018
1 parent b9d0b66 commit 2ebf4eb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions beakerx/beakerx/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from os import environ, path, chmod
from os import environ, path, fdopen, O_WRONLY, O_CREAT, O_TRUNC, open as osopen
from jupyter_core import paths
import json
import pathlib
Expand Down Expand Up @@ -40,10 +40,8 @@ def __init__(self):
@staticmethod
def save_setting_to_file(content):
pathlib.Path(paths.jupyter_config_dir()).mkdir(parents=True, exist_ok=True)
file = open(EnvironmentSettings.config_path, 'w+')
file.write(json.dumps(json.loads(content), indent=4, sort_keys=True))
file.close()
chmod(EnvironmentSettings.config_path, 0o600)
with fdopen(osopen(EnvironmentSettings.config_path, O_WRONLY | O_CREAT | O_TRUNC, 0o600), 'w+') as file:
file.write(json.dumps(json.loads(content), indent=4, sort_keys=True))

@staticmethod
def read_setting_from_file():
Expand Down

0 comments on commit 2ebf4eb

Please sign in to comment.