Files
pipenv/tasks/vendoring/patches/vendor/yaspin-signal-handling.patch
Dan Ryan be3c7714ee Cut in new cursor implementation
- Fix some errors in exception handler
- Update yaspin patch
- Fix spinner

Signed-off-by: Dan Ryan <dan@danryan.co>
2019-03-02 14:20:30 -05:00

63 lines
2.0 KiB
Diff

diff --git a/pipenv/vendor/yaspin/core.py b/pipenv/vendor/yaspin/core.py
index d01fb98e..06b8b621 100644
--- a/pipenv/vendor/yaspin/core.py
+++ b/pipenv/vendor/yaspin/core.py
@@ -16,6 +16,9 @@ import sys
import threading
import time
+import colorama
+from pipenv.vendor.vistir import cursor
+
from .base_spinner import default_spinner
from .compat import PY2, basestring, builtin_str, bytes, iteritems, str
from .constants import COLOR_ATTRS, COLOR_MAP, ENCODING, SPINNER_ATTRS
@@ -23,6 +26,9 @@ from .helpers import to_unicode
from .termcolor import colored
+colorama.init()
+
+
class Yaspin(object):
"""Implements a context manager that spawns a thread
to write spinner frames into a tty (stdout) during
@@ -369,11 +375,14 @@ class Yaspin(object):
# SIGKILL cannot be caught or ignored, and the receiving
# process cannot perform any clean-up upon receiving this
# signal.
- if signal.SIGKILL in self._sigmap.keys():
- raise ValueError(
- "Trying to set handler for SIGKILL signal. "
- "SIGKILL cannot be cought or ignored in POSIX systems."
- )
+ try:
+ if signal.SIGKILL in self._sigmap.keys():
+ raise ValueError(
+ "Trying to set handler for SIGKILL signal. "
+ "SIGKILL cannot be cought or ignored in POSIX systems."
+ )
+ except AttributeError:
+ pass
for sig, sig_handler in iteritems(self._sigmap):
# A handler for a particular signal, once set, remains
@@ -521,14 +530,12 @@ class Yaspin(object):
@staticmethod
def _hide_cursor():
- sys.stdout.write("\033[?25l")
- sys.stdout.flush()
+ cursor.hide_cursor()
@staticmethod
def _show_cursor():
- sys.stdout.write("\033[?25h")
- sys.stdout.flush()
+ cursor.show_cursor()
@staticmethod
def _clear_line():
- sys.stdout.write("\033[K")
+ sys.stdout.write(chr(27) + "[K")