Cut in new cursor implementation

- Fix some errors in exception handler
- Update yaspin patch
- Fix spinner

Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
Dan Ryan
2019-03-02 14:20:30 -05:00
parent 199a14ac0a
commit be3c7714ee
5 changed files with 21 additions and 14 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ import warnings
import click
import six
import urllib3.util as urllib3_util
import vistir
from pipenv.vendor import vistir
import click_completion
import crayons
@@ -1273,7 +1273,7 @@ def pip_install(
use_pep517=True
):
from pipenv.patched.notpip._internal import logger as piplogger
from .utils import Mapping
from .vendor.vistir.compat import Mapping
from .vendor.urllib3.util import parse_url
src = []
write_to_tmpfile = False
+9 -2
View File
@@ -179,7 +179,8 @@ class SystemUsageError(PipenvOptionsError):
crayons.red("Warning", bold=True)
),
]
message = crayons.blue("See also: {0}".format(crayons.white("-deploy flag.")))
if message is None:
message = crayons.blue("See also: {0}".format(crayons.white("--deploy flag.")))
super(SystemUsageError, self).__init__(option_name, message=message, ctx=ctx, extra=extra, **kwargs)
@@ -248,8 +249,14 @@ class UninstallError(PipenvException):
class InstallError(PipenvException):
def __init__(self, package, **kwargs):
message = "{0} {1}".format(
package_message = ""
if package is not None:
package_message = crayons.normal("Couldn't install package {0}\n".format(
crayons.white(package, bold=True)
))
message = "{0} {1} {2}".format(
crayons.red("ERROR:", bold=True),
package_message,
crayons.yellow("Package installation failed...")
)
extra = kwargs.pop("extra", [])
+4 -4
View File
@@ -754,19 +754,19 @@ def actually_resolve_deps(
@contextlib.contextmanager
def create_spinner(text, nospin=None, spinner_name=None):
import vistir.spin
from .vendor.vistir import spin
from .vendor.vistir.misc import fs_str
if not spinner_name:
spinner_name = environments.PIPENV_SPINNER
if nospin is None:
nospin = environments.PIPENV_NOSPIN
with vistir.spin.create_spinner(
with spin.create_spinner(
spinner_name=spinner_name,
start_text=vistir.compat.fs_str(text),
start_text=fs_str(text),
nospin=nospin, write_to_stdout=False
) as sp:
yield sp
def resolve(cmd, sp):
import delegator
from .cmdparse import Script
+3 -3
View File
@@ -17,7 +17,7 @@ import threading
import time
import colorama
import cursor
from pipenv.vendor.vistir import cursor
from .base_spinner import default_spinner
from .compat import PY2, basestring, builtin_str, bytes, iteritems, str
@@ -530,11 +530,11 @@ class Yaspin(object):
@staticmethod
def _hide_cursor():
cursor.hide()
cursor.hide_cursor()
@staticmethod
def _show_cursor():
cursor.show()
cursor.show_cursor()
@staticmethod
def _clear_line():
@@ -7,7 +7,7 @@ index d01fb98e..06b8b621 100644
import time
+import colorama
+import cursor
+from pipenv.vendor.vistir import cursor
+
from .base_spinner import default_spinner
from .compat import PY2, basestring, builtin_str, bytes, iteritems, str
@@ -48,13 +48,13 @@ index d01fb98e..06b8b621 100644
def _hide_cursor():
- sys.stdout.write("\033[?25l")
- sys.stdout.flush()
+ cursor.hide()
+ cursor.hide_cursor()
@staticmethod
def _show_cursor():
- sys.stdout.write("\033[?25h")
- sys.stdout.flush()
+ cursor.show()
+ cursor.show_cursor()
@staticmethod
def _clear_line():