Merge pull request #467 from kennethreitz/updates

notice on updates!
This commit is contained in:
2017-09-02 20:15:37 -04:00
committed by GitHub
4 changed files with 32 additions and 2 deletions
+3
View File
@@ -11,6 +11,9 @@ pew = ">=0.1.26"
pep8 = "*"
pytest = "*"
pip-tools = "*"
background = "*"
semver = "*"
requests = "*"
[requires]
python_version = "3.6"
Generated
+8 -1
View File
@@ -1,8 +1,9 @@
{
"_meta": {
"hash": {
"sha256": "76e3894ec377275576c53e478d0ecc005d0886027f0bb2962bc14faee96bb0e1"
"sha256": "f89bcf3e88bd0c33e5a924e59417f55eba7ff56069860f3faf1c57eaf269e979"
},
"pipfile-spec": 1,
"requires": {
"python_version": "3.6"
},
@@ -14,6 +15,9 @@
]
},
"default": {
"background": {
"version": "==0.1.0"
},
"certifi": {
"version": "==2017.7.27.1"
},
@@ -53,6 +57,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', timeout=0.5)
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:
+2 -1
View File
@@ -26,7 +26,8 @@ required = [
'pew>=0.1.26',
'pip',
'pip-tools>=1.9.0',
'setuptools>=36.3.0'
'setuptools>=36.3.0',
'background'
]
if sys.version_info < (2, 7):