Skip to content

Commit

Permalink
Write rights for all on cache file (#25)
Browse files Browse the repository at this point in the history
* Write rights for all on cache file

* Correct tests and update ci matrix

* Fix chmod
  • Loading branch information
fcollonval authored Jan 24, 2020
1 parent 7856fa9 commit cb25839
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
19 changes: 6 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
12 changes: 9 additions & 3 deletions jupyter_conda/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import logging
import os
import re
import stat
import sys
import tempfile
import traceback
Expand Down Expand Up @@ -348,8 +349,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
)
)
Expand All @@ -363,11 +364,16 @@ 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_IMODE(os.stat(cache_file).st_mode) | (stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH))
PackagesHandler.__is_listing_available = False

if return_packages:
Expand Down
8 changes: 4 additions & 4 deletions jupyter_conda/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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)
Expand All @@ -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])
Expand All @@ -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()
Expand Down

0 comments on commit cb25839

Please sign in to comment.