upgrade message

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
2017-09-02 20:09:43 -04:00
parent 8f8579ad41
commit ceedd19943
3 changed files with 24 additions and 1 deletions
+1
View File
@@ -12,6 +12,7 @@ pep8 = "*"
pytest = "*"
pip-tools = "*"
background = "*"
semver = "*"
[requires]
python_version = "3.6"
Generated
+4 -1
View File
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "bd2336c28dabc3c3cadf760e0f49a28b6403e13ff6d2623694879836fe29e56b"
"sha256": "38b59dc070cded14f6a19f827b3423f34761232e0563da9e0c733e650bc0423c"
},
"pipfile-spec": 1,
"requires": {
@@ -72,6 +72,9 @@
"resumable-urlretrieve": {
"version": "==0.1.5"
},
"semver": {
"version": "==2.7.8"
},
"six": {
"version": "==1.10.0"
},
+19
View File
@@ -8,6 +8,7 @@ import distutils.spawn
import shutil
import signal
import background
import click
import click_completion
import crayons
@@ -16,6 +17,7 @@ import parse
import pexpect
import requests
import pipfile
import semver
from blindspin import spinner
from requests.packages.urllib3.exceptions import InsecureRequestWarning
@@ -60,6 +62,21 @@ requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
project = Project()
@background.task
def check_for_updates():
try:
r = requests.get('https://pypi.python.org/pypi/pipenv/json')
latest = sorted([semver.parse_version_info(v) for v in list(r.json()['releases'].keys())])[-1]
current = semver.parse_version_info(__version__)
if latest > current:
click.echo('{0}: {1} is now available. You get bonus points for upgrading!'.format(
crayons.green('Courtesy Notice'),
crayons.yellow('Pipenv v{v.major}.{v.minor}.{v.patch}'.format(v=latest)),
), err=True)
except Exception:
pass
def cleanup_virtualenv(bare=True):
"""Removes the virtualenv directory from the system."""
@@ -790,6 +807,8 @@ def easter_egg(package_name):
@click.pass_context
def cli(ctx, where=False, venv=False, rm=False, bare=False, three=False, python=False, help=False):
check_for_updates()
if ctx.invoked_subcommand is None:
# --where was passed...
if where: