Added spinner
This commit is contained in:
parent
236597848a
commit
570ede237e
@ -22,10 +22,11 @@
|
|||||||
<select />
|
<select />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="7e2256bc-a6b8-4880-83a6-8b0e3372d0a4" name="Default Changelist" comment="Improved application">
|
<list default="true" id="7e2256bc-a6b8-4880-83a6-8b0e3372d0a4" name="Default Changelist" comment="Improved workspace">
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/cpl/console/spinner_thread.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/cpl/application/application_abc.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/application/application_abc.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/cpl/console/console.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/console/console.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/cpl_cli/cli.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl_cli/cli.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/cpl_cli/publish/publisher.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl_cli/publish/publisher.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -486,20 +487,6 @@
|
|||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1605881914521</updated>
|
<updated>1605881914521</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00044" summary="Improved setup.py">
|
|
||||||
<created>1608059501153</created>
|
|
||||||
<option name="number" value="00044" />
|
|
||||||
<option name="presentableId" value="LOCAL-00044" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1608059501153</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00045" summary="Added first cli commands">
|
|
||||||
<created>1608066984496</created>
|
|
||||||
<option name="number" value="00045" />
|
|
||||||
<option name="presentableId" value="LOCAL-00045" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1608066984496</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00046" summary="Bugfixes and improved setup logic">
|
<task id="LOCAL-00046" summary="Bugfixes and improved setup logic">
|
||||||
<created>1608070231599</created>
|
<created>1608070231599</created>
|
||||||
<option name="number" value="00046" />
|
<option name="number" value="00046" />
|
||||||
@ -829,7 +816,21 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1614838148219</updated>
|
<updated>1614838148219</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="93" />
|
<task id="LOCAL-00093" summary="Readded workspace.xml">
|
||||||
|
<created>1614896688665</created>
|
||||||
|
<option name="number" value="00093" />
|
||||||
|
<option name="presentableId" value="LOCAL-00093" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1614896688665</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00094" summary="Improved workspace">
|
||||||
|
<created>1614896795653</created>
|
||||||
|
<option name="number" value="00094" />
|
||||||
|
<option name="presentableId" value="LOCAL-00094" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1614896795653</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="95" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
@ -845,8 +846,6 @@
|
|||||||
<option name="oldMeFiltersMigrated" value="true" />
|
<option name="oldMeFiltersMigrated" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="Added imports" />
|
|
||||||
<MESSAGE value="Removed build form gitignore, added build command" />
|
|
||||||
<MESSAGE value="Added init file for build command package" />
|
<MESSAGE value="Added init file for build command package" />
|
||||||
<MESSAGE value="Added pycharm files to gitignore" />
|
<MESSAGE value="Added pycharm files to gitignore" />
|
||||||
<MESSAGE value="Added more development tests" />
|
<MESSAGE value="Added more development tests" />
|
||||||
@ -870,7 +869,9 @@
|
|||||||
<MESSAGE value="Improved cpl.json" />
|
<MESSAGE value="Improved cpl.json" />
|
||||||
<MESSAGE value="Added cpl.json" />
|
<MESSAGE value="Added cpl.json" />
|
||||||
<MESSAGE value="Improved application" />
|
<MESSAGE value="Improved application" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Improved application" />
|
<MESSAGE value="Readded workspace.xml" />
|
||||||
|
<MESSAGE value="Improved workspace" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Improved workspace" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
from collections import Callable
|
||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
|
|
||||||
import pyfiglet
|
import pyfiglet
|
||||||
@ -7,6 +9,7 @@ from termcolor import colored
|
|||||||
|
|
||||||
from cpl.console.background_color import BackgroundColor
|
from cpl.console.background_color import BackgroundColor
|
||||||
from cpl.console.foreground_color import ForegroundColor
|
from cpl.console.foreground_color import ForegroundColor
|
||||||
|
from cpl.console.spinner_thread import SpinnerThread
|
||||||
|
|
||||||
|
|
||||||
class Console:
|
class Console:
|
||||||
@ -203,3 +206,16 @@ class Console:
|
|||||||
if not cls._is_first_write:
|
if not cls._is_first_write:
|
||||||
cls._output('', end='')
|
cls._output('', end='')
|
||||||
cls._output(string, x, y, end='')
|
cls._output(string, x, y, end='')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def spinner(cls, message: str, call: Callable):
|
||||||
|
cls.write(message)
|
||||||
|
spinner = SpinnerThread(cls)
|
||||||
|
spinner.start()
|
||||||
|
call()
|
||||||
|
spinner.stop_spinning()
|
||||||
|
cls.write_line()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def flush(cls):
|
||||||
|
sys.stdout.flush()
|
||||||
|
31
src/cpl/console/spinner_thread.py
Normal file
31
src/cpl/console/spinner_thread.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
class SpinnerThread(threading.Thread):
|
||||||
|
|
||||||
|
def __init__(self, console):
|
||||||
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
|
self._console = console
|
||||||
|
self._is_spinning = True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _spinner():
|
||||||
|
while True:
|
||||||
|
for cursor in '|/-\\':
|
||||||
|
yield cursor
|
||||||
|
|
||||||
|
def run(self) -> None:
|
||||||
|
spinner = self._spinner()
|
||||||
|
while self._is_spinning:
|
||||||
|
self._console.write(next(spinner))
|
||||||
|
time.sleep(0.1)
|
||||||
|
self._console.write('\b')
|
||||||
|
self._console.flush()
|
||||||
|
|
||||||
|
self._console.write(' ')
|
||||||
|
|
||||||
|
def stop_spinning(self):
|
||||||
|
self._is_spinning = False
|
||||||
|
time.sleep(0.1)
|
Loading…
Reference in New Issue
Block a user