From bec205bbd51271c4a5335f257d2d66e012ddaa39 Mon Sep 17 00:00:00 2001 From: Ulrik Johansson Date: Sun, 9 Sep 2018 13:35:12 +0200 Subject: [PATCH] Add ability to override the pyup.io API key for the check command --- docs/advanced.rst | 3 +++ pipenv/core.py | 7 ++++--- pipenv/environments.py | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/advanced.rst b/docs/advanced.rst index f3122724..a3f044cb 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -240,6 +240,9 @@ Example:: API access throttling based on overall usage rather than individual client usage. + You can also use your own safety API key by setting the + environment variable ``PIPENV_CHECK_KEY``. + ☤ Community Integrations ------------------------ diff --git a/pipenv/core.py b/pipenv/core.py index 52c127b1..830834a4 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -55,6 +55,7 @@ from .environments import ( PIPENV_DONT_USE_PYENV, SESSION_IS_INTERACTIVE, PIPENV_CACHE_DIR, + PIPENV_CHECK_KEY, ) # Packages that should be ignored later. @@ -2275,15 +2276,15 @@ def do_check( else: ignored = "" c = delegator.run( - '"{0}" {1} check --json --key=1ab8d58f-5122e025-83674263-bc1e79e0 {2}'.format( - python, escape_grouped_arguments(path), ignored + '"{0}" {1} check --json --key={2} {3}'.format( + python, escape_grouped_arguments(path), PIPENV_CHECK_KEY, ignored ) ) try: results = simplejson.loads(c.out) except ValueError: click.echo("An error occurred:", err=True) - click.echo(c.err, err=True) + click.echo(c.err if len(c.err) > 0 else c.out, err=True) sys.exit(1) for (package, resolved, installed, description, vuln) in results: click.echo( diff --git a/pipenv/environments.py b/pipenv/environments.py index b6633f39..6762709d 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -194,6 +194,7 @@ Default is to prompt the user for an answer if the current command line session if interactive. """ +PIPENV_CHECK_KEY = os.environ.get("PIPENV_CHECK_KEY", "1ab8d58f-5122e025-83674263-bc1e79e0") # Internal, support running in a different Python from sys.executable. PIPENV_PYTHON = os.environ.get("PIPENV_PYTHON")