From e8493fc19cdcee33fe0a860d8735ddcbea1731ed Mon Sep 17 00:00:00 2001 From: Frederic Collonval Date: Fri, 17 Jan 2020 03:39:04 -0500 Subject: [PATCH 1/3] Write rights for all on cache file --- jupyter_conda/handlers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jupyter_conda/handlers.py b/jupyter_conda/handlers.py index 3624fc7b..b5afaf6b 100644 --- a/jupyter_conda/handlers.py +++ b/jupyter_conda/handlers.py @@ -348,8 +348,8 @@ def get(self): with open(cache_file) as cache: cache_data = cache.read() except OSError as e: - logger.warning( - "[jupyter_conda] Fail to load available packages from cache {!s}.".format( + logger.info( + "[jupyter_conda] No available packages list in cache {!s}.".format( e ) ) @@ -363,11 +363,14 @@ def update_available( with open(cache_file, "w+") as cache: json.dump(answer, cache) except (ValueError, OSError) as e: - logger.warning( + logger.info( "[jupyter_conda] Fail to cache available packages {!s}.".format( e ) ) + else: + # Change rights to ensure every body can update the cache + os.chmod(cache_file, stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH) PackagesHandler.__is_listing_available = False if return_packages: From 30d18cc26b0e4e699fb842cdb6275c5aa78f498e Mon Sep 17 00:00:00 2001 From: Frederic Collonval Date: Thu, 23 Jan 2020 09:09:15 -0500 Subject: [PATCH 2/3] Correct tests and update ci matrix --- .travis.yml | 19 ++++++------------- jupyter_conda/handlers.py | 1 + jupyter_conda/tests/test_api.py | 8 ++++---- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5d2c8a0e..ee2b589d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,26 +24,19 @@ matrix: - bash miniconda.sh -b -p $HOME/miniconda - export PATH="$HOME/miniconda/bin:$PATH" - source $HOME/miniconda/bin/activate - - name: "Windows Python 3.6" - os: windows - env: PYTHON_VERSION=3.6 DEPS="typing" + - name: "Xenial Linux Python 3.8" + env: PYTHON_VERSION=3.8 DEPS="" before_install: - - choco install miniconda3 - - . /c/tools/miniconda3/etc/profile.d/conda.sh + - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh + - bash miniconda.sh -b -p $HOME/miniconda + - export PATH="$HOME/miniconda/bin:$PATH" + - source $HOME/miniconda/bin/activate - name: "Windows Python 3.7" os: windows env: PYTHON_VERSION=3.7 DEPS="" before_install: - choco install miniconda3 - . /c/tools/miniconda3/etc/profile.d/conda.sh - - name: "macOS Python 3.6" - os: osx - env: PYTHON_VERSION=3.6 DEPS="typing" - before_install: - - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O ~/miniconda.sh - - bash ~/miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - source $HOME/miniconda/bin/activate - name: "macOS Python 3.7" os: osx env: PYTHON_VERSION=3.7 DEPS="" diff --git a/jupyter_conda/handlers.py b/jupyter_conda/handlers.py index b5afaf6b..6c95ed0f 100644 --- a/jupyter_conda/handlers.py +++ b/jupyter_conda/handlers.py @@ -10,6 +10,7 @@ import logging import os import re +import stat import sys import tempfile import traceback diff --git a/jupyter_conda/tests/test_api.py b/jupyter_conda/tests/test_api.py index dfe3a5cc..85f65985 100644 --- a/jupyter_conda/tests/test_api.py +++ b/jupyter_conda/tests/test_api.py @@ -480,7 +480,7 @@ def test_pkg_install_with_version_constraints(self): r = self.wait_for_task( self.conda_api.post, ["environments", n, "packages"], - body={"packages": [test_pkg + "==0.7.11"]}, + body={"packages": [test_pkg + "==0.7.12"]}, ) self.assertEqual(r.status_code, 200) r = self.conda_api.get(["environments", n]) @@ -490,7 +490,7 @@ def test_pkg_install_with_version_constraints(self): if p["name"] == test_pkg: v = p break - self.assertEqual(v["version"], "0.7.11") + self.assertEqual(v["version"], "0.7.12") n = generate_name() self.wait_for_task(self.mk_env, n) @@ -514,7 +514,7 @@ def test_pkg_install_with_version_constraints(self): r = self.wait_for_task( self.conda_api.post, ["environments", n, "packages"], - body={"packages": [test_pkg + ">=0.7.10,<0.7.12"]}, + body={"packages": [test_pkg + ">=0.7.10,<0.7.13"]}, ) self.assertEqual(r.status_code, 200) r = self.conda_api.get(["environments", n]) @@ -525,7 +525,7 @@ def test_pkg_install_with_version_constraints(self): v = tuple(map(int, p["version"].split("."))) break self.assertGreaterEqual(v, (0, 7, 10)) - self.assertLess(v, (0, 7, 12)) + self.assertLess(v, (0, 7, 13)) def test_package_install_development_mode(self): n = generate_name() From b9737b490fd6cada1dd28fe78e8440a296c1bacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Thu, 23 Jan 2020 17:40:32 +0100 Subject: [PATCH 3/3] Fix chmod --- jupyter_conda/handlers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jupyter_conda/handlers.py b/jupyter_conda/handlers.py index 6c95ed0f..8fbe8896 100644 --- a/jupyter_conda/handlers.py +++ b/jupyter_conda/handlers.py @@ -371,7 +371,9 @@ def update_available( ) else: # Change rights to ensure every body can update the cache - os.chmod(cache_file, stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH) + os.chmod( + cache_file, + stat.S_IMODE(os.stat(cache_file).st_mode) | (stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)) PackagesHandler.__is_listing_available = False if return_packages: